CVE-2024-7042
Critical · 9.8@langchain/community SQL Injection vulnerability
CVSS
9.8
EPSS
0.3%
Published
Oct 29, 2024
CISA due date
—
Cloudanix analysis
A flaw in a popular AI library lets attackers trick it into running harmful database commands that can delete or steal information.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- Low
- Impact
- Data Tampering
- Component
- Library
- Class
- SQL Injection
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Prompt injection in GraphCypherQAChain allows crafted inputs to generate and execute arbitrary Cypher queries, enabling unauthorized node/relationship creation, updates, deletion, data extraction, and cross-tenant access.
Why it matters to the business
Attackers can delete or alter critical data, steal sensitive information across tenants, or cause service outages, leading to data loss, compliance violations, and operational disruption in applications using the affected library.
How an attack unfolds
An attacker supplies malicious prompts to the GraphCypherQAChain interface; the chain converts the input into a Cypher query without sufficient sanitization, allowing the query to execute arbitrary graph database operations such as data exfiltration or deletion.
How to fix it
Upgrade hwchase17/langchain to the commit 9a31ad6f606ae223e4ea382cecef9612f98a2c3e or later; implement strict input validation and least-privilege database accounts for any remaining chain usage.
How to confirm the fix worked
Confirm the library version is at or beyond commit 9a31ad6f606ae223e4ea382cecef9612f98a2c3e; test with known prompt injection payloads to verify queries remain restricted to intended operations.
Typical attack path
- Identify an application endpoint or interface that accepts user input passed to GraphCypherQAChain
- Craft a prompt containing instructions that override the intended query logic to produce malicious Cypher
- Submit the prompt to trigger query generation and execution against the graph database
- Observe results for data manipulation, exfiltration, or denial of service effects
How to detect it
Inspect application and database logs for unexpected Cypher statements containing DELETE, CREATE, or MATCH patterns originating from user-controlled input; correlate with chain invocation timestamps.
What your security team should do
- Immediately upgrade all instances to the fixed commit
- Review and restrict database permissions used by the chain
- Add runtime monitoring for anomalous Cypher query patterns
- Disable or replace GraphCypherQAChain where possible until validated
The record
A vulnerability in the GraphCypherQAChain class of langchain-ai/langchainjs versions 0.2.5 and all versions with this class allows for prompt injection, leading to SQL injection. This vulnerability permits unauthorized data manipulation, data exfiltration, denial of service (DoS) by deleting all data, breaches in multi-tenant security environments, and data integrity issues. Attackers can create, update, or delete nodes and relationships without proper authorization, extract sensitive data, disrupt services, access data across different tenants, and compromise the integrity of the database.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| PyPI | langchain | 0 | 0.3.1 |
| npm | @langchain/community | 0 | 0.3.3 |
| Chainguard | kibana-8 | 0 | 8.16.1-r1 |
| Chainguard | kibana-8-bitnami | 0 | 8.16.1-r1 |
| Chainguard | kibana-8-iamguarded | 0 | 8.16.1-r1 |
Related vulnerabilities
- CVE-2026-45134 LangSmith Client SDKs provide SDK's for interacting with the LangSmith platform. Also affects langchain
- GHSA-3644-q5cj-c5c7 LangSmith SDK: Public prompt pull deserializes untrusted manifests without trust boundary… Also affects langchain
- CVE-2024-8309 Langchain SQL Injection vulnerability Also affects langchain
- CVE-2024-5998 LangChain pickle deserialization of untrusted data Also affects langchain
- CVE-2024-2965 A Denial-of-Service (DoS) vulnerability exists in the `SitemapLoader` class of the… Also affects langchain
- CVE-2023-36095 An issue in Harrison Chase langchain v.0.0.194 allows an attacker to execute arbitrary… Also affects langchain
- GHSA-mphv-75cg-56wg LangChain Community: redirect chaining can lead to SSRF bypass via RecursiveUrlLoader Also affects @langchain/community
- CVE-2026-27795 LangChain is a framework for building LLM-powered applications. Also affects @langchain/community