CVE-2023-36189: LangChain SQLDatabaseChain: SQL injection, DB exfil
GHSA-7q94-qpjr-xpgm HIGH PoC AVAILABLEUnauthenticated 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
Severity & Risk
Attack Surface
Recommended Action
6 steps-
Patch: Upgrade langchain to >= 0.0.247. Reference PR #6051 for the fix.
-
Audit: Inventory all internal services using langchain and validate version.
-
Workaround (if unable to patch): Disable or remove SQLDatabaseChain usage; replace with parameterized query wrappers.
-
Harden: Restrict the database user used by SQLDatabaseChain to minimum required tables and columns (principle of least privilege).
-
Detect: Review database query logs for anomalous SQL patterns (UNION SELECT, subqueries, tautologies) originating from the LangChain service account.
-
Network: Ensure LangChain endpoints are not exposed to untrusted networks.
CISA SSVC Assessment
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
Classification
Compliance Impact
This CVE is relevant to:
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.
Weaknesses (CWE)
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N References
- gist.github.com/rharang/9c58d39db8c01db5b7c888e467c0533f
- github.com/hwchase17/langchain/issues/5923 Exploit
- github.com/hwchase17/langchain/pull/6051 Patch
- github.com/langchain-ai/langchain/issues/5923
- github.com/advisories/GHSA-7q94-qpjr-xpgm
- github.com/langchain-ai/langchain/commit/fab24457bcf8ede882abd11419769c92bc4e7751
- github.com/langchain-ai/langchain/issues/5923
- github.com/langchain-ai/langchain/pull/8425
- github.com/pypa/advisory-database/tree/main/vulns/langchain/PYSEC-2023-110.yaml
- nvd.nist.gov/vuln/detail/CVE-2023-36189
- github.com/invariantlabs-ai/invariant Exploit
Timeline
Related Vulnerabilities
CVE-2025-2828 10.0 LangChain RequestsToolkit: SSRF exposes cloud metadata
Same package: langchain CVE-2023-34541 9.8 LangChain: RCE via unsafe load_prompt deserialization
Same package: langchain CVE-2023-29374 9.8 LangChain: RCE via prompt injection in LLMMathChain
Same package: langchain CVE-2023-34540 9.8 LangChain: RCE via JiraAPIWrapper crafted input
Same package: langchain CVE-2023-36258 9.8 LangChain: unauthenticated RCE via code injection
Same package: langchain
AI Threat Alert