Arviser

CVE-2025-68664 in langchain-core: how model output can leak your secrets

Advisory explainer. Facts come from the public advisory linked in the sources. Last checked: 2026-11-22.

Short answer: CVE-2025-68664 is a serialization injection bug in langchain-core. Text that an attacker controls, including model output steered by prompt injection, could be rebuilt as a LangChain object when your app deserialized it, and that could expose environment variables such as API keys. Fixed in langchain-core 0.3.81 and 1.2.5. If you run an older version, upgrade first and then check how your app serializes data.

What does the advisory record say?

Short answer: GitHub rates it critical, CVSS 3.1 score 9.3. The National Vulnerability Database shows its own score of 8.2, high, with the same attack vector and a different scope value. The weakness type is CWE-502 (deserialization of untrusted data). Published on 2025-12-23.

Field Value in the GitHub advisory
Advisory ID GHSA-c67j-w6g6-q2cm
CVE CVE-2025-68664
Package langchain-core on PyPI
Affected versions 1.0.0 up to but not including 1.2.5, and everything before 0.3.81
Fixed versions 1.2.5 and 0.3.81
CVSS 3.1 vector AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N

The functions dumps() and dumpd() did not escape dictionaries that contain the key lc. LangChain uses that key to mark its own serialized objects. When such a dictionary came back through load() or loads(), it was treated as a real LangChain object and not as plain data.

Why does this matter for a model-based product?

Short answer: the text that reaches serialization often comes from outside your control. The advisory names LLM response fields such as additional_kwargs and response_metadata as the most common path, because prompt injection can influence them.

The attack chain below is our illustration of the advisory's description, not a quote from it. A user or a retrieved document plants an instruction. The model output carries a crafted structure into a metadata field. Your app serializes the run, for example for streaming events or message history, and later loads it. The loader reads the planted structure and acts on it. One structure type asks the loader to read an environment variable, and in the old default configuration (secrets_from_env=True) it did. The advisory also says injected structures could instantiate classes inside the trusted LangChain namespaces, including classes with side effects such as network calls or file operations.

This is the pattern behind LLM01 Prompt Injection in our OWASP LLM Top 10 2026 mapping and the reason indirect injection reaches secrets, as described in the indirect prompt injection guide.

Which code paths does the advisory list as affected?

Short answer: any code that serializes data containing untrusted text and later deserializes it. The advisory lists these among its cases:

The advisory lists more cases. Check your code against the full list.

What changed in the fix?

Short answer: escaping was fixed and three defaults became stricter, which are breaking changes for some apps.

If you deserialize your own custom classes, the advisory says to list them in allowed_objects explicitly.

What should you check in your own system?

Short answer: version, usage, and what a leaked environment would expose.

  1. Version. Run pip show langchain-core in every deployed image, not only in your lockfile. Compare with 0.3.81 and 1.2.5.
  2. Usage. Search the code for astream_events, astream_log, dumps, dumpd, load(, loads(, hub.pull and RunnableWithMessageHistory. For each hit, write down where the serialized text came from.
  3. Blast radius. List what lives in the process environment of the agent. API keys for tools the agent does not use should not be there. See agent tool permissions.
  4. Regression test. Put a canary value in an environment variable in a test run. Send a user message and a retrieved document that carry the structure from the advisory's own example, pointed at the canary. Assert that the canary never appears in any output, log or stored state. Our AI security regression tests guide shows how to keep such a test in CI.
  5. Logs. Check whether serialized runs are stored somewhere that more people can read than the secrets themselves. See LLM logging and privacy.

An AI Security Review of your own system is the way to confirm your exposure.

Sources

A record does not mean anyone was attacked.

We re-check this page against the advisory when it is updated. If you see a difference, write to contact@arviser.com.

Weekly advisories · digest by email planned

Hear when the weekly AI security digest starts

Every week we publish a plain-language digest of public advisories for AI frameworks, gateways and MCP servers, with the real dates and what to check for each. The email digest is planned. Leave your address and you get one message when it starts, with a link to confirm. Until then you get nothing else from this form. You can also follow the Atom feed.

Next: Indirect prompt injection · Agent tool permissions and MCP · Twelve security tests · AI Security Review · Request scope

Request a security review