UTC
High

Langroid: SQLChatAgent _validate_query blocklist misses pg_read_file family enabling arbitrary file read

CVE-2026-50180 · GHSA-pmch-g965-grmr · published 2026-07-02

Severity
High
CVSS score
8.7
Chance of exploitation (EPSS)
0.69%
Fixed in
0.64.0
  • Exploitation No known exploitation
  • Automatable Yes
  • Technical impact Partial
  • CISA SSVC
What it is

Arbitrary file read from the PostgreSQL host: pgreadfile() reads files from PGDATA-relative paths by default and can take absolute paths when the DB role holds pgreadserverfiles (or equivalent in managed-Postgres setups). For self-managed PostgreSQL deployments the DB role is frequently a superuser, in which case absolute paths are always accepted and the impact extends to postgresql.conf, pghba.conf, ~/.pgpass, TLS keys, and any other file readable by the PostgreSQL OS user. Filesystem reconnaissance via pgstatfile() (file existence, size, mtime, isdir), pglslogdir(), pglswaldir(), pglstmpdir(), pglsarchivestatusdir(), pgcurrentlogfile().

What to do

Upgrade langroid to 0.64.0 or later.

Patch DANGEROUSSQLPATTERNS to cover the full family rather than individual function names. Two compatible approaches; either is enough. Approach 1 — family-prefix regex (minimal change, simplest to review): Approach 2 — sqlglot AST walk in addition to regex. sqlglot is already imported by sqlchatagent.py; iterate every function-call node (sqlglotexp.Anonymous / sqlglotexp.Func) inside the parsed statements and reject when the lower-cased name starts with pgread, pgstat, pgls, pgcurrentlogfile, lo, or matches the MSSQL extended-procedure prefixes (xp, sp_oa). AST matching is robust to whitespace, comments, and case games inside identifiers, at the cost of broader per-dialect maintenance.

Affected
PackageRegistryAffectedFixed in
langroidPyPI<= 0.63.00.64.0

The impact, patch and workaround text comes from the advisory, shortened (GitHub Advisory Database, CC BY 4.0). Proof-of-concept and reproduction sections and code are left out; the original advisory has them.

Sources: GitHub Advisory Database, reviewed and malware advisories (CC BY 4.0, https://github.com/advisories); advisories published by Cursor (https://github.com/cursor/cursor/security/advisories); advisories published by OpenClaw (https://github.com/openclaw/openclaw/security/advisories); advisories published by vLLM (https://github.com/vllm-project/vllm/security/advisories); advisories published by Open WebUI (https://github.com/open-webui/open-webui/security/advisories); advisories published by n8n (https://github.com/n8n-io/n8n/security/advisories); advisories published by Flowise (https://github.com/FlowiseAI/Flowise/security/advisories); advisories published by Langflow (https://github.com/langflow-ai/langflow/security/advisories); advisories published by the MCP Python SDK project (https://github.com/modelcontextprotocol/python-sdk/security/advisories); advisories published by MLflow (https://github.com/mlflow/mlflow/security/advisories); CISA Known Exploited Vulnerabilities catalog (CC0). Data as of 2026-11-22. ShieldMap describes how each problem works and how to fix it; it does not publish exploit code. Report a correction to [email protected].