NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · LangChain

CVE-2026-44843: LangChain vulnerable to unsafe deserialization of attacker-controlled objects through overly broad `load()` allowlists

highCVSS 3.1 8.2GHSA-pjwx-r37v-7724

langchain-core revives LangChain objects from attacker-shaped data in some older runtime paths, because they call load() with allowed_objects="all". An app that passes untrusted nested JSON into RunnableWithMessageHistory, astream_log() or astream_events(version="v1") can have its chat history poisoned or trusted classes built with attacker arguments. Fixed in langchain-core 1.3.3 and 0.3.85.

Published May 8, 2026 · Updated Jun 8, 2026 · Analysis Oct 28, 2026

What an attacker can do

LangChain serializes objects as dictionaries with lc, type, id and kwargs keys. Several older runtime paths deserialize run inputs, run outputs and message history with a broad load() allowlist. If an attacker submits a nested dictionary shaped like {"lc": 1, "type": "constructor", "id": ["langchain_core", "messages", "ai", "AIMessage"], "kwargs": {...}} and the app keeps it in run data, LangChain builds that class instead of treating the dictionary as plain data. This is not arbitrary Python object deserialization. Only trusted LangChain-serializable classes can be revived, but the constructor arguments come from the attacker. A second flaw, a secret-marker bypass in _is_lc_secret, let such dictionaries skip escaping during dumps() then loads() round trips.

The app is exposed only if it accepts untrusted structured input, does not reduce it to an inert schema before calling LangChain, keeps the nested structure in run inputs or outputs, and uses an affected path.

Realistic outcomes in the advisory are persistent chat-history poisoning through fake AIMessage, HumanMessage or SystemMessage objects, prompt injection when those messages reach model context, and instantiation of unexpected trusted objects. If an object reads environment credentials, builds clients or contacts attacker-chosen endpoints at construction, credential disclosure or server-side requests are possible. Apps that validate requests to a fixed schema, such as a plain string, are unlikely to be exposed.

Who is affected

Affected: pip package langchain-core >= 1.0.0 and <= 1.3.2, and langchain-core <= 0.3.84. The named runtime surfaces are RunnableWithMessageHistory, astream_log() and astream_events(version="v1"). Apps that explicitly load serialized prompts or runnables from untrusted places (shared prompt stores, Hub artifacts) can be exposed through similar patterns.

Check the version:

pip show langchain-core

Then search your code for the three APIs and for calls to load() or loads().

langchain-core

Ecosystem
PyPI
Affected
>= 1.0.0, <= 1.3.2
Fixed in
1.3.3
Check
pip show langchain-core

langchain-core

Ecosystem
PyPI
Affected
<= 0.3.84
Fixed in
0.3.85
Check
pip show langchain-core

How to fix it

Upgrade langchain-core to 1.3.3 (1.x line) or 0.3.85 (0.3 line):

pip install --upgrade "langchain-core>=1.3.3"

The release deprecates RunnableWithMessageHistory, astream_log() and astream_events(version="v1"), tightens load() and loads(), and fixes the _is_lc_secret bypass. Move to the newer stream API and memory patterns.

The advisory's guidance, which also reduces exposure: coerce user input into a plain string or message-content field before invoking LangChain; never pass user-controlled data to load() or loads(); and pass a narrow allowed_objects value for a trusted manifest rather than relying on the default or allowed_objects="all".

How to tell if you were hit

Look in stored chat history and run logs for entries containing the keys lc and type: "constructor" inside user-supplied fields. Messages in the history store that the user never sent through your normal message path, or that claim to be from the AI or system, point to poisoning.

In code, grep for allowed_objects="all", for load( and loads( on request data, and for the three affected APIs. In request logs, look for JSON bodies where text fields contain nested objects with an lc key. Unexpected outbound connections from the app at object construction time can mean a client was built with attacker arguments.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

LangChain contains older runtime code paths that deserialize run inputs, run outputs, or other application-controlled payloads using overly broad object allowlists. These paths may call load() with allowed_objects="all". This does not enable arbitrary Python object deserialization, but it does allow any trusted LangChain-serializable object to be revived, which is broader than these runtime paths require. As a result, attacker-supplied LangChain serialized constructor dictionaries may cause trusted runtime paths to instantiate classes with untrusted constructor arguments.

Applications are exposed only when all of the following are true:

  1. The application accepts untrusted structured input, such as JSON, from a user or network request.
  2. The application does not validate or canonicalize that input into an inert schema before invoking LangChain.
  3. Attacker-controlled nested dictionaries or lists are preserved in LangChain run inputs or outputs.
  4. The application uses an affected API path that later deserializes that run data.

Known affected runtime surfaces include:

  • RunnableWithMessageHistory
  • astream_log()
  • astream_events(version="v1")

Related unsafe deserialization patterns may also affect applications that explicitly load serialized LangChain prompt or runnable objects from untrusted sources, including shared prompt stores, Hub artifacts with model configuration, or other application-controlled serialization stores.

Applications that validate incoming requests against a fixed schema, such as coercing user input to a plain string or message-content field before invoking LangChain, are unlikely to expose this deserialization primitive.

This release also fixes a related secret-marker validation bypass in the serialization and deserialization layer (_is_lc_secret). That issue creates an additional path by which attacker-controlled constructor dictionaries can avoid escaping during dumps() -> loads() round-trips and reach LangChain object revival logic.

Impact

An attacker who can submit untrusted structured input to an affected application, and have that structure preserved in LangChain run data, may be able to inject LangChain serialized constructor payloads such as:

{
  "lc": 1,
  "type": "constructor",
  "id": ["langchain_core", "messages", "ai", "AIMessage"],
  "kwargs": {"content": "attacker-controlled content"}
}

If this payload reaches a broad load() call, LangChain may instantiate the referenced class instead of treating the payload as inert user data.

Realistic impacts include:

  • Persistent chat-history poisoning when revived AIMessage, HumanMessage, or SystemMessage objects are stored by RunnableWithMessageHistory.
  • Prompt injection or behavior manipulation if attacker-controlled messages are later included in model context.
  • Instantiation of unexpected trusted LangChain objects with attacker-controlled constructor arguments.
  • Possible credential disclosure or server-side requests if a reachable object reads environment credentials, creates clients, or contacts attacker-controlled endpoints during initialization.
  • Additional prompt-template or runnable-configuration impacts in applications that separately load and execute untrusted serialized LangChain objects.

Remediation

LangChain will deprecate the affected APIs as part of this fix:

  • RunnableWithMessageHistory
  • astream_log()
  • astream_events(version="v1")

These are older code paths that are no longer recommended for new applications. They were not previously marked as deprecated, but recent LangChain documentation has primarily directed users toward newer streaming and memory patterns, including the stream API. Applications should migrate to the currently recommended APIs rather than continue depending on these older surfaces.

Separately, LangChain will update load() and loads() to tighten deserialization behavior so broad object revival is not applied implicitly to untrusted or application-controlled payloads. The older runtime surfaces listed above are being deprecated rather than preserved as supported paths for broad runtime deserialization.

This release also fixes a related secret-marker validation bypass in the serialization and deserialization layer (_is_lc_secret). That issue creates an additional path by which attacker-controlled constructor dictionaries can avoid escaping during dumps() -> loads() round-trips and reach LangChain object revival logic.

Guidance for load() and loads()

load() and loads() should be used only with trusted LangChain manifests or serialized objects from trusted storage. Do not pass user-controlled data to load() or loads(), and do not use them as general parsers for request bodies, tool inputs, chat messages, or other attacker-controlled data.

load() and loads() are beta APIs, and their behavior may change as LangChain narrows unsafe defaults. Future LangChain versions will require callers to be explicit about which objects may be revived. Users should pass a narrow allowed_objects value appropriate for the specific trusted manifest they are loading, rather than relying on broad defaults or allowed_objects="all", which permits the full trusted LangChain serialization allowlist.

Credits

The original issue was first reported by @u-ktdi.

Similar findings were reported by @dewankpant, @shrutilohani, @Moaaz-0x, @pucagit.

A related _is_lc_secret marker bypass affecting dumps() -> loads() round-trips was reported by @yardenporat353 (and a similar report by @localhost-detect)

Credited to u-ktdi, dewankpant, shrutilohani, Moaaz-0x, yardenporat353, pucagit, nick-hollon-lc, localhost-detect.

Questions

Does this give arbitrary code execution?

The advisory says no. It does not enable arbitrary Python object deserialization. It lets trusted LangChain-serializable classes be built with attacker-controlled constructor arguments.

Am I affected if I validate input to a plain string?

Unlikely. The advisory says apps that coerce input to a fixed schema, such as a string or message-content field, before invoking LangChain are unlikely to expose the primitive.

Which APIs are named as affected?

RunnableWithMessageHistory, astream_log() and astream_events(version="v1"). They are being deprecated in the fix.

Is it exploited in the wild?

No source reports exploitation. It is not in CISA's KEV catalog, and its EPSS score is low (0.0038).

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More LangChain vulnerabilities

All LangChain entries