Langroid CVE-2026-54760
CRITICALAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessInfluence agent's LLM-generated SQL
-
DeliveryEmit obfuscated pg_read_file call
-
ExploitEvade raw-text regex blocklist
-
ExecutionPass sqlglot SELECT-only allowlist
-
PersistExecute pg_read_file on PostgreSQL server
-
ImpactExfiltrate server-side file contents
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V5 - File Handling Path canonicalization, traversal prevention
MITRE ATT&CK
2 techniques across 2 tactics: Discovery, Collection The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires a deployment that uses Langroid's SQLChatAgent against a PostgreSQL backend where the database role can invoke |
| Impact | The published CVSS 4.0 score is 9.3 (Critical) with vector AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H, but that rating appears overstated relative to the advisory's own description. The reporter explicitly assesses this as High, not Critical, and 'by parity' with the parent advisory. Two conflicts stand out: (1) the primitive is a read-only file disclosure via |
| Exploit ScenarioDerived | A web application uses Langroid's SQLChatAgent to answer natural-language data questions against a PostgreSQL database via a superuser connection. An attacker submits a prompt crafted so the LLM emits |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv3 – Jul 10, 2026
Server-side file disclosure in Langroid's SQLChatAgent (Python, pip package langroid <= 0.65.0) lets an attacker who can influence the agent's LLM-generated SQL bypass the _validate_query safety guard and execute PostgreSQL file-read functions such as pg_read_file. The default allow_dangerous_operations=False blocklist relies on a raw-text regex requiring pg_... names to be immediately followed by (, which is evaded by quoted identifiers, inline comments, or schema qualification while still parsing as a permitted SELECT. This is a bypass of the earlier CVE-2026-25879 / GHSA-pmch-g965-grmr regex fix; a working reproduction harness is published in the GHSA advisory, though there is no public exploit identified as being used in active attacks and no CISA KEV listing.
Earlier versions of this analysis (2)
Server-side file read in Langroid's SQLChatAgent (pip package langroid <= 0.65.0) lets an attacker who can influence the agent's LLM-generated SQL bypass the default dangerous-function guard and invoke PostgreSQL file-read functions such as pg_read_file. The guard's raw-text regex blocklist only matches a pg_* name immediately followed by '(', so quoted identifiers ("pg_read_file"(...)), inline comments (pg_read_file/**/(...)), and schema qualification (pg_catalog."pg_read_file"(...)) evade it while still parsing as SELECT and executing. This re-opens the exact primitive that the prior CVE-2026-25879 / GHSA-pmch-g965-grmr fix intended to close; publicly available exploit code exists in the advisory reproduction, there is no CISA KEV listing, and it is fixed in 0.65.1.
Server-side file read in the Langroid (pip:langroid) Python agent framework's SQLChatAgent allows an attacker who can influence LLM-generated SQL to bypass the built-in dangerous-operation guard even with the default allow_dangerous_operations=False. The mitigation's raw-text regex blocklist only matches PostgreSQL functions when the name is directly followed by '(', so quoted-identifier, inline-comment, and schema-qualified forms (e.g. "pg_read_file"(...), pg_read_file/**/(...), pg_catalog."pg_read_file"(...)) evade it while still parsing as SELECT and executing pg_read_file. This re-opens the exact file-read primitive that the parent advisory CVE-2026-25879 / GHSA-pmch-g965-grmr tried to close; a working proof-of-concept is documented in the advisory, but there is no CISA KEV listing and no evidence of active exploitation.
RemediationAI
Vendor-released patch: upgrade langroid to 0.65.1 or later, which is the fixed version per GHSA-6xc5-4r68-67fc (https://github.com/langroid/langroid/security/advisories/GHSA-6xc5-4r68-67fc). Beyond patching, apply defense-in-depth per the advisory's guidance: run SQLChatAgent with a least-privilege PostgreSQL role that is NOT a superuser and has not been granted pg_read_server_files, which removes the pg_read_file primitive entirely (trade-off: none for typical read-query workloads, since legitimate SQLChatAgent use does not need server-file access). Where feasible, keep allow_dangerous_operations=False (the default) and treat all user-influenced content feeding the agent as untrusted. As a structural hardening measure the vendor recommends AST-based validation - walking the sqlglot parse tree and rejecting any function whose normalized, unquoted, schema-stripped, case-folded name is in a dangerous set (pg_read_file, pg_read_binary_file, pg_ls_dir, pg_stat_file, lo_import, lo_export, load_file, load_extension) rather than relying on raw-text regex; upgrading to 0.65.1 is the way to obtain this fix rather than hand-patching.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Langroid is an open-source Python framework for building LLM agents; its SQLChatAgent translates natural-language requests into SQL and executes them against a configured database. The safety layer combines two mechanisms: a regex blocklist (_DANGEROUS_SQL_PATTERNS) applied to the raw query text, and a sqlglot-based allowlist that only permits top-level SELECT statements. The vulnerable regex \bpg_(read|stat|ls|current_logfile)[A-Za-z0-9_]*\s*\( matches a dangerous function only when the identifier is directly followed by optional whitespace and an opening parenthesis. PostgreSQL's parser, however, treats "pg_read_file"(...) (quoted identifier), pg_read_file/**/(...) (inline comment), and pg_catalog."pg_read_file"(...) (schema qualification) as the same callable function. Because _validate_query uses sqlglot only to check statement type and never walks the parsed AST to normalize and match function names, these obfuscated-but-equivalent calls pass both checks. This is the CWE-184 (incomplete blocklist) root cause, classified under CWE-22 because it yields server-side path/file read; the file-read primitive itself is PostgreSQL's pg_read_file and related functions (pg_read_binary_file, pg_ls_dir, pg_stat_file).
Know when PostgreSQL gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
AC:H because it needs a privileged pg_read_file role plus attacker influence over generated SQL; read-only host-file disclosure gives C:H, I/A:N, and S:C since files outside the DB are read.
Primary rating from Vendor (https://github.com/langroid/langroid).
CVSS VectorVendor: https://github.com/langroid/langroid
Lifecycle Timeline
3DescriptionCVE.org
SQLChatAgent _validate_query dangerous-pattern regex is bypassable via quoted/commented/qualified function names
Summary
The SQLChatAgent SQL-injection mitigation, with default allow_dangerous_operations=False, combines a raw-text regex blocklist (_DANGEROUS_SQL_PATTERNS) with a sqlglot SELECT-only statement allowlist. The blocklist entries that target callable functions require the function name to be immediately followed by \s*\(.
PostgreSQL accepts the same call with the name separated from ( by a quoted identifier, an inline comment, or schema qualification. These forms evade the regex, still parse as SELECT, and execute the same PostgreSQL function. This restores the pg_read_file server-side file-read primitive that the prior CVE-2026-25879 / GHSA-pmch-g965-grmr fix was meant to block: the parent advisory fixed a missing pg_read_file blocklist entry, while this report shows that the added regex is bypassable.
Affected Code
Tested against current main commit:
6e8e7b2bb23ec04c1c25be479f16b8cc9a4f8796
The current source still contains:
re.compile(r"\bpg_(read|stat|ls|current_logfile)[A-Za-z0-9_]*\s*\(", re.IGNORECASE)_validate_query checks the raw query against _DANGEROUS_SQL_PATTERNS, then parses with sqlglot and allows SELECT statements. The dangerous-call check is raw text, not normalized AST function-name matching.
Root Cause
The current mitigation treats dangerous PostgreSQL function calls as a raw-text regex problem. The regex requires the pg_... function token to be followed directly by optional whitespace and (, but PostgreSQL accepts equivalent calls through quoted identifiers, comments, and schema-qualified names. Because _validate_query only uses sqlglot to enforce the top-level statement type, those normalized function names are never checked after parsing.
Auth Boundary
The boundary is the default SQLChatAgent safety policy between attacker-influenced SQL generation and database operations that can read server-side files. With allow_dangerous_operations=False, a user or prompt that influences generated SQL should not be able to bypass the guard and execute PostgreSQL file-read functions such as pg_read_file.
This is not a new unauthenticated endpoint or product-wide SQL injection; it applies when untrusted user content can influence SQLChatAgent's generated SQL.
Reproduction
The local harness uses the current sql_chat_agent.py, extracts the real shipped dangerous regex list, validates the queries with real sqlglot==30.8.0, then executes the accepted bypasses against a local throwaway PostgreSQL 16 container.
Transcript excerpt:
CONTROL "SELECT pg_read_file('/etc/passwd')" -> REJECTED: matches '\\bpg_(read|stat|ls|current_logfile)[A-Za-z0-9_]*\\s*\\('
BYPASS 'SELECT "pg_read_file"(\'/etc/passwd\')' -> ALLOWED (validator returned None -> would execute)
BYPASS "SELECT pg_read_file/**/('/etc/passwd')" -> ALLOWED (validator returned None -> would execute)
BYPASS 'SELECT pg_catalog."pg_read_file"(\'/etc/passwd\')' -> ALLOWED (validator returned None -> would execute)
=== Part B: real PostgreSQL execution of the bypass ===
connected; is_superuser=t
executed bypass 'SELECT "pg_read_file"(\'<file>\')' -> file contents returned: 'LANGROID_SAFE_MARKER_...'
executed bypass "SELECT pg_read_file/**/('<file>')" -> file contents returned: 'LANGROID_SAFE_MARKER_...'
executed bypass 'SELECT pg_catalog."pg_read_file"(\'<file>\')' -> file contents returned: 'LANGROID_SAFE_MARKER_...'
RESULT: VULNERABLEThe control query is blocked by the current regex, while all three equivalent PostgreSQL forms are allowed by the validator and return the mounted proof file contents from a real PostgreSQL server. The LANGROID_SAFE_MARKER_... value is a harmless marker generated inside the throwaway local container for this proof.
Impact
On a deployment using SQLChatAgent against PostgreSQL with a role able to call pg_read_file (superuser, or a role granted pg_read_server_files), an attacker who can influence LLM-generated SQL can coerce the agent into emitting one of the obfuscated queries and read files accessible to the PostgreSQL server process through pg_read_file.
This is the same impact and precondition shape as the published pg_read_file advisory, but it targets the bypassability of the current regex-based fix rather than the pre-fix absence of a pg_read_file block.
Severity: High by parity with the published parent advisory; not Critical. CWE-184 leading to server-side file read.
Suggested Fix
Do not rely on raw-text regex matching for dangerous-call detection. After the existing sqlglot parse, walk the AST and reject any function invocation whose normalized, unquoted, schema-stripped, case-folded name is in a dangerous set such as pg_read_file, pg_read_binary_file, pg_ls_dir, pg_stat_file, lo_import, lo_export, load_file, or load_extension.
Also recommend running SQLChatAgent with a least-privilege database role that lacks pg_read_server_files.
Articles & Coverage 3
Executive ViewAI
Langroid, a Python package used for LLM-based database interactions, contains a critical vulnerability in its SQLChatAgent that permits attackers to read sensitive data directly from PostgreSQL databases by bypassing built-in safety controls. Organizations using Langroid for AI-driven database operations face potential unauthorized disclosure of confidential information if they have not applied the available patch.
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
SQL injection exploits the way applications construct database queries by mixing user input directly into SQL statements.
Path traversal exploits occur when applications use user-controlled input to construct file system paths without proper validation.
Affected Products (CPE)CVE.org
More in PostgreSQL
View allPostgreSQL libpq functions PQescapeLiteral(), PQescapeIdentifier(), PQescapeString(), and PQescapeStringConn() improperl
An issue was discovered in Appsmith before 1.52. Rated critical severity (CVSS 9.8), this vulnerability is remotely expl
Argument injection vulnerability in PostgreSQL 9.2.x before 9.2.4, 9.1.x before 9.1.9, and 9.0.x before 9.0.13 allows re
Unauthenticated arbitrary file write in Splunk Enterprise (below 10.2.4 and 10.0.7) and Splunk Cloud Platform (below 10.
Unauthenticated SQL injection in Sangoma Switchvox SMB Edition 8.3 (build 104997) lets remote attackers execute arbitrar
PostgreSQL versions before 9.2.22, 9.3.18, 9.4.13, 9.5.8 and 9.6.4 are vulnerable to incorrect authentication flaw allow
The build_tablename function in pgsql.c in the PostgreSQL (aka pgsql) extension in PHP through 5.6.7 does not validate t
A vulnerability in the h2oai/h2o-3 REST API versions 3.46.0.4 allows unauthenticated remote attackers to execute arbitra
In PostgreSQL 9.3 through 11.2, the "COPY TO/FROM PROGRAM" function allows superusers and users in the 'pg_execute_serve
Unauthenticated SQL injection in Vendure Shop API allows remote attackers to execute arbitrary SQL commands against the
Parse Server is an open source http web server backend. Rated critical severity (CVSS 10.0), this vulnerability is remot
Hard-coded default PostgreSQL credentials shipped in the docker-compose.yaml of langgenius Dify through version 1.5.1 al
GHSA-6xc5-4r68-67fc
NVD
CVE.org
EPSS
Vulnrichment
Exploit-DB