CVE-2024-7042 Prompt Injection in langchain-ai/langchainjs Leading to SQL Injection
Prompt injection in GraphCypherQAChain allows attackers to execute SQL commands, leading to data theft, modification, or deletion.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Local or same network only
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-7042?
CVE-2024-7042 is a medium-severity SQL injection vulnerability in langchain-ai/langchainjs, published on 29 Oct 2024. It can only be exploited from the same machine or local network, with no action from the victim.
Official description
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.
Weakness: CWE-89
Which versions are affected by CVE-2024-7042?
2 open source packages ship an affected version, including @langchain/community. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
@langchain/community npm | All versions | 0.3.3 |
@langchain/community npm | All versions | 0.3.3 |
Products include Langchain Langchain.
How do I fix CVE-2024-7042?
Upgrade @langchain/community to 0.3.3 or later.
Use parameterised queries everywhere and never build SQL by joining strings. Upgrade affected software first; a web application firewall only buys time. More about SQL injection.
Is CVE-2024-7042 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-7042 exists.
Other vulnerabilities in langchain-ai/langchainjs
- CVE-2023-39631 Langchain vulnerable to arbitrary code execution via the evaluate function in the numexpr library
- CVE-2023-36281 langchain vulnerable to arbitrary code execution
- CVE-2023-38860 LangChain vulnerable to arbitrary code execution
- CVE-2023-38896 LangChain vulnerable to arbitrary code execution
- CVE-2023-39659 LangChain vulnerable to arbitrary code execution
Sources
Also known as CLEANSTART-2026-BU53237, ECHO-f514-af32-e2e9, GHSA-6m59-8fmv-m5f9, MINI-5p47-gvq3-6hgc.