CVE-2026-41496: PraisonAI SQL Injection Vulnerability

HIGH
Advisory Identifier: GHSA-rg3h-x3jw-7jm5
CVSS 8.1
CWE-89
Published
Advisory Summary

CVE-2026-41496 is a HIGH (CVSS 8.1) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting PraisonAI libraries in the PyPI ecosystem. The issue involves sql injection via unvalidated `table_prefix` in 9 conversation store backends (incomplete fix for cve-2026-40315). Remediation is available by upgrading affected packages to version 4.5.149, 1.6.8.

CVE-2026-41496 at a Glance

CVE Identifier CVE-2026-41496
GHSA Identifier GHSA-rg3h-x3jw-7jm5
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product PraisonAI
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-41496

To remediate this vulnerability, upgrade all affected PraisonAI dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

praisonai fixed: 4.5.149
pip install praisonai>=4.5.149
praisonaiagents fixed: 1.6.8
pip install praisonaiagents>=1.6.8
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show praisonai

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-41496, inspect your installed packages using pip:

pip show praisonai

Analyze the terminal output to locate any version of PraisonAI in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.5.149), your application is affected.

Note: The pip show praisonai command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In PraisonAI, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

The fix for [CVE-2026-40315](https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-x783-xp3g-mqhp) added input validation to `SQLiteConversationStore` only. Nine sibling backends — MySQL, PostgreSQL, async SQLite/MySQL/PostgreSQL, Turso, SingleStore, Supabase, SurrealDB — pass `table_prefix` straight into f-string SQL. Same root cause, same code pattern, same exploitation. 52 unvalidated injection points across the codebase. `postgres.py` additionally accepts an unvalidated `schema` parameter used directly in DDL. ### Severity **High** — CWE-89 (SQL Injection) CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N — **8.1** Exploitable in any deployment where `table_prefix` is derived from external input (multi-tenant setups, API-driven configuration, user-modifiable config files). Default config (`"praison_"`) is not affected. ### Details The [CVE-2026-40315 fix](https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-x783-xp3g-mqhp) added this guard to `sqlite.py:52`: ```python # sqlite.py — PATCHED import re if not re.match(r'^[a-zA-Z0-9_]*$', table_prefix): raise ValueError("table_prefix must contain only alphanumeric characters and underscores") ``` The following backends perform the identical `table_prefix → f-string SQL` pattern **without this guard**: | Backend | File | Line | Injection points | | ---------------- | -------------------------------------------- | --------------- | ----------------------- | | MySQL | `persistence/conversation/mysql.py` | 65 | 5 | | PostgreSQL | `persistence/conversation/postgres.py` | 89 (+schema:88) | 10 | | Async SQLite | `persistence/conversation/async_sqlite.py` | 43 | 13 | | Async MySQL | `persistence/conversation/async_mysql.py` | 65 | 13 | | Async PostgreSQL | `persistence/conversation/async_postgres.py` | 63 | 13 | | Turso/LibSQL | `persistence/conversation/turso.py` | 66 | 9 | | SingleStore | `persistence/conversation/singlestore.py` | 51 | 7 | | Supabase | `persistence/conversation/supabase.py` | 68 | 9 | | SurrealDB | `persistence/conversation/surrealdb.py` | 57 | 8 | | **Total** | **9 backends** | | **52 injection points** | Additionally, `praisonai-agents/praisonaiagents/storage/backends.py:179` (`SQLiteBackend`) accepts `table_name` without validation. ### PoC ```python #!/usr/bin/env python3 """ Demonstrates: sqlite.py rejects malicious table_prefix, mysql.py accepts it. Run: python3 poc.py (no dependencies required) """ import re payload = "x'; DROP TABLE users; --" # ── SQLite (patched) ──────────────────────────────────────────────── try: if not re.match(r'^[a-zA-Z0-9_]*$', payload): raise ValueError("blocked") print(f"[SQLite] FAIL — accepted: {payload}") except ValueError: print(f"[SQLite] OK — rejected malicious table_prefix") # ── MySQL (unpatched) ─────────────────────────────────────────────── sessions_table = f"{payload}sessions" sql = f"CREATE TABLE IF NOT EXISTS {sessions_table} (session_id VARCHAR(255) PRIMARY KEY)" print(f"[MySQL] VULN — generated SQL:\n {sql}") # ── PostgreSQL (unpatched — both table_prefix AND schema) ────────── schema = "public; DROP SCHEMA data CASCADE; --" sessions_table = f"{schema}.praison_sessions" sql = f"CREATE SCHEMA IF NOT EXISTS {schema}" print(f"[Postgres] VULN — schema injection:\n {sql}") ``` Output: ``` [SQLite] OK — rejected malicious table_prefix [MySQL] VULN — generated SQL: CREATE TABLE IF NOT EXISTS x'; DROP TABLE users; --sessions (session_id VARCHAR(255) PRIMARY KEY) [Postgres] VULN — schema injection: CREATE SCHEMA IF NOT EXISTS public; DROP SCHEMA data CASCADE; -- ``` ### Vulnerable code (mysql.py, representative) ```python # mysql.py:65-67 — NO validation self.table_prefix = table_prefix # ← raw input self.sessions_table = f"{table_prefix}sessions" # ← into identifier self.messages_table = f"{table_prefix}messages" # mysql.py:105 — straight into DDL cur.execute(f""" CREATE TABLE IF NOT EXISTS {self.sessions_table} ( session_id VARCHAR(255) PRIMARY KEY, ... ) """) ``` Compare with the patched `sqlite.py:52`: ```python # sqlite.py:52-53 — HAS validation if not re.match(r'^[a-zA-Z0-9_]*$', table_prefix): raise ValueError("table_prefix must contain only alphanumeric characters and underscores") ``` ### Impact When `table_prefix` originates from untrusted input — multi-tenant tenant names, API request parameters, user-editable config — an attacker achieves **arbitrary SQL execution** against the backing database. The injected SQL runs in the context of DDL and DML operations (CREATE TABLE, INSERT, SELECT, DELETE), giving the attacker read/write/delete access to the entire database. PostgreSQL's `schema` parameter adds a second injection vector in DDL (`CREATE SCHEMA IF NOT EXISTS {schema}`).

CVE-2026-41496 Affected PraisonAI Versions

2 component(s)
Fixed Versions:
4.5.1491.6.8
Product / Package Ecosystem Affected Versions Fixed Version
praisonai
PyPI
< 4.5.149
4.5.149
praisonaiagents
PyPI
< 1.6.8
1.6.8

References

Frequently Asked Questions

What is CVE-2026-41496?
CVE-2026-41496 is a security vulnerability in PraisonAI involving SQL Injection via unvalidated `table_prefix` in 9 conversation store backends (incomplete fix for CVE-2026-40315) under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which PraisonAI versions are affected?
Affected versions include releases prior to 4.5.149, 1.6.8 across affected packages: praisonai, praisonaiagents.
What version fixes CVE-2026-41496?
Upgrading to 4.5.149, 1.6.8 (or the latest patched release for your respective branch) resolves the vulnerability.
Is praisonai affected?
Yes, praisonai is affected in releases prior to 4.5.149. Upgrade your dependency to 4.5.149 or later.
Is praisonaiagents affected?
Yes, praisonaiagents is affected in releases prior to 1.6.8. Upgrade your dependency to 1.6.8 or later.
What is the CVSS score of CVE-2026-41496?
CVE-2026-41496 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-41496?
CVE-2026-41496 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check PyPI dependencies for CVE-2026-41496?
Run the dependency tree command: 'pip show praisonai'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-rg3h-x3jw-7jm5",
  "modified" : "2026-05-12T13:32:02Z",
  "published" : "2026-04-17T22:24:19Z",
  "aliases" : [ "CVE-2026-41496" ],
  "summary" : "PraisonAI: SQL Injection via unvalidated `table_prefix` in 9 conversation store backends (incomplete fix for CVE-2026-40315)",
  "details" : "The fix for [CVE-2026-40315](https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-x783-xp3g-mqhp) added input validation to `SQLiteConversationStore` only. Nine sibling backends — MySQL, PostgreSQL, async SQLite/MySQL/PostgreSQL, Turso, SingleStore, Supabase, SurrealDB — pass `table_prefix` straight into f-string SQL. Same root cause, same code pattern, same exploitation. 52 unvalidated injection points across the codebase.\n\n`postgres.py` additionally accepts an unvalidated `schema` parameter used directly in DDL.\n\n### Severity\n\n**High** — CWE-89 (SQL Injection)\n\nCVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N — **8.1**\n\nExploitable in any deployment where `table_prefix` is derived from external input (multi-tenant setups, API-driven configuration, user-modifiable config files). Default config (`\"praison_\"`) is not affected.\n\n### Details\n\nThe [CVE-2026-40315 fix](https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-x783-xp3g-mqhp) added this guard to `sqlite.py:52`:\n\n```python\n# sqlite.py — PATCHED\nimport re\nif not re.match(r'^[a-zA-Z0-9_]*$', table_prefix):\n    raise ValueError(\"table_prefix must contain only alphanumeric characters and underscores\")\n```\n\nThe following backends perform the identical `table_prefix → f-string SQL` pattern **without this guard**:\n\n| Backend          | File                                         | Line            | Injection points        |\n| ---------------- | -------------------------------------------- | --------------- | ----------------------- |\n| MySQL            | `persistence/conversation/mysql.py`          | 65              | 5                       |\n| PostgreSQL       | `persistence/conversation/postgres.py`       | 89 (+schema:88) | 10                      |\n| Async SQLite     | `persistence/conversation/async_sqlite.py`   | 43              | 13                      |\n| Async MySQL      | `persistence/conversation/async_mysql.py`    | 65              | 13                      |\n| Async PostgreSQL | `persistence/conversation/async_postgres.py` | 63              | 13                      |\n| Turso/LibSQL     | `persistence/conversation/turso.py`          | 66              | 9                       |\n| SingleStore      | `persistence/conversation/singlestore.py`    | 51              | 7                       |\n| Supabase         | `persistence/conversation/supabase.py`       | 68              | 9                       |\n| SurrealDB        | `persistence/conversation/surrealdb.py`      | 57              | 8                       |\n| **Total**        | **9 backends**                               |                 | **52 injection points** |\n\nAdditionally, `praisonai-agents/praisonaiagents/storage/backends.py:179` (`SQLiteBackend`) accepts `table_name` without validation.\n\n### PoC\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nDemonstrates: sqlite.py rejects malicious table_prefix, mysql.py accepts it.\nRun: python3 poc.py  (no dependencies required)\n\"\"\"\nimport re\n\npayload = \"x'; DROP TABLE users; --\"\n\n# ── SQLite (patched) ────────────────────────────────────────────────\ntry:\n    if not re.match(r'^[a-zA-Z0-9_]*$', payload):\n        raise ValueError(\"blocked\")\n    print(f\"[SQLite] FAIL — accepted: {payload}\")\nexcept ValueError:\n    print(f\"[SQLite] OK — rejected malicious table_prefix\")\n\n# ── MySQL (unpatched) ───────────────────────────────────────────────\nsessions_table = f\"{payload}sessions\"\nsql = f\"CREATE TABLE IF NOT EXISTS {sessions_table} (session_id VARCHAR(255) PRIMARY KEY)\"\nprint(f\"[MySQL]  VULN — generated SQL:\\n  {sql}\")\n\n# ── PostgreSQL (unpatched — both table_prefix AND schema) ──────────\nschema = \"public; DROP SCHEMA data CASCADE; --\"\nsessions_table = f\"{schema}.praison_sessions\"\nsql = f\"CREATE SCHEMA IF NOT EXISTS {schema}\"\nprint(f\"[Postgres] VULN — schema injection:\\n  {sql}\")\n```\n\nOutput:\n\n```\n[SQLite] OK — rejected malicious table_prefix\n[MySQL]  VULN — generated SQL:\n  CREATE TABLE IF NOT EXISTS x'; DROP TABLE users; --sessions (session_id VARCHAR(255) PRIMARY KEY)\n[Postgres] VULN — schema injection:\n  CREATE SCHEMA IF NOT EXISTS public; DROP SCHEMA data CASCADE; --\n```\n\n### Vulnerable code (mysql.py, representative)\n\n```python\n# mysql.py:65-67 — NO validation\nself.table_prefix = table_prefix                    # ← raw input\nself.sessions_table = f\"{table_prefix}sessions\"     # ← into identifier\nself.messages_table = f\"{table_prefix}messages\"\n\n# mysql.py:105 — straight into DDL\ncur.execute(f\"\"\"\n    CREATE TABLE IF NOT EXISTS {self.sessions_table} (\n        session_id VARCHAR(255) PRIMARY KEY, ...\n    )\n\"\"\")\n```\n\nCompare with the patched `sqlite.py:52`:\n\n```python\n# sqlite.py:52-53 — HAS validation\nif not re.match(r'^[a-zA-Z0-9_]*$', table_prefix):\n    raise ValueError(\"table_prefix must contain only alphanumeric characters and underscores\")\n```\n\n### Impact\n\nWhen `table_prefix` originates from untrusted input — multi-tenant tenant names, API request parameters, user-editable config — an attacker achieves **arbitrary SQL execution** against the backing database. The injected SQL runs in the context of DDL and DML operations (CREATE TABLE, INSERT, SELECT, DELETE), giving the attacker read/write/delete access to the entire database.\n\nPostgreSQL's `schema` parameter adds a second injection vector in DDL (`CREATE SCHEMA IF NOT EXISTS {schema}`).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "praisonai"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.5.149"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.5.148"
    }
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "praisonaiagents"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.6.8"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.6.7"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-rg3h-x3jw-7jm5"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-41496"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/MervinPraison/PraisonAI"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-17T22:24:19Z",
    "nvd_published_at" : "2026-05-08T14:16:33Z"
  }
}