Langchain SQL Injection Vulnerability in langchain

langchain Updated 02 Oct 2025

Summary

21/10/2023
Yes i
Critical
9.8

CVE-2023-32785: Langchain SQL Injection vulnerability. Affects langchain versions < 0.0.247. Fixed in 0.0.247. How to fix ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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 →

Share this vulnerability

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.

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback