CVE-2024-8309: Langchain community SQL Injection Vulnerability
LOWCVE-2024-8309 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 PyPI ecosystem. The issue involves langchain sql injection vulnerability. Remediation is available by upgrading affected packages to version 0.2.19, 0.2.0.
CVE-2024-8309 at a Glance
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).
How to Fix CVE-2024-8309
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.
pip install langchain-community>=0.2.19
pip install langchain>=0.2.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show langchain-community
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2024-8309, inspect your installed packages using pip:
pip show 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.2.19), your application is affected.
Note: The pip show langchain-community command checks currently installed packages in your active Python environment.
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
CVE-2024-8309 Affected Langchain community Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
langchain-community
|
PyPI |
≥ 0.2.0
< 0.2.19
|
0.2.19
|
|
langchain
|
PyPI |
< 0.2.0
|
0.2.0
|
References
Frequently Asked Questions
What is CVE-2024-8309?
Which Langchain community versions are affected?
What version fixes CVE-2024-8309?
Is langchain-community affected?
Is langchain affected?
What is the CVSS score of CVE-2024-8309?
What CWE is associated with CVE-2024-8309?
How can I check PyPI dependencies for CVE-2024-8309?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-45pg-36p6-83v9",
"modified" : "2024-11-12T19:57:59Z",
"published" : "2024-10-29T15:32:05Z",
"aliases" : [ "CVE-2024-8309" ],
"summary" : "Langchain SQL Injection vulnerability",
"details" : "A vulnerability in the GraphCypherQAChain class of langchain-ai/langchain version 0.2.5 allows for SQL injection through prompt injection. This vulnerability can lead to 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" : "PyPI",
"name" : "langchain-community"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.2.0"
}, {
"fixed" : "0.2.19"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "langchain"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.2.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-8309"
}, {
"type" : "WEB",
"url" : "https://github.com/langchain-ai/langchain/commit/64c317eba05fbac0c6a6fc5aa192bc0d7130972e"
}, {
"type" : "WEB",
"url" : "https://github.com/langchain-ai/langchain/commit/c2a3021bb0c5f54649d380b42a0684ca5778c255"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/langchain-ai/langchain"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/langchain/PYSEC-2024-115.yaml"
}, {
"type" : "WEB",
"url" : "https://huntr.com/bounties/8f4ad910-7fdc-4089-8f0a-b5df5f32e7c5"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-74", "CWE-89" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2024-10-29T19:54:15Z",
"nvd_published_at" : "2024-10-29T13:15:10Z"
}
}