CVE-2024-21513: langchain-experimental vulnerable to Arbitrary Code Execution
langchain-experimental versions from 0.0.15 before 0.0.21 run Python `eval()` on every value that `VectorSQLDatabaseChain` reads back from the database. An attacker who can influence the prompt can get arbitrary Python executed on the server. Upgrade to langchain-experimental 0.0.21, or stop using `VectorSQLDatabaseChain`.
Published Jul 15, 2024 · Updated Nov 18, 2024 · Analysis Nov 1, 2026
What an attacker can do
VectorSQLDatabaseChain turns a natural-language question into a vector SQL query, runs it and returns the rows. In sql/vector_sql.py, the helper _try_eval called eval() on each column value in the result, and fell back to the raw value if that failed. Data that comes from the database is treated as code.
The attacker does not need to touch the database directly. A user who can only send prompts can steer the LLM to build a query that returns a string such as a Python expression, for instance through a SELECT of a literal. The chain then evaluates it in the application process. The advisory describes the requirement as being able to influence the input prompt while the server uses this chain, with a low-privileged account. Result: arbitrary Python as the application's user, so environment variables, API keys, files and network access are all reachable. The scope change in the CVSS 3.1 vector reflects the jump from the library to the host operating system.
Who is affected
Affected: langchain-experimental >= 0.0.15, < 0.0.21. The advisory data lists the range as every version below 0.0.21. Only applications that configure VectorSQLDatabaseChain and let untrusted users feed it prompts are exposed. Other chains in the package are not part of this advisory.
pip show langchain-experimentalAlso search your code for VectorSQLDatabaseChain.
langchain-experimental
- Ecosystem
- PyPI
- Affected
- >= 0, < 0.0.21
- Fixed in
- 0.0.21
- Check
pip show langchain-experimental
How to fix it
Upgrade to langchain-experimental 0.0.21.
pip install --upgrade "langchain-experimental>=0.0.21"The fix commit deletes _try_eval. get_result_from_sqldb now returns the raw result of db._execute(cmd, fetch="all"), so values come back as the database types them rather than as evaluated Python. Code that relied on the evaluated values may see different types. The advisory names no workaround beyond not using the chain with untrusted prompts.
How to tell if you were hit
Search your code and dependencies for VectorSQLDatabaseChain and for the old helper _try_eval. Review application logs for prompts or generated SQL that return Python-looking strings, such as __import__, os.system or subprocess. Look for unexpected child processes, outbound connections or new files from the process that serves the chain.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
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.
Notes:
Impact on the Confidentiality, Integrity and Availability of the vulnerable component:
Confidentiality: Code execution happens within the impacted component, in this case langchain-experimental, so all resources are necessarily accessible.
Integrity: 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.
Availability: The loss of availability isn't caused by the attack itself, but it happens as a result during the attacker's post-exploitation steps.
Impact on the Confidentiality, Integrity and Availability of the subsequent system:
As 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.
AT:P: An attacker needs to be able to influence the input prompt, whilst the server is configured with the VectorSQLDatabaseChain plugin.
Questions
- Does CVE-2024-21513 affect all of LangChain?
No. It affects the separate
langchain-experimentalpackage, and only whenVectorSQLDatabaseChainis configured. The corelangchainpackage is not the vulnerable one here.- Does the attacker need database access?
No. The advisory says control of the input prompt is enough, because the chain evaluates what the query returns.
- What replaced eval in the fix?
Nothing. The commit removes
_try_evaland returns raw query results.
References
Read for this analysis:
- https://github.com/advisories/GHSA-cgcg-p68q-3w7v
- https://github.com/langchain-ai/langchain/commit/7b13292e3544b2f5f2bfb8a27a062ea2b0c34561
- https://nvd.nist.gov/vuln/detail/CVE-2024-21513
- https://security.snyk.io/vuln/SNYK-PYTHON-LANGCHAINEXPERIMENTAL-7278171
- https://github.com/langchain-ai/langchain/blob/672907bbbb7c38bf19787b78e4ffd7c8a9026fe4/libs/experimental/langchain_experimental/sql/vector_sql.py#L81
- https://github.com/pypa/advisory-database/tree/main/vulns/langchain-experimental/PYSEC-2024-62.yaml
- https://github.com/langchain-ai/langchain/blob/672907bbbb7c38bf19787b78e4ffd7c8a9026fe4/libs/experimental/langchain_experimental/sql/vector_sql.py%23L81
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More LangChain vulnerabilities
All LangChain entriesCVE-2026-55443
LangChain: Path traversal and sandbox escape in LangChain file-search middleware and loaders
medium5.1Jun 16, 2026CVE-2026-45134
LangSmith SDK: Public prompt pull deserializes untrusted manifests without trust boundary warning
high7.1May 13, 2026CVE-2026-44843
LangChain vulnerable to unsafe deserialization of attacker-controlled objects through overly broad `load()` allowlists
high8.2May 8, 2026CVE-2026-40087
LangChain has incomplete f-string validation in prompt templates
medium5.3Apr 8, 2026CVE-2026-34070
LangChain Core has Path Traversal vulnerabilites in legacy `load_prompt` functions
high7.5Mar 27, 2026CVE-2026-27795
LangChain Community: redirect chaining can lead to SSRF bypass via RecursiveUrlLoader
medium4.1Feb 25, 2026
