CVE-2025-68664: LangChain Serialization Injection Vulnerability Allows Secret Extraction

langchain-core Updated 23 Dec 2025

Summary

23/12/2025
Yes i
Critical
9.3

CVE-2025-68664: LangChain serialization injection vulnerability enables secret extraction in dumps/loads APIs. Affects langchain-core across 2 version ranges.

< 0.3.81 >= 1.0.0, < 1.2.5

Fixed in 0.3.81 or 1.2.5, depending on the release line you run. 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

LangChain is an open-source framework designed for building applications that utilize language models. It provides functionalities for serialization and deserialization of objects, enabling developers to manage complex data structures easily. However, a critical vulnerability has been identified in its serialization methods, specifically in the dumps() and dumpd() functions, which fail to properly escape user-controlled data containing specific keys, leading to potential security risks.

Vulnerability Detail

A serialization injection vulnerability exists in LangChain's dumps() and dumpd() functions. These functions do not escape dictionaries with 'lc' keys when serializing free-form dictionaries. As a result, user-controlled data containing this key structure is treated as legitimate LangChain objects during deserialization. This vulnerability allows attackers to inject malicious structures through user data, enabling them to extract sensitive information such as environment variable secrets or instantiate classes with controlled parameters, potentially triggering harmful side effects.

How To Fix

Latest published version: 1.7.0 as of 22 Oct 2026

pip install --upgrade "langchain-core==1.7.0"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 0.3.81 0.3.81
    pip install --upgrade "langchain-core==0.3.81"
  • >= 1.0.0, < 1.2.5 1.2.5
    pip install --upgrade "langchain-core==1.2.5"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If immediate patching is not feasible, consider implementing input validation to sanitize user-controlled data before serialization. For example, avoid using user data directly in serialization functions or implement a custom serialization method that escapes or filters out 'lc' keys. Here is a simple code snippet to demonstrate input validation:

def safe_dumps(data):
    if isinstance(data, dict) and 'lc' in data:
        raise ValueError('Invalid data structure: contains forbidden key')
    return dumps(data)

Use safe_dumps() instead of dumps() to prevent serialization of unsafe data.

Conclusion

The LangChain serialization injection vulnerability (CVE-2025-68664) poses significant risks to applications using the affected serialization methods. It is crucial for developers to update to the latest patched version of the package and implement necessary security measures to protect against potential exploits.

See every vulnerability recorded for langchain-core →

Share this vulnerability

FAQ

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

You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Visit the Vulert playground at Vulert Scanner to check if your application is affected without requiring signup.

Attackers can exploit this vulnerability to extract sensitive information, such as environment variable secrets, or execute arbitrary code by instantiating classes with controlled parameters.

Implement input validation to sanitize user-controlled data before serialization as a temporary workaround until you can apply the patch.

The patch introduces escaping for user-controlled data, restricts deserialization to an allowlist of classes, changes the default setting for loading secrets from environment variables, and blocks Jinja2 templates by default.

Related vulnerabilities

Recent vulnerabilities recorded for langchain-core.

How To Fix

Latest published version: 1.7.0 as of 22 Oct 2026

pip install --upgrade "langchain-core==1.7.0"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 0.3.81 0.3.81
    pip install --upgrade "langchain-core==0.3.81"
  • >= 1.0.0, < 1.2.5 1.2.5
    pip install --upgrade "langchain-core==1.2.5"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. 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