/

CVE-2026-44843

Severity:

HIGH RISK

(8.2)

Unsafe Deserialization in LangChain Runtime Serialization

CVE-2026-44843

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Unexpected Object Instantiation and Logic Abuse in LLM Application Runtimes

Severity:

HIGH RISK

(8.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

LangChain's older runtime serialization paths deserialize run inputs, outputs, and other payloads using overly broad object allowlists, effectively permitting any LangChain-serializable object to be revived.

When an attacker can supply serialized constructor dictionaries, they may cause trusted runtime code paths to instantiate unexpected classes with untrusted constructor arguments, expanding the attack surface for logic abuse and secondary vulnerabilities.

Affected context

This issue affects LangChain-based applications that:

  • Use the framework's runtime serialization/deserialization mechanisms for runs, tools, chains, or agents.
  • Accept or forward user-controlled or application-controlled serialized payloads (e.g., run inputs/outputs, tool configs, or messages) into these deserialization paths.
  • Rely on default or permissive allowed_objects behavior, including paths that use load(..., allowed_objects="all").

The vulnerability manifests where runtime logic trusts that only a narrow set of object types will be reinstantiated but the actual deserialization allows a broader set of LangChain-serializable classes.

Exploit preconditions

  • Attack surface: Application endpoints, workflows, or message channels that:
  • Accept serialized LangChain payloads (e.g., JSON/dict representations of objects), or
  • Persist and later reload such payloads from storage.
  • Required access: Ability to:
  • Provide or influence serialized constructor dictionaries processed by LangChain's deserialization utilities, or
  • Interfere with stored run state/configuration that will later be deserialized.
  • Trigger point: Invocation of LangChain runtime code paths that:
  • Call load() (or equivalent) with allowed_objects="all" or overly broad allowlists, and
  • Use the resulting objects to perform runtime actions (such as running tools, chains, callbacks, or components).
  • Why exploitation is possible:
  • The deserialization logic revives any trusted LangChain-serializable object rather than enforcing a minimal, context-specific type set.
  • Constructor arguments for these objects are derived from attacker-influenced serialized data, enabling instantiation of unexpected classes with untrusted parameters.

Why this happens

The core problem is unsafe deserialization with over-permissive type allowlists, aligning with CWE-502: Deserialization of Untrusted Data.

Instead of enforcing narrow, context-specific sets of permissible object types, the runtime deserialization logic can be configured with allowed_objects="all" or similarly broad rules. This means:

  • Any object that LangChain considers serializable can be reconstructed, regardless of whether it is appropriate for a given runtime path.
  • The framework trusts constructor dictionaries provided at runtime, allowing untrusted data to flow directly into class constructors.

Although this does not allow arbitrary Python object deserialization in the general sense, it still embodies the unsafe deserialization pattern:

  • Serialized data acts as a blueprint for object graphs.
  • Runtime code implicitly assumes these revived objects are safe, creating opportunities for misuse, logic manipulation, or chained exploitation when combined with other vulnerabilities.

Potential impact

  • Instantiation of unexpected LangChain components with untrusted constructor arguments, which may:
  • Bypass intended control flow or validation steps.
  • Enable unexpected tool or chain invocation.
  • Abuse of callback, tool, or agent configurations to:
  • Alter agent behaviors.
  • Expand an attacker's influence over how LLM outputs are processed or acted upon.
  • Indirect security impacts such as:
  • Triggering over-privileged components in the application.
  • Escalating logical access to internal resources exposed via tools or integrations.
  • Facilitation of secondary vulnerabilities if:
  • Other components assume instantiated objects are trusted, or
  • Constructors perform side effects or access sensitive resources.

General mitigation guidance

Mitigation strategies focus on tightening the deserialization boundary and minimizing the trust placed in runtime object reconstruction:

  • Restrict object types per context:
  • Configure deserialization to allow only the minimal set of object types required in a given runtime path.
  • Replace broad settings like allowed_objects="all" with explicit allowlists tailored to each use case.
  • Reduce or eliminate user-controlled serialization formats:
  • Avoid directly accepting raw serialized constructor dictionaries from untrusted sources.
  • Introduce intermediate, strictly-typed DTOs (data transfer objects) or schemas that map to safe runtime representations.
  • Validate and sanitize configuration data:
  • Perform schema-based validation on serialized payloads before deserialization.
  • Enforce strong invariants (e.g., allowed tool IDs, chain types, or configuration parameters) at the application boundary.
  • Constrain runtime privileges:
  • Ensure that instantiated objects operate under least privilege, limiting access to sensitive tools, credentials, and integrations.
  • Separate high-privilege components from data/control flows that may originate from untrusted serialization inputs.
  • Adopt safer serialization patterns:
  • Prefer simpler, data-only structures for cross-boundary communication.
  • Reserve rich object deserialization for strictly internal, trusted channels.

How teams detect issues like this

Effective detection revolves around identifying unsafe deserialization patterns and over-broad type allowlists:

  • Static analysis and code scanning:
  • Search for use of deserialization utilities that:
  • Call load() (or equivalent) on untrusted data.
  • Use allowed_objects="all" or analogous broad configurations.
  • Flag call sites where deserialized objects are immediately used to:
  • Instantiate tools, chains, or agents.
  • Invoke callbacks or perform side-effectful operations.
  • Code review focus areas:
  • Examine boundaries where external or persisted data is converted into LangChain objects.
  • Verify that each runtime context explicitly defines which object types may be deserialized.
  • Look for constructors or factory methods that accept arbitrary dictionaries or dynamic configurations.
  • Runtime monitoring and policy enforcement:
  • Implement logging around deserialization events, including:
  • Object types being revived.
  • Sources of serialized payloads (user input, storage, messaging systems).
  • Apply application-level policies that:
  • Reject or quarantine unknown or unexpected object types.
  • Alert when new or unusual classes appear in deserialization logs.
  • Automated tooling:
  • Incorporate security-focused linters or SAST tools capable of recognizing:
  • Deserialization of untrusted data.
  • Overly permissive object allowlists in serialization frameworks.
  • Integrate these checks into CI pipelines to prevent regressions.

Sources

SourceLink
github.comgithub.com/langchain-ai/langchain/security/advisories/GHSA-pjwx-r37v-7724

Frequently asked

questions

Exploitability depends heavily on how a LangChain-based application handles serialized payloads. If user-controlled or externally influenced serialized dictionaries are passed into these deserialization paths, an attacker can more easily instantiate unexpected components. If all serialized data is strictly internal and trusted, the practical risk is lower, but defensive hardening is still recommended.

An attacker typically needs the ability to provide or influence serialized payloads that the application will deserialize—such as API requests, messages, or configuration/state stored in databases or queues and later reloaded. Without this access, the issue is less likely to be exploitable.

The safest pattern is to remove or avoid broad allowlists like allowed_objects="all" and instead:

  • Define strict, context-specific allowlists of permissible object types.
  • Introduce schema validation or DTOs to constrain what gets deserialized.
  • Treat deserialization of any externally influenced data as a high-risk operation requiring explicit review.

Prevention relies on designing serialization boundaries with minimal trust:

  • Prefer data-only representations when crossing trust boundaries.
  • Explicitly enumerate allowed object types and reject everything else.
  • Use defensive validation and invariants on configuration and control data.
  • Incorporate security reviews and static analysis focused on serialization/deserialization logic during the development lifecycle.
Find out what's already
exploitable in your codebase.