# 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](/guides/owasp-llm-top-10-2026) and the reason indirect injection reaches secrets, as described in the [indirect prompt injection guide](/guides/indirect-prompt-injection).

## 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:

- `astream_events(version="v1")`. Version `v2` is stated as not vulnerable.
- `Runnable.astream_log()`.
- `dumps()` or `dumpd()` on untrusted data followed by `load()` or `loads()`.
- `RunnableWithMessageHistory`.
- `InMemoryVectorStore.load()` on untrusted documents.
- Loading manifests from the LangChain Hub with `hub.pull`.

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.

- `load()` and `loads()` take a new `allowed_objects` parameter that defaults to `core`.
- `secrets_from_env` now defaults to `False`.
- A new `init_validator` blocks Jinja2 templates by default.

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](/guides/agent-tool-permissions-mcp).
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](/guides/ai-security-regression-tests) 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](/guides/llm-logging-privacy).

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

**In the security library:** [Loading a model file runs code: what happened, and how to test your loader](/library/patterns/model-file-loading). Why loading a pickle-based model file can run code, the records from 2018 to 2026, a canary test for your own loader and our lab run on torch and NumPy.

## Sources

A record does not mean anyone was attacked.

- GitHub Advisory Database, [GHSA-c67j-w6g6-q2cm](https://github.com/advisories/GHSA-c67j-w6g6-q2cm). Published 2025-12-23.
- National Vulnerability Database, [CVE-2025-68664](https://nvd.nist.gov/vuln/detail/CVE-2025-68664).
- LangChain releases: [langchain-core 1.2.5](https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.2.5) and [langchain-core 0.3.81](https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.81).

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

<!--digest-card:advisory-->

**Next:** [Indirect prompt injection](/guides/indirect-prompt-injection) · [Agent tool permissions and MCP](/guides/agent-tool-permissions-mcp) · [Twelve security tests](/guides/ai-security-twelve-tests) · [AI Security Review](/ai-security) · [Request scope](/#scope)
