CVE-2024-7042

9.8 CRITICAL

📋 TL;DR

A prompt injection vulnerability in langchain-ai/langchainjs GraphCypherQAChain class allows attackers to inject SQL commands through manipulated prompts, leading to unauthorized database operations. This affects all applications using langchain-ai/langchainjs versions 0.2.5 and any versions containing the vulnerable GraphCypherQAChain class.

💻 Affected Systems

Products:
  • langchain-ai/langchainjs
Versions: 0.2.5 and all versions containing GraphCypherQAChain class
Operating Systems: all
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects implementations using the GraphCypherQAChain class with Neo4j or similar graph databases.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise including data deletion, exfiltration of all sensitive information, and unauthorized access across multi-tenant environments.

🟠

Likely Case

Unauthorized data access and manipulation, potential data exfiltration, and disruption of database operations.

🟢

If Mitigated

Limited impact with proper input validation and database access controls, though prompt injection vectors may still exist.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires access to the prompt interface but no authentication. Public proof-of-concept exists in the bounty report.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Fixed in commit 615b9d9ab30a2d23a2f95fb8d7acfdf4b41ad7a6

Vendor Advisory: https://github.com/langchain-ai/langchainjs/commit/615b9d9ab30a2d23a2f95fb8d7acfdf4b41ad7a6

Restart Required: No

Instructions:

1. Update langchain-ai/langchainjs to version containing commit 615b9d9ab30a2d23a2f95fb8d7acfdf4b41ad7a6. 2. Verify GraphCypherQAChain class implements proper input sanitization. 3. Test prompt injection vectors are blocked.

🔧 Temporary Workarounds

Disable GraphCypherQAChain

all

Temporarily disable or remove GraphCypherQAChain functionality until patched.

Remove or comment out GraphCypherQAChain imports and usage

Implement Input Validation

all

Add strict input validation and sanitization for all prompt inputs.

Implement regex filtering for SQL keywords in user prompts
Use parameterized queries for all database operations

🧯 If You Can't Patch

  • Implement strict network segmentation to isolate database servers from application servers
  • Enable database audit logging and monitor for unusual query patterns

🔍 How to Verify

Check if Vulnerable:

Check if your application uses langchain-ai/langchainjs GraphCypherQAChain class and is on version 0.2.5 or earlier.

Check Version:

npm list langchain or check package.json for langchain-ai/langchainjs version

Verify Fix Applied:

Test prompt injection attempts with SQL commands to verify they are properly sanitized or blocked.

📡 Detection & Monitoring

Log Indicators:

  • Unusual database queries from application layer
  • SQL error messages in application logs
  • Unexpected CREATE/UPDATE/DELETE operations

Network Indicators:

  • Unusual database connection patterns
  • Large data transfers from database servers

SIEM Query:

source="application_logs" AND ("SQL syntax" OR "unexpected query" OR "GraphCypherQAChain")

🔗 References

📤 Share & Export