CVE-2024-7042: @langchain/community SQL Injection Vulnerability

LOW
Advisory Identifier: GHSA-6m59-8fmv-m5f9
CVSS 4.9
CWE-89
Published
Advisory Summary

CVE-2024-7042 is a LOW (CVSS 4.9) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting @langchain/community libraries in the npm ecosystem. The issue involves @langchain/community sql injection vulnerability. Remediation is available by upgrading affected packages to version 0.3.3.

CVE-2024-7042 at a Glance

CVE Identifier CVE-2024-7042
GHSA Identifier GHSA-6m59-8fmv-m5f9
Severity LOW
CVSS v3.1 Base Score 4.9
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product @langchain/community
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L).

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2024-7042

To remediate this vulnerability, upgrade all affected @langchain/community dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@langchain/community fixed: 0.3.3
npm install @langchain/community@0.3.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @langchain/community

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-7042, inspect your project dependencies using npm:

npm ls @langchain/community

Analyze the terminal output to locate any version of @langchain/community in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.3.3), your application is affected.

Note: The npm ls @langchain/community command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In @langchain/community, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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.

CVE-2024-7042 Affected @langchain/community Versions

1 component(s)
Fixed Versions:
0.3.3
Product / Package Ecosystem Affected Versions Fixed Version
@langchain/community
npm
< 0.3.3
0.3.3

References

Frequently Asked Questions

What is CVE-2024-7042?
CVE-2024-7042 is a security vulnerability in @langchain/community involving @langchain/community SQL Injection vulnerability under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which @langchain/community versions are affected?
Affected versions include releases prior to 0.3.3 across affected packages: @langchain/community.
What version fixes CVE-2024-7042?
Upgrading to 0.3.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @langchain/community affected?
Yes, @langchain/community is affected in releases prior to 0.3.3. Upgrade your dependency to 0.3.3 or later.
What is the CVSS score of CVE-2024-7042?
CVE-2024-7042 has a CVSS v3.1 base score of 4.9 (LOW) with vector string CVSS:3.0/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2024-7042?
CVE-2024-7042 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check npm dependencies for CVE-2024-7042?
Run the dependency tree command: 'npm ls @langchain/community'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-6m59-8fmv-m5f9",
  "modified" : "2024-11-01T13:16:11Z",
  "published" : "2024-10-29T15:32:05Z",
  "aliases" : [ "CVE-2024-7042" ],
  "summary" : "@langchain/community SQL Injection vulnerability",
  "details" : "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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@langchain/community"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.3.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-7042"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/langchain-ai/langchainjs/commit/615b9d9ab30a2d23a2f95fb8d7acfdf4b41ad7a6"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/langchain-ai/langchainjs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/langchain/PYSEC-2024-114.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.com/bounties/b612defb-1104-4fff-9fef-001ab07c7b2d"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-10-29T19:38:29Z",
    "nvd_published_at" : "2024-10-29T13:15:08Z"
  }
}