/

CVE-2026-34934

Severity:

CRITICAL RISK

(9.8)

SQL Injection in PraisonAI get_all_user_threads Query

CVE-2026-34934

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Execution and Full Database Compromise

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

PraisonAI contained a critical SQL injection vulnerability where the get_all_user_threads function built raw SQL queries with f-strings, directly interpolating unescaped thread IDs.

An attacker able to store a crafted thread ID via update_thread could trigger arbitrary SQL execution when the thread list is loaded, potentially gaining full database access.

Affected context

The vulnerability occurs in PraisonAI's data access layer responsible for listing user threads, specifically in the get_all_user_threads function.

The issue manifests when:

  • Thread identifiers from persistent storage are treated as trusted values
  • Raw SQL queries are constructed via Python f-strings or string concatenation
  • No parameterized queries or escaping are applied to the thread IDs before query execution

This pattern can appear in any environment where PraisonAI is deployed with a relational database backend.

Exploit preconditions

  • Attack surface: Application backend functions that load user thread lists from the database.
  • Required access: Ability to invoke update_thread or any feature that can persist or modify thread IDs (e.g., via authenticated API or compromised internal process).
  • Trigger point: Any operation that calls get_all_user_threads and executes the dynamically constructed SQL containing the malicious thread ID.
  • Why exploitation is possible: The application directly embeds thread IDs into SQL statements using f-strings without parameterization or sanitization, allowing attacker-controlled content to be interpreted as SQL syntax.

Why this happens

This vulnerability stems from constructing SQL queries by concatenating or interpolating untrusted data into query strings, instead of using parameterized queries.

In PraisonAI, get_all_user_threads uses Python f-strings with thread IDs retrieved from the database, assuming they are safe. However, because update_thread allows an attacker to store arbitrary content as a thread ID, that content can later be reinterpreted as part of the SQL statement.

This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the failure to neutralize metacharacters in input allows attackers to alter the structure and logic of database queries.

Potential impact

  • Execution of arbitrary SQL commands against the application database
  • Reading, modifying, or deleting sensitive user and application data
  • Creation of new privileged accounts or escalation of existing privileges at the application or database layer
  • Destruction or corruption of database tables, leading to denial of service
  • Bypassing application-level authorization by directly manipulating data relationships

General mitigation guidance

Mitigation should focus on eliminating direct string-based query construction and enforcing strict separation between SQL code and data:

  • Use parameterized queries (prepared statements) provided by the database driver or ORM for all dynamic values, including identifiers where supported.
  • Avoid constructing SQL with f-strings, string concatenation, or format operations that include any value that has ever been influenced by users or external systems.
  • Introduce strict validation and normalization for identifiers such as thread IDs (e.g., enforcing specific formats or types) before they are used in database operations.
  • Centralize database access in a well-reviewed data access layer where secure query patterns are enforced by default.
  • Apply least-privilege principles to database accounts so that even if a query is abused, the scope of damage is constrained.

How teams detect issues like this

Organizations can detect similar issues by:

  • Running static analysis rules that flag raw SQL construction using string interpolation (f-strings, %, .format, or concatenation) with variable content.
  • Reviewing code paths where identifiers (IDs, keys, names) are persisted and later reused in SQL statements, ensuring parameterization at every step.
  • Implementing secure coding guidelines and pre-commit or CI checks that disallow direct SQL string composition except in vetted, parameterized helper functions.
  • Using dynamic application security testing (DAST) or interactive testing to probe API endpoints like update_thread and list-threads for SQL injection behavior.
  • Logging anomalous SQL errors and patterns (e.g., syntax errors containing user-controlled fragments) and monitoring for suspicious query activity.

Sources

SourceLink
github.comgithub.com/MervinPraison/PraisonAI/security/advisories/GHSA-9cq8-3v94-434g

Frequently asked

questions

Yes, it can be remotely exploitable if an attacker can reach the update_thread functionality over the network and later cause the application to load user threads, thereby executing the injected SQL.

The attacker needs the ability to store or modify thread IDs, typically via authenticated access to relevant APIs or a compromised component that interacts with update_thread. Once this is achieved, further access to trigger get_all_user_threads is required, which may occur during normal application use.

Replace all string-interpolated SQL with parameterized queries throughout the codebase, ensuring that every dynamic value is passed as a bound parameter rather than embedded directly into the SQL text. Complement this with strict validation of identifiers and centralized, reusable query helpers.

Adopt a development policy that forbids ad hoc SQL string construction, enforce secure database access patterns via code review and automated checks, and train developers on safe query practices. Using ORMs or query builders that default to parameterization and regularly running security-focused tests against database-facing endpoints can further reduce risk.

Find out what's already
exploitable in your codebase.