Description
Langroid is a framework for building large-language-model-powered applications. Prior to version 0.64.0, `SQLChatAgent` in `langroid` ships a `_validate_query` defense-in-depth layer whose `_DANGEROUS_SQL_PATTERNS` regex blocklist enumerates dangerous SQL primitives by specific function name. The list misses the canonical PostgreSQL filesystem-disclosure family `pg_read_file()`, `pg_stat_file()`, `pg_ls_logdir()`, `pg_ls_waldir()`, `pg_current_logfile()` (and similar `SELECT`-shaped functions in the same family). It also leaves SQL Server `OPENDATASOURCE` and SQLite `ATTACH '<file>' AS x` (DATABASE keyword omitted) unblocked. An attacker able to shape the LLM's generated SQL (directly via prompt input or transitively via prompt-injection in data the LLM ingests) can read arbitrary files from the PostgreSQL host through ordinary `SELECT` queries, even with the agent's strict default configuration (`allow_dangerous_operations=False`, `allowed_statement_types=['SELECT']`). The payloads survive the statement-type allowlist (each is a `SELECT`) and pass through the regex blocklist (none of the function names match), then reach the live SQLAlchemy engine via `SQLChatAgent.run_query`. Version 0.64.0 contains a patch for the issue.
Published: 2026-07-09
Score: 8.7 High
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

Langroid's SQLChatAgent provides a defensive layer that relies on a regular expression blocklist. The list omitted the PostgreSQL file‑reading family of functions (pg_read_file, pg_stat_file, pg_ls_logdir, pg_ls_waldir, pg_current_logfile) and also failed to block certain SQL Server and SQLite file‑access functions. An attacker who can influence the language‑model output, for example by submitting a prompt that steers the model into generating a SELECT statement containing one of these functions, can thus read arbitrary files from the PostgreSQL host. The flaw persists even when the agent is configured with allow_dangerous_operations = False and allowed_statement_types limited to SELECT, because the problematic function names are not detected by the regex and the statements remain SELECT queries.

Affected Systems

This vulnerability affects all installations of the Langroid framework that use SQLChatAgent from versions earlier than 0.64.0. The defect resides in the library code bundled with the agent, so any application that imports SQLChatAgent from those older releases—or deploys a custom agent that relies on the same blocklist—is vulnerable. Users of langroid < 0.64.0 should verify their installed version and plan to update or apply a workaround.

Risk and Exploitability

The CVSS base score of 8.7 reflects high severity and the potential for arbitrary information disclosure. The EPSS score of < 1 % indicates a very low probability of exploitation in the wild, likely due to the need for logical access to the prompt content that feeds the LLM. The flaw is not listed in the CISA KEV catalog. A successful exploit requires the attacker to craft or influence the model’s generated SQL, so the attack vector is logical/prompt path rather than a direct network attack. If the attacker succeeds, they can read any file on the database host that the PostgreSQL process can access, potentially revealing credentials, application configuration or other sensitive data.

Generated by OpenCVE AI on July 29, 2026 at 11:38 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade Langroid to version 0.64.0 or later to receive the official patch that expands the regex blocklist to include PostgreSQL file‑reading functions and the SQL Server OPENDATASOURCE and SQLite ATTACH patterns.
  • If an immediate upgrade is not possible, extend the agent’s custom blocklist to include the missing PostgreSQL file‑reading functions (pg_read_file, pg_stat_file, pg_ls_logdir, pg_ls_waldir, pg_current_logfile) as wellas SQL Server OPENDATASOURCE and SQLite ATTACH '<file>' AS X patterns, and confirm the regex rejects those queries.
  • Restrict the agent’s allowed_statement_types to only those statements that your application needs, and remove SELECT if file reading is unnecessary, to reduce the attack surface.
  • Sanitize and limit user‑supplied prompt data to prevent the language model from generating arbitrary SQL, or disable the SQL execution feature for untrusted data.

Generated by OpenCVE AI on July 29, 2026 at 11:38 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-pmch-g965-grmr Langroid: SQLChatAgent _validate_query blocklist misses pg_read_file family enabling arbitrary file read
History

Fri, 10 Jul 2026 21:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Fri, 10 Jul 2026 01:45:00 +0000

Type Values Removed Values Added
First Time appeared Langroid
Langroid langroid
Vendors & Products Langroid
Langroid langroid

Fri, 10 Jul 2026 00:15:00 +0000

Type Values Removed Values Added
Description Langroid is a framework for building large-language-model-powered applications. Prior to version 0.64.0, `SQLChatAgent` in `langroid` ships a `_validate_query` defense-in-depth layer whose `_DANGEROUS_SQL_PATTERNS` regex blocklist enumerates dangerous SQL primitives by specific function name. The list misses the canonical PostgreSQL filesystem-disclosure family `pg_read_file()`, `pg_stat_file()`, `pg_ls_logdir()`, `pg_ls_waldir()`, `pg_current_logfile()` (and similar `SELECT`-shaped functions in the same family). It also leaves SQL Server `OPENDATASOURCE` and SQLite `ATTACH '<file>' AS x` (DATABASE keyword omitted) unblocked. An attacker able to shape the LLM's generated SQL (directly via prompt input or transitively via prompt-injection in data the LLM ingests) can read arbitrary files from the PostgreSQL host through ordinary `SELECT` queries, even with the agent's strict default configuration (`allow_dangerous_operations=False`, `allowed_statement_types=['SELECT']`). The payloads survive the statement-type allowlist (each is a `SELECT`) and pass through the regex blocklist (none of the function names match), then reach the live SQLAlchemy engine via `SQLChatAgent.run_query`. Version 0.64.0 contains a patch for the issue.
Title Langroid: SQLChatAgent _validate_query blocklist misses pg_read_file family enabling arbitrary file read
Weaknesses CWE-22
CWE-89
References
Metrics cvssV4_0

{'score': 8.7, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N'}


Subscriptions

Langroid Langroid
cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-07-10T20:59:17.652Z

Reserved: 2026-06-03T22:05:13.644Z

Link: CVE-2026-50180

cve-icon Vulnrichment

Updated: 2026-07-10T20:53:14.951Z

cve-icon NVD

No data.

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-07-29T11:45:03Z

Weaknesses
  • CWE-22

    Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

  • CWE-89

    Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')