CVE-2025-68665: LangChain serialization injection enables secret extraction

CVE-2025-68665 · Severity: high · CVSS 8.6 · Published 2025-12-23

LangChain is a popular JavaScript library framework for building AI applications. A flaw in its serialization mechanism allows attackers who control data passed through the library to inject malicious structures that extract environment variable secrets (like API keys) or instantiate arbitrary classes when the data is later deserialized. This is particularly dangerous in applications that process untrusted LLM responses or user-supplied metadata.

Technologies: LangChain Core. Vendors: LangChain, npm.

Quick answers

Is CVE-2025-68665 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2025-68665 being exploited in the wild.
How severe is CVE-2025-68665?
High severity, with a CVSS score of 8.6, published 23 December 2025.
Which products and versions are affected?
@langchain/core (npm) SEMVER:introduced=1.0.0,fixed=1.1.8; langchain (npm) SEMVER:introduced=1.0.0,fixed=1.2.3.
Is there a fix for CVE-2025-68665?
Yes. @langchain/core (npm): upgrade to 1.1.8 or later; langchain (npm): upgrade to 1.2.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2025-68665 attacked?
It is attacked over the network.
Am I affected by CVE-2025-68665?
Check whether you run LangChain Core, Langchain.Js, Langchain\ or one of the others listed at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • @langchain/core (npm): upgrade to 1.1.8 or later
    npm install @langchain/core@1.1.8
  • langchain (npm): upgrade to 1.2.3 or later
    npm install langchain@1.2.3

Technical details

The vulnerability is a serialization injection flaw in LangChain JS's toJSON() method. The method failed to escape user-controlled objects containing 'lc' keys (used internally to mark serialized LangChain objects) within kwargs like additional_kwargs, metadata, or response_metadata. During deserialization via load(), these injected structures were incorrectly treated as legitimate LangChain objects rather than plain data. This allowed attackers to inject secret extraction payloads ({"lc": 1, "type": "secret", "id": ["ENV_VAR"]}) that would leak environment variables when secretsFromEnv was enabled, or to instantiate arbitrary classes from provided import maps with controlled parameters. Attack preconditions include either: serializing untrusted data followed by deserialization, or directly deserializing untrusted data. The patch adds an escape mechanism in toJSON(), changes secretsFromEnv default to false, and introduces a maxDepth parameter for DoS protection.

Affected products

  • LangChain @langchain/core < 1.1.8 (when >= 1.0.0), < 0.3.80
  • LangChain langchain < 1.2.3 (when >= 1.0.0), < 0.3.37

Identifiers

  • CVE-2025-68665
  • GHSA-r399-636x-v7f6

Timeline

  • 2025-12-23: disclosed
  • 2025-12-23: patched: @langchain/core 1.1.8 and 0.3.80; langchain 1.2.3 and 0.3.37

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.