Cloudanix VulnDB

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

Monitor only SSVC: Track

A flaw in a popular AI library lets attackers trick it into running harmful database commands that can delete or steal information.

Chainable
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

  1. Identify an application endpoint or interface that accepts user input passed to GraphCypherQAChain
  2. Craft a prompt containing instructions that override the intended query logic to produce malicious Cypher
  3. Submit the prompt to trigger query generation and execution against the graph database
  4. 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