CVE-2023-36189: LangChain SQLDatabaseChain: SQL injection, DB exfil

GHSA-7q94-qpjr-xpgm HIGH PoC AVAILABLE
Published July 6, 2023
CISO Take

Unauthenticated SQL injection in LangChain's SQLDatabaseChain allows full read access to any database the chain is connected to — no credentials or user interaction required. If your AI agents or LLM applications use LangChain's SQL tools, upgrade to 0.0.247+ immediately. This is a classic injection flaw in an AI-native component that often connects LLMs to sensitive internal databases.

Risk Assessment

High severity (CVSS 7.5) with low attack complexity and no authentication barrier make this trivially exploitable if the LangChain application is network-exposed. EPSS of 0.002 and absence from CISA KEV suggest limited active exploitation, but the attack surface is significant: SQLDatabaseChain is a commonly used pattern in enterprise LLM deployments, often wired to production databases containing sensitive data. The real risk is that many LangChain deployments are internal-facing AI tools where SQL access is implicitly trusted.

Affected Systems

Package Ecosystem Vulnerable Range Patched
langchain pip No patch
135.7K OpenSSF 6.5 2.6K dependents Pushed 7d ago 17% patched ~256d to patch Full package profile →
langchain pip >= 0, < 0.0.247 0.0.247
135.7K OpenSSF 6.5 2.6K dependents Pushed 7d ago 17% patched ~256d to patch Full package profile →

Severity & Risk

CVSS 3.1
7.5 / 10
EPSS
0.2%
chance of exploitation in 30 days
Higher than 37% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Trivial
Exploitation Confidence
medium
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, CISA SSVC, EPSS, trickest/cve, and Nuclei templates.

Attack Surface

AV AC PR UI S C I A
AV Network
AC Low
PR None
UI None
S Unchanged
C High
I None
A None

Recommended Action

6 steps
  1. Patch: Upgrade langchain to >= 0.0.247. Reference PR #6051 for the fix.

  2. Audit: Inventory all internal services using langchain and validate version.

  3. Workaround (if unable to patch): Disable or remove SQLDatabaseChain usage; replace with parameterized query wrappers.

  4. Harden: Restrict the database user used by SQLDatabaseChain to minimum required tables and columns (principle of least privilege).

  5. Detect: Review database query logs for anomalous SQL patterns (UNION SELECT, subqueries, tautologies) originating from the LangChain service account.

  6. Network: Ensure LangChain endpoints are not exposed to untrusted networks.

CISA SSVC Assessment

Decision Track
Exploitation none
Automatable Yes
Technical Impact partial

Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
A.6.2.6 - Information security of AI systems
NIST AI RMF
MANAGE-2.4 - Residual risks are monitored and managed
OWASP LLM Top 10
LLM06 - Sensitive Information Disclosure LLM07 - Insecure Plugin Design

Frequently Asked Questions

What is CVE-2023-36189?

Unauthenticated SQL injection in LangChain's SQLDatabaseChain allows full read access to any database the chain is connected to — no credentials or user interaction required. If your AI agents or LLM applications use LangChain's SQL tools, upgrade to 0.0.247+ immediately. This is a classic injection flaw in an AI-native component that often connects LLMs to sensitive internal databases.

Is CVE-2023-36189 actively exploited?

Proof-of-concept exploit code is publicly available for CVE-2023-36189, increasing the risk of exploitation.

How to fix CVE-2023-36189?

1. Patch: Upgrade langchain to >= 0.0.247. Reference PR #6051 for the fix. 2. Audit: Inventory all internal services using langchain and validate version. 3. Workaround (if unable to patch): Disable or remove SQLDatabaseChain usage; replace with parameterized query wrappers. 4. Harden: Restrict the database user used by SQLDatabaseChain to minimum required tables and columns (principle of least privilege). 5. Detect: Review database query logs for anomalous SQL patterns (UNION SELECT, subqueries, tautologies) originating from the LangChain service account. 6. Network: Ensure LangChain endpoints are not exposed to untrusted networks.

What systems are affected by CVE-2023-36189?

This vulnerability affects the following AI/ML architecture patterns: agent frameworks, text-to-SQL pipelines, LLM application backends, RAG pipelines.

What is the CVSS score for CVE-2023-36189?

CVE-2023-36189 has a CVSS v3.1 base score of 7.5 (HIGH). The EPSS exploitation probability is 0.16%.

Technical Details

NVD Description

SQL injection vulnerability in langchain before v0.0.247 allows a remote attacker to obtain sensitive information via the SQLDatabaseChain component.

Exploitation Scenario

An attacker targets an enterprise LLM assistant built on LangChain that accepts natural language questions and translates them to SQL queries via SQLDatabaseChain. By injecting a crafted query such as 'Show me orders' with appended SQL injection payloads, the attacker bypasses input validation and forces the chain to execute a UNION-based query against the underlying database. This allows enumeration of table schemas and full exfiltration of sensitive records — customer PII, financial data, or proprietary operational data — without any credentials. The AI layer acts as an unintentional SQL proxy, making detection harder since queries appear to originate from a trusted internal service account.

CVSS Vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

Timeline

Published
July 6, 2023
Last Modified
November 21, 2024
First Seen
July 6, 2023

Related Vulnerabilities