A LangChain serialization vulnerability is a weakness where an application stores or loads AI workflow objects in an unsafe format, allowing an attacker to alter how they are reconstructed. In practice, malicious serialized data can trigger unintended code execution, prompt manipulation, or unauthorized tool use when agents, chains, or memory components are restored.
What this vulnerability means in practice
Serialization becomes dangerous when an application treats stored workflow state as trusted. For LangChain-style systems, that means agents, chains, memory objects, or tool descriptors can be reconstructed from attacker-influenced data, turning a persistence feature into an execution path.
The core issue is not the existence of serialization itself, but unsafe deserialisation boundaries. If the application loads workflow objects without strict integrity checks and type restrictions, the attacker can change what gets rebuilt, which is why this class often sits close to code execution, prompt manipulation, and tool abuse.
Where the exposure comes from
Exposure usually starts where workflow state is persisted, exchanged, or restored across sessions, services, or environments. That can include local files, caches, queues, object stores, backups, or orchestration layers that move agent state between runs.
The risk is highest when the reconstructed object graph can influence execution order, prompt content, or tool selection. In that case, the data does not merely describe the workflow, it can steer it.
- Attackers look for restore paths that accept untrusted input or partially trusted artifacts.
- They target environments where agents can call tools, fetch data, or execute code after loading state.
- They also exploit assumptions that serialized content is “internal” and therefore safe.
How organisations should assess and reduce exposure
Teams should inventory every place serialized AI workflow data is written, copied, and restored, then determine whether any of those paths are reachable by users, plugins, CI jobs, shared storage, or external services. Vendor advisories and project security guidance should be checked for the exact framework or component in use.
Where the application design permits it, prefer safer interchange formats, narrow object schemas, and explicit allowlists for reconstructed types and fields. If unsafe deserialisation cannot be removed immediately, place the restore step behind strong trust boundaries and limit what the restored object can do.
For broader vulnerability triage and emergency response, use a vulnerability management process that prioritises active exploitation, compensating controls, and post-fix verification; the Zero-Day and Exploited Vulnerabilities Guide is a useful reference point for that workflow.
Detection, recovery, and trust impact
Detection should focus on unexpected workflow reconstruction, unusual tool invocation after restore, and prompt or execution behaviour that differs from the known-good baseline. If a serialized payload was accepted before controls were fixed, assume the object graph may already have been used to alter agent behaviour or exfiltrate data.
Post-incident review should include any credentials, session material, API keys, or service access that the compromised workflow could reach. For readers building wider agent security programmes, the Securing Agent Frameworks Guide covers the surrounding controls for deserialisation, tool access, approvals, telemetry, and dependency risk.
Because this class can turn restored state into active control flow, recovery is not only about patching the code path. It also requires reviewing what the attacker may have changed inside the stored workflow, and whether any downstream actions should be treated as untrusted.
Risk and Threat Considerations
Unsafe serialization can convert a storage or restore feature into a compromise path, especially in agentic systems that automatically resume tools, memory, and execution context. The main danger is that the attacker does not need a new execution primitive if the application eagerly trusts reconstructed state.
Failure mechanism: Malicious serialized data changes the object graph or its execution-relevant fields, so restoration triggers unintended code paths, prompt tampering, or unauthorized tool use.
Impact: This can lead to code execution, data exposure, workflow hijacking, credential theft, or lateral abuse through trusted agent actions.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-02 — Secret Leakage | Serialized workflows may expose embedded secrets or tokens. |
| NHI-04 — Insecure Authentication | Unsafe restore can let altered state bypass trusted workflow authentication assumptions. | |
| NHI-10 — Human Use of NHI | Agent state can be restored into human-operated or shared automation flows with unsafe trust transfer. | |
| Recommendation — Keep secrets out of serialized workflow objects and store them in protected vaults. Require integrity-checked reconstruction before any workflow state is trusted. Separate human-operated controls from machine-restored workflow state and validate authority on load. | ||
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | Serialization attacks depend on accepting attacker-controlled data for reconstruction. |
| SC-18 — Mobile Code | Deserialisation can introduce executable behavior from untrusted content. | |
| CM-6 — Configuration Settings | Secure reconstruction depends on hardened runtime and framework configuration. | |
| Recommendation — Validate serialized inputs and reject unexpected fields, types, and structures. Restrict or disable executable behavior embedded in restored objects. Harden serialization settings to block unsafe object types and permissive loaders. | ||
| CIS Controls v8 | CIS-8 — Audit Log Management | Detection depends on logging restore events and unusual post-load actions. |
| CIS-16 — Application Software Security | Application-layer secure design is central to preventing unsafe workflow deserialisation. | |
| Recommendation — Log serialization and restore events so abnormal workflow reconstruction can be investigated. Review application code paths that deserialize workflows and remove unsafe reconstruction logic. | ||
Practitioner Guidance
What to watch for: Treat every restore boundary as a security decision point, not a convenience feature. If a workflow object can influence prompts, tools, or execution, it should be handled as security-sensitive state with explicit trust validation and narrow reconstruction rules.
Practitioner takeaway: In agent frameworks, serialization is safe only when the application can prove the restored object is exactly what was written, and that it cannot expand its own authority on load.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org