Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1310 CNY

100%

CVE-2024-21513 PoC — LangChain 安全漏洞

Source
Associated Vulnerability
Title:LangChain 安全漏洞 (CVE-2024-21513)
Description: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.
Description
PoC for CVE-2024-21513
Readme
# CVE-2024-21513
PoC for CVE-2024-21513
Original exploit documented by Snyk Security Research

## Exploit
CVE-2024-21513 is a vulnerability in langchain-experimental where unvalidated SQL query results were passed to Python's eval(), enabling remote code execution through SQL-based input injection. 

## PoC Structure

This PoC is a very basic Flask App with inline HTML where users can enter coordinates into a SQLite DB.

If a user enters a malicious payload in the y value, a vulnerable LangChain-Experimental feature will fetch the y value based on the x value and pass the result to eval() which causes it to be executed. 

This PoC has a hard-coded LLM that returns the SQL query for finding where x = 10. 

### Example: 
1) Add multiple regular coordinates to the DB
2) Add the point (10, print("You've been pwned!)) to the DB through the same form
3) Check to see if the points are all there by checking the /debug route
4) Ask for data where x = 10 in the /query function (what you ask doesn't matter, the SQL result is always the same)

## File Structure
```
.
├── Dockerfile
├── README.md
├── app
│   ├── db.py
│   ├── exploit.db
│   ├── llm.py
│   ├── main.py
│   └── requirements.txt
└── docker-compose.yml
```
## How to Run This
This exploit is containerized so that it doesn't impact anything on your actual dev environment. 

I assume that you have Docker and/or Docker Compose already installed (ensure that WSL2 config is on in Docker if you are using WSL)
### Steps to Run: 
1) `git clone https://github.com/nskath/CVE-2024-21513`
2) `cd CVE-2024-21513`
3) `docker-compose up --build`
4) Visit `localhost:5000 (127.0.0.1:5000)`

## Video of Exploit: 

https://github.com/user-attachments/assets/7ad27115-411a-467f-b649-2b3508b6f5df


File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →