appsec.fyi

Deserialization — A Practical Guide

A curated AppSec resource library covering XSS, SQLi, SSRF, IDOR, RCE, XXE, OSINT, and more.

Deserialization: A Practical Guide

Curated and synthesized by . Last updated 2026-08-01. Synthesized from 103 of 103 curated resources. Browse all 103 Deserialization resources →

The Problem with Untrusted Data

Deserialization is a fundamental process in modern software development. It involves converting serialized data—often a byte stream or text format—back into an object or data structure that an application can use. This is essential for tasks like maintaining application state across requests, inter-process communication, caching, and data storage. However, when applications deserialize data originating from untrusted or attacker-controlled sources without adequate validation, they introduce a significant security risk.

The core of the problem lies in the deserialization process itself. Many serialization mechanisms, particularly native language-specific ones, reconstruct objects by invoking constructors, setters, and even "magic" or special methods (like __destruct or __wakeup in PHP, or readObject in Java) as part of the reconstruction. If an attacker can control the serialized input, they can craft it to instantiate malicious classes or trigger these special methods, leading to unintended and potentially dangerous behavior. This effectively transforms a data handling operation into an arbitrary code execution vulnerability [1] [2] [3].

The OWASP Top Ten consistently highlights insecure deserialization as a critical risk. In the 2017 list, it was ranked #8, and in the 2021 list, it was subsumed into the broader category of "Software and Data Integrity Failures" [4] [1]. This signifies its pervasive and high-impact nature.

The danger is amplified by the vast ecosystem of libraries and frameworks applications depend on. These dependencies often introduce "gadgets"—classes or methods that, when chained together during deserialization, can achieve arbitrary code execution. Attackers don't need to inject new code; they leverage existing, legitimate code to achieve malicious ends [5] [6] [7]. This makes mitigation challenging, as simply removing known dangerous classes is often impractical due to transitive dependencies and the constant discovery of new gadget chains [8] [2].

Core Mechanics: How Deserialization Becomes Exploitable

At its heart, insecure deserialization occurs when an application trusts serialized data to the point where it allows the reconstruction of arbitrary objects, often without verifying the object's origin, integrity, or type. The exploitability hinges on several key factors:

When these conditions align, the deserialization process itself becomes the attack vector. Instead of merely reconstructing data, it can be manipulated to trigger code execution, manipulate application state, cause denial-of-service conditions, or escalate privileges.

Notable Techniques and Attack Vectors

Deserialization vulnerabilities manifest across numerous programming languages and platforms, with specific techniques evolving based on the underlying serialization libraries and runtime environments.

Java Deserialization

Java's native serialization mechanism, particularly via ObjectInputStream.readObject(), is a well-known source of vulnerabilities [17] [20] [2]. The availability of powerful libraries like Apache Commons Collections, Spring, and Groovy provides a rich source of gadgets.

Gadget Chains: Attackers construct sequences of method calls from available classes that, when triggered by deserialization, lead to arbitrary code execution. A classic example involves LazyMap and ChainedTransformer from Apache Commons Collections, which can be chained to call Runtime.exec() [17] [21] [11] [22]. Tools like ysoserial automate the generation of these payloads [23] [21] [19].

Specific Libraries:

PHP Deserialization

PHP's unserialize() function is a common target. Vulnerabilities often arise from classes with "magic methods" like __wakeup() or __destruct(), which are automatically called during deserialization and can be manipulated to execute arbitrary code or perform file operations [28] [10] [29] [30] [15].

PHAR Deserialization: A specific PHP technique abuses the phar:// stream wrapper. When file operations are performed on PHAR archives using this wrapper, the metadata (which can contain serialized objects) is automatically deserialized, potentially leading to RCE via Property-Oriented Programming (POP) chains [31] [29] [15].

POP Chains: Attackers construct serialized objects that leverage magic methods and controllable object properties to hijack control flow and achieve code execution [32] [30]. Tools like phpggc can generate payloads for various PHP frameworks.

Python Deserialization

Python's pickle module is notoriously insecure. The documentation explicitly warns against unpickling untrusted data due to its ability to execute arbitrary code via the __reduce__ method [33] [13] [34] [1] [35] [36].

Model Loading in ML: A significant attack surface exists in AI/ML frameworks that use pickle for model serialization. Maliciously crafted model files can execute arbitrary code when loaded, posing a supply chain risk [37] [38] [34]. Tools like PickleScan aim to detect malicious pickles, but have themselves been found to have bypasses [38] [39].

YAML Deserialization: Libraries like PyYAML, when used with unsafe loaders (e.g., yaml.unsafe_load() or yaml.load(..., Loader=yaml.UnsafeLoader)), are also vulnerable to RCE [13] [40] [41].

.NET Deserialization

In the .NET ecosystem, several serialization formats are susceptible:

Tools like ysoserial.net are used to generate .NET deserialization payloads leveraging gadget chains within common .NET libraries [42] [48] [19].

Other Languages and Formats

Detection and Prevention

Effectively detecting and preventing insecure deserialization requires a multi-layered approach focusing on code hygiene, input validation, and runtime monitoring.

Detection Strategies

Prevention and Mitigation

The most robust mitigation strategy is to avoid deserializing untrusted data altogether. When unavoidable, stricter controls are necessary:

Tooling for Deserialization Security

A variety of tools assist in identifying, generating, and mitigating deserialization vulnerabilities:

Recent Developments

The landscape of deserialization vulnerabilities is constantly evolving:

Where to Go Deeper

For those seeking to deepen their understanding and practical skills in dealing with deserialization vulnerabilities, the following resources are highly recommended:

Sources cited in this guide

  1. Insecure Deserialization: The Vulnerability That Gives Attackers RCE — aquilax.ai
  2. Insecure Deserialization | OWASP — owasp.org
  3. Insecure deserialization | Web Security Academy — portswigger.net
  4. Prevent insecure deserialization attacks (Veracode) — docs.veracode.com
  5. Deserialization Gadget Chain Definition — pentesterlab.com
  6. What Actually Is a Deserialization Gadget Chain? — medium.com
  7. Ruby 2.x Universal RCE Deserialization Gadget Chain | elttam — elttam.com
  8. Depickling, Gadgets, and Chains: The Exploit That Unraveled Equifax — brandur.org
  9. Insecure Deserialization: Risks, Examples, and Best Practices — promon.io
  10. The Anatomy of Deserialization Attacks — cobalt.io
  11. Insecure Deserialization Tutorial and Examples — learn.snyk.io
  12. Insecure Deserialization Explained with Examples — thehackerish.com
  13. PayloadsAllTheThings: Insecure Deserialization Python — github.com
  14. .NET Deserialization Cheat Sheet — github.com
  15. Exploiting Insecure Deserialization Vulnerabilities | PortSwigger — portswigger.net
  16. Precise and Effective Gadget Chain Mining through Deserialization-Guided Call Graph Construction (USENIX Security 2025) — usenix.org
  17. Java Deserialization Gadget Chains Explained — klogixsecurity.com
  18. An In-depth Study of Java Deserialization RCE Exploits — dl.acm.org
  19. Now You Serial, Now You Don't — Systematically Hunting for Deserialization Exploits | Google Cloud — cloud.google.com
  20. Deserialization Vulnerabilities in Java — baeldung.com
  21. ysoserial: Java Deserialization Payload Generator — github.com
  22. PayloadsAllTheThings - Java Deserialization Payloads — github.com
  23. CVE-2025-24813 PoC: Apache Tomcat Java Deserialization — github.com
  24. Jackson deserialization vulnerability exploit (3 gadgets, GitHub) — github.com
  25. SnakeYAML Deserialization Deep Dive (CVE-2022-1471) — greynoise.io
  26. Apache Struts2 Code Execution Exploit (Infopercept) — infopercept.com
  27. Deep Dive into Fastjson Deserialization Vulnerabilities — medium.com
  28. picoCTF Super Serial Writeup: PHP Object Injection Explained Clearly — medium.com
  29. PayloadsAllTheThings - PHP Deserialization Payloads — github.com
  30. PHP Object Injection Research — sonarsource.com
  31. How to Exploit PHAR Deserialization Vulnerability — pentest-tools.com
  32. Exploiting PHP Deserialization with POP Chains — medium.com
  33. SOUR PICKLE: Insecure Deserialization with Python Pickle — medium.com
  34. Pickle Deserialization in ML Pipelines: The RCE That Won't Go Away — afine.com
  35. Introduction to Deserialization Attacks — owlhacku.com
  36. Reversing Pickles with r2pickledec — blog.doyensec.com
  37. The Art of Hide and Seek: Pickle-Based Model Supply Chain Poisoning — arxiv.org
  38. PyTorch Users at Risk: 3 Zero-Day PickleScan Vulnerabilities — jfrog.com
  39. Exposing 4 Critical Vulnerabilities in Python Picklescan — sonatype.com
  40. Docling RCE via PyYAML (CVE-2026-24009) — oligo.security
  41. OWASP Deserialization Cheat Sheet — cheatsheetseries.owasp.org
  42. PayloadsAllTheThings: Insecure Deserialization DotNET — github.com
  43. BinaryFormatter Deserialization Security Guide for .NET — learn.microsoft.com
  44. Deep Dive into .NET ViewState Deserialization — swapneildash.medium.com
  45. ViewState Deserialization Zero-Day in Sitecore (CVE-2025-53690) — cloud.google.com
  46. SharePoint Zero-Day CVE-2025-53770 Actively Exploited — blog.checkpoint.com
  47. .NET JSON.NET Deserialization RCE — invicti.com
  48. ysoserial.net: Deserialization Payload Generator for .NET — github.com
  49. PayloadsAllTheThings - Ruby Deserialization Payloads — github.com
  50. Ruby Vulnerabilities: Exploiting Open, Send, and Deserialization — bishopfox.com
  51. Marshal Madness: A Brief History of Ruby Deserialization Exploits — blog.trailofbits.com
  52. Unsafe Deserialization in Ruby | SecureFlag — knowledge-base.secureflag.com
  53. Insecure Deserialization Guide - SecPortal — secportal.io
  54. Insecure Deserialization in Web Applications — invicti.com
  55. Java Deserialization Cheat Sheet — github.com
  56. CVE-2026-20963: SharePoint Deserialization RCE Analysis — securityboulevard.com
  57. SolarWinds Web Help Desk Deserialization Vulnerability — cybersecuritynews.com
  58. CVE-2026-25769: Wazuh Critical RCE via Unsafe Deserialization — resecurity.com
  59. Security Advisory: Critical RCE Vulnerabilities in React Server Components (CVE-2025-55182) — snyk.io
  60. IBM Langflow Desktop RCE via Insecure Deserialization — thehackerwire.com
  61. CVE-2025-12305: Shiyi-blog RCE via Deserialization — sentinelone.com
  62. IBM webMethods Integration CVE-2025-36072: Deserialization RCE — zeropath.com
  63. Cisco ISE Insecure Java Deserialization (CVE-2025-20124) — sec.cloudapps.cisco.com
  64. Insecure Reflection Practices in Java and C# — sprocketsecurity.com
  65. DELMIA Apriso Insecure Deserialization Exploited in the Wild (CVE-2025-5086) — sonicwall.com
  66. Microsoft SharePoint Deserialization RCE (CVE-2026-26114) — thehackerwire.com
  67. U-Office Force Critical RCE via Insecure Deserialization (CVE-2026-3422) — thehackerwire.com
  68. CVE-2025-34153: Hyland OnBase RCE via Deserialization — sentinelone.com
  69. CVE-2025-42928: SAP jConnect RCE via Deserialization — sentinelone.com
  70. Insecure DeserializationWeb ChallengesPart 1 — medium.com
  71. Leaking internal headers in Flask Ninja with deserialization — eval.blog
  72. TryHackMe — Pickle Rick: Rick Left the Door Open. I Just Walked In. — infosecwriteups.com
  73. Apache Struts vulnerability leads to RCE — medium.com
  74. Exploiting Apache Struts: Writing Better Detections (Gigamon) — blog.gigamon.com
  75. Understanding Insecure Deserialization: Risks and Mitigations — snynr.medium.com
  76. Bug Bounty Hunting: Insecure Deserialization — medium.com
  77. Java Deserialization Tricks - Synacktiv — synacktiv.com
  78. CVE-2026-33728: dd-trace-java Unsafe Deserialization in RMI — advisories.gitlab.com
  79. CVE-2026-33439: OpenAM Pre-Auth RCE via Deserialization — advisories.gitlab.com
  80. Deserialization Gadget Chains in Android: An In-Depth Study — arxiv.org
  81. Deserialization Attacks: How Exploiting Data Formats Can Break Security — firecompass.com
  82. What is PHP Object Injection? An In-Depth Guide — jetpack.com
  83. Deserialization Bugs in the Wild — medium.com
  84. Breaking Pickle: RCE Through Python Deserialization — medium.com
  85. Remote Code Execution (RCE) Prevention - SecPortal — secportal.io
  86. Analyzing Prerequisites of Known Deserialization Vulnerabilities on Java Applications — dl.acm.org
  87. Lab: Exploiting Ruby Deserialization Using a Documented Gadget Chain | PortSwigger — portswigger.net
  88. WSUS Deserialization Exploit in the Wild (CVE-2025-59287) — research.eye.security
📚 This guide is synthesized from the full text of resources curated in the Deserialization library, and refreshed as new material is added.