CVE-2025-68665 is a high-severity insecure deserialization vulnerability in @langchain/core (npm), affecting versions >= 1.0.0, < 1.1.8. It is fixed in 1.1.8, 0.3.80, 1.2.3, 0.3.37.
Context A serialization injection vulnerability exists in LangChain JS's toJSON() method (and subsequently when string-ifying objects using JSON.stringify(). The method did not escape objects with 'lc' keys when serializing free-form data in kwargs. The 'lc' key is used internally by LangChain to mark serialized objects. When user-controlled data contains this key structure, it is treated as a legitimate LangChain object during deserialization rather than plain user data. Attack surface The core vulnerability was in Serializable.toJSON(): this method failed to escape user-controlled objects containing 'lc' keys within kwargs (e.g., additionalkwargs, metadata, responsemetadata). When this unescaped data was later deserialized via load(), the injected structures were treated as legitimate LangChain objects rather than plain user data. This escaping bug enabled several attack vectors: Injection via user data: Malicious LangChain object structures could be injected through user-controlled fields like metadata, additionalkwargs, or responsemetadata Secret extraction: Injected secret structures could extract environment variables when secretsFromEnv was enabled (which had no explicit default, effectively defaulting to true behavior) Class instantiation via import maps: Injected constructor structures could instantiate any class available in the provided import maps with attacker-controlled parameters Note on import maps: Classes must be explicitly included in import maps to be instantiatable. The core import map includes standard types (messages, prompts, documents), and users can extend this via importMap and optionalImportsMap options. This architecture naturally limits the attack surface, an allowedObjects parameter is not necessary because users control which classes are available through the import maps they provide. Security hardening: This patch fixes the escaping bug in toJSON() and introduces new restrictive defaults in load(): secretsFromEnv now explicitly defaults to false, and a maxDepth parameter protects against DoS via deeply nested structures. JSDoc security warnings have been added to all import map options. Who is affected? Applications are vulnerable if they: Serialize untrusted data via JSON.stringify() on Serializable objects, then deserialize with load(), Trusting your own serialization output makes you vulnerable if user-controlled data (e.g., from LLM responses, metadata fields, or user inputs) contains 'lc' key structures. Deserialize untrusted data with load(), Directly deserializing untrusted data that may contain injected 'lc' structures. Use LangGraph checkpoints, Checkpoint serialization/deserialization paths may be affected. The most common attack vector is through LLM response fields like additionalkwargs or responsemetadata, which can be controlled via prompt injection and then serialized/deserialized in streaming operations. Impact Attackers who control serialized data can extract environment variable secrets by injecting {"lc": 1, "type": "secret", "id": ["ENVVAR"]} to load environment variables during deserialization (when secretsFromEnv: true). They can also instantiate classes with controlled parameters by injecting constructor structures to instantiate any class within the provided import maps with attacker-controlled parameters, potentially triggering side effects such as network calls or file operations. Key severity factors: Affects the serialization path, applications trusting their own serialization output are vulnerable Enables secret extraction when combined with secretsFromEnv: true LLM responses in additionalkwargs can be controlled via prompt injection Exploit example Security hardening changes This patch introduces the following changes to load(): secretsFromEnv default changed to false: Disables automatic secret loading from environment variables. Secrets not found in secretsMap now throw an error instead of being loaded from process.env. This fail-safe behavior ensures missing secrets are caught immediately rather than silently continuing with null. New maxDepth parameter (defaults to 50): Protects against denial-of-service attacks via deeply nested JSON structures that could cause stack overflow. Escape mechanism in toJSON(): User-controlled objects containing 'lc' keys are now wrapped in {"lc_escaped": {...}} during serialization and unwrapped as plain data during deserialization. JSDoc security warnings: All import map options (importMap, optionalImportsMap, optionalImportEntrypoints) now include security warnings about never populating them from user input. Migration guide No changes needed for most users If you're deserializing standard LangChain types (messages, documents, prompts) using the core import map, your code will work without changes: For secrets from environment secretsFromEnv now defaults to false, and missing secrets throw an error. If you need to load secrets: Warning: Only enable secretsFromEnv if you trust the serialized data. Untrusted data could extract any environment variable. Note: If a secret reference is encountered but not found in secretsMap (and secretsFromEnv is false or the secret is not in the environment), an error is thrown. This fail-safe behavior ensures you're aware of missing secrets rather than silently receiving null values. For deeply nested structures If you have legitimate deeply nested data that exceeds the default depth limit of 50: For custom import maps If you provide custom import maps, ensure they only contain trusted modules:
Untrusted serialized data is processed by a deserializer that can instantiate arbitrary objects or execute code as a side effect. Typical impact: arbitrary code execution or logic abuse.
CVE-2025-68665 has a CVSS score of 8.6 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment.
A fixed version is available (1.1.8, 0.3.80, 1.2.3, 0.3.37). Upgrading removes the vulnerable code path.
npm
@langchain/core (>= 1.0.0, < 1.1.8)@langchain/core (< 0.3.80)langchain (>= 1.0.0, < 1.2.3)langchain (< 0.3.37)@langchain/core → 1.1.8 (npm)@langchain/core → 0.3.80 (npm)langchain → 1.2.3 (npm)langchain → 0.3.37 (npm)Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter instead of chasing every advisory.
Kodem's Application Detection and Response identifies whether CVE-2025-68665 is reachable in your applications. Explore runtime application protection for your team.
See if CVE-2025-68665 is reachable in your applications. Get a demo
Already deployed Kodem? See CVE-2025-68665 in your environment →Upgrade the following packages to resolve this vulnerability:
@langchain/core to 1.1.8 or later@langchain/core to 0.3.80 or laterlangchain to 1.2.3 or laterlangchain to 0.3.37 or laterKodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
CVE-2025-68665 is a high-severity insecure deserialization vulnerability in @langchain/core (npm), affecting versions >= 1.0.0, < 1.1.8. It is fixed in 1.1.8, 0.3.80, 1.2.3, 0.3.37. Untrusted serialized data is processed by a deserializer that can instantiate arbitrary objects or execute code as a side effect.
CVE-2025-68665 has a CVSS score of 8.6 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
@langchain/core (npm) (versions >= 1.0.0, < 1.1.8)langchain (npm) (versions >= 1.0.0, < 1.2.3)Yes. CVE-2025-68665 is fixed in 1.1.8, 0.3.80, 1.2.3, 0.3.37. Upgrade to this version or later.
Whether CVE-2025-68665 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
@langchain/core to 1.1.8 or later@langchain/core to 0.3.80 or laterlangchain to 1.2.3 or laterlangchain to 0.3.37 or later