Insecure Deserialization
Reconstructing attacker-controlled serialized data with a mechanism that can instantiate arbitrary types and run their callbacks, so that choosing the bytes becomes choosing the program’s behaviour — classically remote code execution (CWE-502).
What it is
Serialization turns an in-memory object graph into bytes for storage or transport; deserialization rebuilds it. The vulnerability is a trust-boundary failure: an application hands a native object format bytes that a user can modify, and the deserializer does more than read data — it names a type, constructs it, and runs code while doing so. A data-only format (JSON, MessagePack, Protobuf) can only describe strings, numbers, booleans, null, lists and maps, so the worst a hostile document can do on its own is be an unexpected value. A native object format — Python pickle, PHP serialize(), Java ObjectInputStream, .NET BinaryFormatter, Ruby Marshal — can name a class, ask for an instance, and (pickle) name any callable. The question the deserializer answers is not “what data is this?” but “what should I construct, and what runs while I construct it?” (DedSec, OWASP CWE-502).
Three conditions make it dangerous (Mandiant): the serialized object is attacker-controllable; the app deserializes it without validation; and the deserializing process has useful classes on its classpath/importable. The last is why the same vulnerable line is RCE on one deployment and inert on another — exploitability is a property of what code is loadable, not of the bug alone.
Why it matters
- Impact ladder. Benign-looking state tampering (changing a quantity, a username, a role) → object injection and logic subversion → denial of service → authentication bypass → remote code execution, frequently unauthenticated and pre-auth. It is a perennial OWASP Top 10 category spanning C/C++, Java, PHP, .NET, Python, Ruby and Node.
- Severity drivers. Reachability (pre-auth network sink vs. authenticated import), the privilege of the deserializing process (root containers, SYSTEM services), and classpath richness. Many 2025–26 cases are CVSS 9.8–10.0.
- Real breaches. The Equifax breach traced to Apache Struts (CVE-2017-5638); APT41 used .NET ViewState and Java chains against governments and enterprises (Mandiant); SharePoint “ToolShell” (CVE-2025-53770) and WSUS (CVE-2025-59287) saw mass in-the-wild exploitation; DELMIA Apriso (CVE-2025-5086) and Apache Roller (CVE-2026-129448) reached CISA KEV.
How it works
The deserializer rebuilds the graph and, along the way, invokes callbacks the attacker’s chosen types define. Linking those callbacks from an entry point to a dangerous sink is a gadget chain (Property-Oriented Programming): existing, benign code reused in an unexpected order, injecting nothing new. The mechanics differ by stack, each with its own page:
- Java Deserialization —
ObjectInputStream.readObject()and JVM marshallers (XStream, Hessian, Kryo, AMF, SnakeYAML); collection re-hash as the kick-off; JRE/Xalan bytecode and JNDI sinks; JDK 17+ module encapsulation reshaped the landscape. - PHP Object Injection —
unserialize(),maybe_unserialize(), and the implicitphar://metadata path;__wakeup/__destructand POP chains in plugins/libraries. - Python Pickle Deserialization —
pickle.loads()and everything built on it;__reduce__can call any importable callable; the ML-model format problem. - .NET Deserialization —
BinaryFormatter/LosFormatter/ObjectStateFormatter, type-binding JSON/XML, and ASP.NET ViewState keyed onmachineKey. - Polymorphic Deserialization — JSON/YAML/XML/BSON bugs where the document names the concrete type (
$type,@type, AutoType,!!python/object, Puppet__ptype), re-introducing object injection into “data” formats. - Data files whose fields are evaluated — not a deserializer at all, but the same trust failure: yt CVE-2026-132751 restores a saved HDF5 dataset’s
con_argsattribute witheval()(CWE-95), soyt.load()on a shared file runs its author’s Python (Loading a dataset should not run code). See Code Injection and Model Deserialization Attacks. - Ruby
Marshal—marshal_load/_load/_load_dataand implicit kick-offs (hash,eql?); covered within Gadget Chains.
Where to find it
Serialized values surface in cookies and session stores, non-HTTP platform listeners the server profile enables (WildFly IIOP on 3528, read before auth in 32-35), config-management channels (Puppet agent reports on 8140), hidden form fields (ViewState), headers, query/body parameters, import/upload files, caches and message queues (Redis/Celery/Kafka/ZeroMQ), RPC/management ports (RMI, JMX, T3, .NET Remoting, gRPC), and model/checkpoint files. Recognise formats by their first bytes:
| Format | Hex | Base64 begins |
|---|---|---|
| Java native | AC ED 00 05 | rO0AB |
| Pickle proto 2/3/4/5 | 80 02/80 03/80 04 95/80 05 95 | gAJ/gAN/gASV/gAWV |
| PHP object / array | O:5:"..." / a:1:{ | Tzo / YTo |
| .NET BinaryFormatter | — | AAEAAAD///// |
| ASP.NET ViewState | — | /wE |
| Ruby Marshal | 04 08 | BAh |
Node node-serialize | marker _$$ND_FUNC$$_ inside JSON | — |
| gzip wrapper (any of the above) | 1F 8B 08 | H4sI |
Decode and check the actual bytes — a two-character base64 prefix collides by chance (~1 in 4096), while gASV/rO0AB/H4sI do not (DedSec measured).
How to test
A finding is a claim about a chain of four facts, each with its own evidence (DedSec):
- Accepted — the server took the blob. Evidence: a response. (A 200 proves only acceptance.)
- Parsed — a deserializer read the bytes. Evidence: a format-specific error from a truncated/corrupted copy of the app’s own value (
pickle data was truncated,unserialize(): Error at offset N). A generic 500 proves nothing. - Instantiated — a named class was constructed. Evidence: the class name or its side effect (PHP
bad session: CacheWarmervs__PHP_Incomplete_Class). - Executed — attacker-chosen code ran. Evidence: an effect only execution causes — an out-of-band callback carrying a per-request token, or a computed marker.
Methodology:
- Decode the value; note whether it is signed (separator + second component) and/or compressed.
- Prove the deserializer runs by replaying the app’s own value with trailing bytes removed, then corrupted.
- Confirm with an OOB payload first — one unique token per request to an HTTP and DNS listener (Java’s
URLDNS, a Python/pickle stdlib callback; for PHP/Java RCE you need a gadget loadable in the target, so record which one). See Out-of-Band Detection. - Use time only with controls: a non-sleeping payload of the same format, and ideally a delay that scales — a delay on the failure path (a login/bad-session throttle) is a classic false positive.
- On a handler that returns an identical response to every failure, the response cannot confirm or refute anything; only an out-of-band effect can.
- For a signed value, test ordering: an OOB payload under a deliberately wrong signature should produce no callback; if it does, verification runs after deserialization. Separately, check whether the signing key is leaked.
Checklist: decode and identify format → signed/compressed? → prove parse (truncate/corrupt) → OOB payload with unique token (HTTP+DNS) → time only with same-format non-sleeping control → look outside the response → record negatives precisely (“no callback from these gadgets”).
Exploitation and escalation
Impact is whatever the chain’s sink does, and depends on what is loadable — see Gadget Chains for the kick-off/helper/bypass/sink anatomy and per-language entry points and sinks. Escalation paths seen in the corpus: ViewState/machineKey disclosure → signable deserialization sink (.NET Deserialization); leaked Flask SECRET_KEY reused from an OAuth secret → forgeable pickle cookie → unauth RCE (Google, $90k); pre-auth parameters bypassing earlier allowlist patches (OpenAM CVE-2026-33439); cache/queue poisoning (rConfig Laravel Horizon, AWS JDBC wrapper); and post-RCE pivots to CA signing keys (Puppet/OpenVox CVE-2026-115731). Deserialization is a frequent high-value link in a chain to Remote Code Execution.
Bypassing defenses
Common failures of partial mitigations (observed in the corpus and lab-measured by DedSec):
- Validation that runs too late or sees too little. WildFly 32-35 authenticated IIOP calls only after unmarshalling the parameters; jackson’s PTV checked only the outer class of
ArrayList<Gadget>(CVE-2026-54512). The review question is whether the check runs before the dangerous operation and inspects everything it will use (WildFly two roads). - Authenticated-only sinks with weak enrollment. Puppet’s report deserializer needs a CA-signed agent cert, but weak autosign hands one to anyone (Ostorlab Puppet).
- Blocklists/denylists trust every class they did not name. UltraRed built a working chain from Oracle Coherence + Xalan classes a custom blocklist never listed; AI tooling now finds novel chains cheaply — see AI-Accelerated Gadget Discovery.
- Module allowlists are weaker than exact-name allowlists (a Python module allowlist still lets
builtins.evalthrough). - Allowed classes still run their callbacks —
__setstate__,__wakeup,readObjecton an allowed class is a permitted gadget. - Signatures are integrity, not safety — they limit who can submit bytes; a leaked key (git history, env, CI log, image) turns a signed blob back into an unsigned one. Verification after deserialization is no protection.
- Encryption at rest is not trust. rConfig encrypted device passwords and then
unserialized the decrypted value with no class list; the app itself encrypted whatever the user stored, so the ciphertext carried the gadget faithfully (CVE-2026-135692, advisory). - No key at all. Idunno.AntiCsrf ran
ObjectStateFormatterwithout a MAC, unlike ViewState withmachineKey; any non-empty cookie plus a gadget in the form field was enough (THN). - WAFs see only the planting request. For phpAfterShell the unserialize happens when PHP reads a spliced session file, and session data copied from a DB or queue never crosses the WAF (Cloudflare).
- “Weights-only” / option flags are not full boundaries (Stanza reached
pickle.loadsunderweights_only=True). - Scanner bypasses: picklescan/modelscan denylists were bypassed repeatedly (JFrog, Sonatype) via extension trust, ZIP CRC/flag tampering, subclass imports.
- Pre-.NET-4.5 ViewState honoured an unencrypted payload if
__VIEWSTATEENCRYPTEDwas simply removed.
Real-world cases
| CVE / ID | Target | One line |
|---|---|---|
| CVE-2017-5638 / 9805 | Apache Struts | Equifax-era OGNL/XStream RCE |
| CVE-2025-20124 | Cisco ISE | CVSS 9.9, any admin incl. read-only |
| CVE-2025-53690 | Sitecore | ViewState via sample machineKey |
| CVE-2025-53770 | SharePoint “ToolShell” | Unauth ViewState webshell, mass-exploited |
| CVE-2025-59287 | WSUS | Unauth SOAP deserialization, in-the-wild |
| CVE-2025-5086 | DELMIA Apriso | WCF NetDataContractSerializer, KEV |
| CVE-2025-55182 | React/Next.js RSC | ”Flight” protocol, CVSS 10.0 |
| CVE-2026-28326 | SolarWinds ARM | Hardcoded secret → .NET sink, SYSTEM |
| CVE-2026-129448 | Apache Roller | Pre-auth XML-RPC, KEV |
| CVE-2026-115731 | Puppet/OpenVox | __ptype report deserialization → class_eval → CA key; KEV 2026-11-17 |
| CVE-2026-54512 | jackson-databind (WildFly 35) | PTV allowlist bypass via generic type parameters |
| — | WildFly 32-35 IIOP | Pre-auth CORBA parameter deserialization |
| CVE-2026-115560 | PHP sessions “phpAfterShell” | Session serializer mismatch → RCE |
| CVE-2026-131754 | APCu Manager (WordPress) | Object injection, critical |
| CVE-2026-132751 | yt | eval() of a stored dataset attribute |
| CVE-2025-32444 | vLLM | Pickle over ZeroMQ, CVSS 10.0 |
| CVE-2026-126714 | PHP sessions “PHPAfterShell” | Spliced session file → unserialize (SecurityWeek) |
| CVE-2026-131914 | Idunno.AntiCsrf (ASP.NET) | Unkeyed ObjectStateFormatter on the CSRF form token; one pre-auth POST → w3wp.exe RCE, exploited in the wild |
| CVE-2026-135692 | rConfig | EncryptStringCast unserializes decrypted fields; gadget in a device password fires on GET /api/devices |
| CVE-2026-131707 | ProfileGrid (WordPress) | Object injection through 6.0.0.6 |
| CVE-2026-129039 | Tribulant Newsletters (WordPress) | Object injection through 4.18.2, critical |
| CVE-2026-131782 | Simple Shopping Cart (WordPress) | Object injection through 5.3.3, critical |
| CVE-2022-1471 | SnakeYAML | Insecure-by-default YAML |
| — | Google DevSite ($90k) | Pickle cookie signed by its own secret |
Prevention
- Don’t deserialize untrusted data with a native object format. Keep state server-side with an opaque identifier, or use JSON/MessagePack/Protobuf with an explicit schema. OWASP’s first recommendation, and the only control under which no class was looked up at all in the DedSec lab.
- If a native format can’t be removed, allowlist exact expected types at the deserializer: Java
ObjectInputFilter/JEP 290 with default-deny (!*); PHPunserialize($x, ['allowed_classes' => [...]])orfalse; a restricted PythonUnpickleroverridingfind_classwith exact(module, name)pairs; disable type binding (Jackson default typing off, Fastjson safeMode, Json.NETTypeNameHandling.None, PyYAMLsafe_load, Oj:strict). Audit the magic methods of every allowed class. - Integrity-protect where the format is unavoidable, but verify the signature before deserializing and keep keys secret and rotated; treat a leaked
machineKey/SECRET_KEYas a deserialization finding. - Isolate deserialization in least-privilege, egress-restricted compartments; bind RPC/IPC to localhost and authenticate peers first; disable listeners the app doesn’t need (IIOP) and weak certificate autosign; patch gadget-bearing libraries.
- For ML, prefer
safetensors, verify model provenance, and don’t trust a file by extension — see Model Deserialization Attacks.
Tools
- Payload generation / validation:
ysoserial(Java),ysoserial.net/ysonet(.NET),phpggc(PHP);URLDNSfor Java verification;r2pickledec/pickletoolsto read pickles. - Discovery / static analysis: GadgetInspector, Tabby, Crystallizer, ODDFuzz, FLASH (USENIX 2025), GadgetHunter, Gleipner benchmark; Serianalyzer, Find-Sec-Bugs.
- Hunting / detection: Mandiant HeySerial + CheckYoself; Burp deserialization scanners/extensions. Scanners: picklescan / modelscan / PickleBall for ML (with the bypass caveats above).
Sub-pages
- Java Deserialization —
ObjectInputStreamand JVM marshallers; gadget sinks and the JDK 17+ shift. - PHP Object Injection —
unserialize(),phar://, POP chains, session-splice CVEs. - Python Pickle Deserialization —
pickle.loads()and its wrappers; the ML-model problem. - .NET Deserialization —
BinaryFormatter, type-binding JSON, ViewState/machineKey. - Gadget Chains — POP anatomy, per-language entry points and sinks, discovery tooling.
- Polymorphic Deserialization — type-binding bugs in JSON/YAML/XML/BSON “data” formats.
- Model Deserialization Attacks — ML model/checkpoint/cache RCE and scanner bypasses (extra).
- AI-Accelerated Gadget Discovery — LLM-driven chain discovery breaking blocklist defences (extra).
Sources
- Hackers Exploit Critical ASP.NET Anti-CSRF Library Flaw Allowing Unauthenticated RCE · original
- rConfig PHP object injection · original
- ProfileGrid deserialization of untrusted data · original
- Tribulant Newsletters deserialization of untrusted data (critical) · original
- Simple Download Monitor deserialization of untrusted data (critical) · original
- How Cloudflare WAF helps protect against phpAfterShell and other critical PHP flaws · original
- phpAfterShell Vulnerability Revives PHP2Shell's Attack Path · original
- SharePoint Zero-Day CVE-2025-53770 · original
- Puppet Server deserialization RCE (CVE-2026-115731) - Ostorlab · original
- Marshal Madness: Ruby Deserialization Exploits · original
- Depickling, Gadgets, and Chains: the Exploit that Unraveled Equifax · original
- OWASP Deserialization Cheat Sheet · original
- Two roads to RCE in WildFly: pre-auth CORBA deserialization and JSON parser bypass · original
- Systematically Hunting for Deserialization Exploits (Mandiant) · original
- ViewState Deserialization Zero-Day in Sitecore · original
- The Anatomy of Deserialization Attacks · original
- Apache Roller CVE-2026-129448 pre-auth XML-RPC · original
- Insecure deserialization as a DAST finding: confirming it properly · original
- Prevent insecure deserialization attacks (Veracode) · original
- APCu Manager deserialization of untrusted data (critical) · original
- SnakeYAML Deserialization Deep Dive · original
- Insecure Deserialization in Web Applications · original
- GadgetHunter: neuro-symbolic detection of Java deserialization vulns (FSE 2026) · original
- BinaryFormatter Deserialization Security Guide for .NET · original
- Insecure Deserialization Tutorial and Examples · original
- Bug Bounty Hunting: Insecure Deserialization · original
- Deserialization Bugs in the Wild · original
- phpAfterShell: Critical PHP Vulnerabilities (CVE-2026-115560 & CVE-2026-126714) · original
- Insecure Deserialization | OWASP · original
- Exploiting Insecure Deserialization Vulnerabilities · original
- Insecure deserialization | Web Security Academy · original
- Insecure deserialization in Java, .NET, PHP, Python and Node.js · original
- Loading a Dataset Should Not Run Code · original
- WSUS Deserialization Exploit in the Wild · original
- $90k RCE Vulnerability in Google · original
- Critical RCE in React Server Components (CVE-2025-55182) · original
- DELMIA Apriso Insecure Deserialization (CVE-2025-5086) · original
- Insecure Deserialization Explained with Examples · original
- Puppet Enterprise CVE-2026-115731 deserialization RCE · original