Skip to main content

Langroid CVE-2026-54760

CRITICAL
Path Traversal (CWE-22)
2026-07-06 https://github.com/langroid/langroid GHSA-6xc5-4r68-67fc
9.3
CVSS 4.0 · Vendor: https://github.com/langroid/langroid
Share

Severity by source

Vendor (https://github.com/langroid/langroid) PRIMARY
9.3 CRITICAL
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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
vuln.today AI
5.9 MEDIUM

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.

3.1 AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N
4.0 AV:N/AC:H/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N

Primary rating from Vendor (https://github.com/langroid/langroid).

CVSS VectorVendor: https://github.com/langroid/langroid

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
X

Lifecycle Timeline

6
Analysis Updated
Jul 10, 2026 - 00:31 vuln.today
v3 (cvss_changed)
Source Code Evidence Fetched
Jul 10, 2026 - 00:31 vuln.today
Analysis Updated
Jul 10, 2026 - 00:31 vuln.today
v2 (cvss_changed)
Re-analysis Queued
Jul 10, 2026 - 00:22 vuln.today
cvss_changed
CVSS changed
Jul 10, 2026 - 00:22 NVD
9.3 (CRITICAL)
Analysis Generated
Jul 06, 2026 - 21:19 vuln.today

DescriptionCVE.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:

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

text
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: VULNERABLE

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

AnalysisAI

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.

Technical ContextAI

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

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.

CVE-2025-1094 HIGH POC
8.1 Feb 13

PostgreSQL libpq functions PQescapeLiteral(), PQescapeIdentifier(), PQescapeString(), and PQescapeStringConn() improperl

CVE-2024-55964 CRITICAL POC
9.8 Mar 26

An issue was discovered in Appsmith before 1.52. Rated critical severity (CVSS 9.8), this vulnerability is remotely expl

CVE-2013-1899 MEDIUM POC
6.5 Apr 04

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

CVE-2026-20253 CRITICAL POC
9.8 Jun 10

Unauthenticated arbitrary file write in Splunk Enterprise (below 10.2.4 and 10.0.7) and Splunk Cloud Platform (below 10.

CVE-2026-9586 CRITICAL POC
9.3 Jul 17

Unauthenticated SQL injection in Sangoma Switchvox SMB Edition 8.3 (build 104997) lets remote attackers execute arbitrar

CVE-2017-7546 CRITICAL
9.8 Aug 16

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

CVE-2015-1352 MEDIUM POC
5.0 Mar 30

The build_tablename function in pgsql.c in the PostgreSQL (aka pgsql) extension in PHP through 5.6.7 does not validate t

CVE-2024-10553 CRITICAL POC
9.8 Mar 20

A vulnerability in the h2oai/h2o-3 REST API versions 3.46.0.4 allows unauthenticated remote attackers to execute arbitra

CVE-2019-9193 HIGH POC
7.2 Apr 01

In PostgreSQL 9.3 through 11.2, the "COPY TO/FROM PROGRAM" function allows superusers and users in the 'pg_execute_serve

CVE-2026-40887 CRITICAL POC
9.1 Apr 14

Unauthenticated SQL injection in Vendure Shop API allows remote attackers to execute arbitrary SQL commands against the

CVE-2022-24760 CRITICAL POC
10.0 Mar 12

Parse Server is an open source http web server backend. Rated critical severity (CVSS 10.0), this vulnerability is remot

CVE-2025-56157 CRITICAL POC
9.8 Dec 18

Hard-coded default PostgreSQL credentials shipped in the docker-compose.yaml of langgenius Dify through version 1.5.1 al

Share

CVE-2026-54760 vulnerability details – vuln.today

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy