CVE-2024-21513: Langchain experimental Langchain-experimental Vulnerable To Arbitrary Code Vulnerability
CRITICALCVE-2024-21513 is a CRITICAL (CVSS 8.5) langchain-experimental vulnerable to arbitrary code vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Langchain experimental libraries in the PyPI ecosystem. The issue involves langchain-experimental vulnerable to arbitrary code execution. Remediation is available by upgrading affected packages to version 0.0.21.
CVE-2024-21513 at a Glance
Security Impact
CVSS: 8.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H).
How to Fix CVE-2024-21513
To remediate this vulnerability, upgrade all affected Langchain experimental 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-experimental>=0.0.21
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show langchain-experimental
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2024-21513, inspect your installed packages using pip:
pip show langchain-experimental
Analyze the terminal output to locate any version of Langchain experimental in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.0.21), your application is affected.
Note: The pip show langchain-experimental command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Langchain experimental, 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-21513 Affected Langchain experimental Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
langchain-experimental
|
PyPI |
< 0.0.21
|
0.0.21
|
References
Frequently Asked Questions
What is CVE-2024-21513?
Which Langchain experimental versions are affected?
What version fixes CVE-2024-21513?
Is langchain-experimental affected?
What is the CVSS score of CVE-2024-21513?
What CWE is associated with CVE-2024-21513?
How can I check PyPI dependencies for CVE-2024-21513?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-cgcg-p68q-3w7v",
"modified" : "2024-11-18T16:26:52Z",
"published" : "2024-07-15T06:30:53Z",
"aliases" : [ "CVE-2024-21513" ],
"summary" : "langchain-experimental vulnerable to Arbitrary Code Execution",
"details" : "Versions of the package langchain-experimental from 0.0.15 and before 0.0.21 are vulnerable to Arbitrary Code Execution when retrieving values from the database, the code will attempt to call 'eval' on all values. An attacker can exploit this vulnerability and execute arbitrary python code if they can control the input prompt and the server is configured with VectorSQLDatabaseChain.\n\n**Notes:**\n\nImpact on the Confidentiality, Integrity and Availability of the vulnerable component:\n\nConfidentiality: Code execution happens within the impacted component, in this case langchain-experimental, so all resources are necessarily accessible.\n\nIntegrity: There is nothing protected by the impacted component inherently. Although anything returned from the component counts as 'information' for which the trustworthiness can be compromised.\n\nAvailability: The loss of availability isn't caused by the attack itself, but it happens as a result during the attacker's post-exploitation steps.\n\n\nImpact on the Confidentiality, Integrity and Availability of the subsequent system:\n\nAs a legitimate low-privileged user of the package (PR:L) the attacker does not have more access to data owned by the package as a result of this vulnerability than they did with normal usage (e.g. can query the DB). The unintended action that one can perform by breaking out of the app environment and exfiltrating files, making remote connections etc. happens during the post exploitation phase in the subsequent system - in this case, the OS.\n\nAT:P: An attacker needs to be able to influence the input prompt, whilst the server is configured with the VectorSQLDatabaseChain plugin.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "langchain-experimental"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.0.21"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-21513"
}, {
"type" : "WEB",
"url" : "https://github.com/langchain-ai/langchain/commit/7b13292e3544b2f5f2bfb8a27a062ea2b0c34561"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/langchain-ai/langchain"
}, {
"type" : "WEB",
"url" : "https://github.com/langchain-ai/langchain/blob/672907bbbb7c38bf19787b78e4ffd7c8a9026fe4/libs/experimental/langchain_experimental/sql/vector_sql.py#L81"
}, {
"type" : "WEB",
"url" : "https://github.com/langchain-ai/langchain/blob/672907bbbb7c38bf19787b78e4ffd7c8a9026fe4/libs/experimental/langchain_experimental/sql/vector_sql.py%23L81"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/langchain-experimental/PYSEC-2024-62.yaml"
}, {
"type" : "WEB",
"url" : "https://security.snyk.io/vuln/SNYK-PYTHON-LANGCHAINEXPERIMENTAL-7278171"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2024-07-15T16:26:46Z",
"nvd_published_at" : "2024-07-15T05:15:01Z"
}
}