CVE-2024-8309: langchain SQL Injection Vulnerability via Prompt Injection

langchain Updated 02 Oct 2025

Summary

05/11/2024
Yes i
Critical
9.8

CVE-2024-8309: A vulnerability in the GraphCypherQAChain class of langchain-ai/langchain-community version 0.2.5 allows for SQL injection through prompt injection. Affects langchain across 2 version ranges.

< 0.2.0 < c2a3021bb0c5f54649d380b42a0684ca5778c255

Fixed in c2a3021bb0c5f54649d380b42a0684ca5778c255. How to fix ↓

Also tracked for

The same CVE-2024-8309 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

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

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

Langchain is an open-source framework designed for building applications that utilize language models. It provides a versatile interface for integrating various language processing capabilities, enabling developers to create complex applications that can understand and generate human-like text. However, the framework is vulnerable to SQL injection through prompt injection, particularly in the GraphCypherQAChain class, which can lead to severe security issues.

Vulnerability Detail

A vulnerability in the GraphCypherQAChain class of langchain-ai/langchain version 0.2.5 allows for SQL injection through prompt injection. This vulnerability can lead to unauthorized data manipulation, data exfiltration, denial of service (DoS) by deleting all data, breaches in multi-tenant security environments, and data integrity issues. Attackers can create, update, or delete nodes and relationships without proper authorization, extract sensitive data, disrupt services, access data across different tenants, and compromise the integrity of the database.

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

c2a3021bb0c5f54649d380b42a0684ca5778c255

This is the first release that contains the fix.

pip install --upgrade "langchain==c2a3021bb0c5f54649d380b42a0684ca5778c255"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, you can implement input validation and sanitization to mitigate the risk of SQL injection until the package is updated. Ensure that any user inputs are properly escaped and validated before being processed.

Conclusion

The CVE-2024-8309 vulnerability in the langchain package poses significant risks, including SQL injection and unauthorized data manipulation. It is crucial for users to update their packages promptly and implement necessary workarounds to safeguard their applications.

See every vulnerability recorded for langchain →

Share this vulnerability

FAQ

CVE-2024-8309 is a vulnerability in the langchain package that allows for SQL injection through prompt injection, potentially leading to unauthorized data manipulation.

The vulnerability affects langchain version 0.2.5 and earlier. It is recommended to upgrade to a version that includes the fix.

The impacts include unauthorized data manipulation, data exfiltration, denial of service, and breaches in multi-tenant security environments.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The CVSS score for this vulnerability is 9.8, indicating a critical level of severity.

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

c2a3021bb0c5f54649d380b42a0684ca5778c255

This is the first release that contains the fix.

pip install --upgrade "langchain==c2a3021bb0c5f54649d380b42a0684ca5778c255"

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