Langchain SQL Injection Vulnerability in langchain
Summary
CVE-2023-32785: Langchain SQL Injection vulnerability. Affects langchain versions < 0.0.247. Fixed in 0.0.247. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Langchain is a Python package available on PyPI that provides a SQL service for the chain. It allows users to execute SQL queries against the database. However, a vulnerability has been discovered in versions up to 0.0.155 of Langchain that allows for SQL injection attacks. This vulnerability can be exploited to execute arbitrary code against the SQL service, potentially leading to unauthorized access, data manipulation, or other malicious activities.
Vulnerability Detail
The Langchain SQL Injection vulnerability (CVE-2023-32785) allows an attacker to inject malicious SQL code into the application's input, which is then executed by the SQL service. This can lead to unauthorized access to the database, data leakage, data manipulation, or even remote code execution. The vulnerability originates from improper input validation and lack of parameterization in the SQL queries, allowing an attacker to craft malicious input that is executed as part of the SQL query.
How To Fix
Latest published version: 1.4.7 as of 22 Oct 2026
pip install --upgrade "langchain==1.4.7"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
0.0.247
This is the first release that contains the fix.
pip install --upgrade "langchain==0.0.247"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no known workaround for the Langchain SQL Injection vulnerability. It is recommended to update to a patched version of Langchain as soon as possible.
Conclusion
The Langchain SQL Injection vulnerability poses a significant risk to applications using vulnerable versions of Langchain. It is crucial to update to a patched version of Langchain and ensure that all user input is properly validated and sanitized to prevent SQL injection attacks. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for langchain →
FAQ
The Langchain SQL Injection vulnerability can allow an attacker to execute arbitrary SQL code, potentially leading to unauthorized access, data manipulation, or other malicious activities.
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by the Langchain SQL Injection vulnerability. Simply provide your Pipfile.lock file, and Vulert will analyze it for any known vulnerabilities, including the Langchain SQL Injection vulnerability.
At the time of this advisory, there are no known public exploits specifically targeting the Langchain SQL Injection vulnerability. However, it is important to patch your Langchain installation as soon as possible to mitigate the risk.
Yes, a fix is available for the Langchain SQL Injection vulnerability. Users should update their Langchain installation to the latest version available on PyPI, which should include the necessary patches and security improvements.
To prevent SQL injection attacks, it is important to properly validate and sanitize all user input before using it in SQL queries. Using parameterized queries or prepared statements can help prevent SQL injection attacks by separating the SQL code from the user input.
Related vulnerabilities
Recent vulnerabilities recorded for langchain.