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-06-29. Synthesized from 102 of 102 curated resources. Browse all 102 Deserialization resources →

Problem Framing

Deserialization is a fundamental process in software development, enabling the reconstruction of data structures and objects from a serialized format. This is essential for tasks like persisting state, inter-process communication, and data transfer across networks. However, when applications deserialize data from untrusted or user-controlled sources without adequate validation, they become susceptible to a class of vulnerabilities known as insecure deserialization [1][2][3][4][5][6].

At its core, an insecure deserialization vulnerability allows an attacker to influence the deserialization process to achieve malicious outcomes. This typically involves crafting a serialized payload that, when processed by the application, triggers unintended code execution, data manipulation, or denial-of-service conditions [1][2][3][5][6]. The severity of these vulnerabilities stems from their potential to lead to Remote Code Execution (RCE), granting attackers significant control over the compromised system [7][2][8][3][9][4].

The OWASP Top Ten has consistently recognized insecure deserialization as a critical security risk, highlighting its prevalence and impact [10][1][9][4]. This vulnerability class is not confined to a single programming language; it spans Java, Python, .NET, PHP, Ruby, and others, each with its own specific mechanisms and exploitation vectors [1][2][11][4].

Core Mechanics

The deserialization process itself is not inherently insecure. The vulnerability arises from how it is implemented and the data it processes. At a high level, the process involves:

  1. Serialization: An object's state is converted into a format (e.g., byte stream, JSON, XML) that can be stored or transmitted.
  2. Transmission/Storage: The serialized data is sent over a network, read from a file, or retrieved from a database.
  3. Deserialization: The application receives the serialized data and reconstructs the original object(s).

Insecure deserialization occurs when step 3 is performed on data that is untrusted or has been tampered with by an attacker, and the deserialization mechanism does not properly validate the data's integrity or type [2][3][5].

Deserialization Triggers

Deserialization can be triggered in various ways within an application:

The Role of Gadgets and Gadget Chains

A critical aspect of many deserialization exploits is the concept of "gadgets" and "gadget chains." Gadgets are existing classes or methods within an application's dependencies (libraries, frameworks) that perform potentially dangerous operations. When an attacker crafts a serialized payload, they can leverage these gadgets to control program flow during deserialization [2][27][25][28][29][30][31].

A gadget chain is a sequence of method calls on these gadgets, orchestrated through deserialization, that ultimately leads to a "sink" method capable of executing arbitrary code or performing other malicious actions [2][27][25][28][30][4]. The deserialization process automatically invokes these chained methods, effectively turning legitimate code into an exploit vector [2][25][31].

For instance, in Java, a common exploit involves using ObjectInputStream.readObject() which can trigger custom readObject() methods. If a class's readObject() method uses reflection to call a method specified by an attacker-controlled field, this can lead to RCE [31]. Tools like ysoserial (Java) [32][28] and ysoserial.net (.NET) [33][34] are designed to generate payloads that exploit known gadget chains in various libraries.

Language-Specific Mechanisms

The specific mechanics vary by language:

Notable Techniques

Deserialization vulnerabilities can be exploited through a variety of techniques, often tailored to the specific language, library, and application context.

Remote Code Execution (RCE) via Gadget Chains

This is the most severe impact of insecure deserialization. Attackers craft serialized objects that, when deserialized, trigger a sequence of method calls (gadget chains) leading to arbitrary code execution.

PHP unserialize() Exploitation

The unserialize() function in PHP is a common vector. By controlling the serialized string, attackers can instantiate classes with magic methods like __wakeup(), __destruct(), or __toString() that perform malicious actions, such as arbitrary file writes or command execution [40][41][42][15][6].

PHP PHAR Deserialization

The phar:// stream wrapper in PHP can be abused. PHAR archives contain metadata that is automatically deserialized when accessed via the wrapper. Attackers can place serialized objects in the metadata to trigger RCE [22][39][42][15].

.NET ViewState Exploitation

In ASP.NET applications, ViewState often contains serialized data. If the machine key protecting ViewState integrity is compromised or absent, attackers can craft malicious ViewState payloads to achieve RCE [52][13][63][53][61].

YAML Deserialization

Libraries like PyYAML in Python or SnakeYAML in Java can be vulnerable if they use unsafe loading mechanisms (e.g., yaml.load without SafeLoader). This allows attackers to inject malicious Python or Java objects [45][51][16].

Exploiting Specific Libraries/Frameworks

Certain libraries and frameworks have had widespread deserialization vulnerabilities:

Detection & Prevention

Detecting and preventing insecure deserialization requires a multi-layered approach, focusing on both static analysis and runtime monitoring.

Detection Strategies

Prevention and Mitigation

Tooling

A variety of tools aid in identifying, analyzing, and exploiting deserialization vulnerabilities.

Recent Developments

The landscape of deserialization vulnerabilities continues to evolve, with new targets and exploitation techniques emerging.

Where to Go Deeper

For practitioners seeking to deepen their understanding and improve their defensive strategies against deserialization vulnerabilities, the following resources are highly recommended:

Sources cited in this guide

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