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-07-01. Synthesized from 100 of 100 curated resources. Browse all 100 Deserialization resources →

The Problem of Untrusted Data in Serialization

Deserialization, the process of reconstructing an object from a stream of bytes or other serialized data, is a fundamental mechanism in modern software development. It enables data persistence, inter-process communication, caching, and various other functionalities. However, when applications deserialize data originating from untrusted or user-controlled sources without adequate validation, they become susceptible to a critical class of vulnerabilities: insecure deserialization. This flaw can allow attackers to inject malicious serialized objects, leading to severe consequences such as remote code execution (RCE), denial-of-service (DoS) attacks, privilege escalation, and data corruption [1][2][3][4][5][6][7].

The root cause is the inherent trust placed in the deserialization process. Many serialization formats, especially native ones in languages like Java, .NET, Python, and PHP, are designed to reconstruct not just data but also the behavior of objects. This often involves dynamically loading classes, instantiating objects, and invoking constructors or specific methods (like readObject, __wakeup, or __reduce__) as part of the deserialization lifecycle. If an attacker can control the serialized input, they can craft it to trigger these mechanisms in unintended ways, effectively weaponizing the application's own code against it [8][9][10][11][12][13][14][6][7].

The OWASP Top Ten has consistently highlighted insecure deserialization as a critical security risk, ranking it eighth in both the 2017 and 2021 lists (as part of "Software and Data Integrity Failures") [1][5]. This persistent recognition underscores its widespread impact and the difficulty in fully mitigating it.

Core Mechanics: How Deserialization Works and Becomes Insecure

At its core, serialization involves transforming an object's state into a format that can be stored or transmitted. Deserialization is the reverse: taking that format and reconstructing the original object in memory. The danger arises when the deserialization process trusts the input implicitly.

Consider a simplified Java example: an application serializes a UserSession object to a cookie. Later, when the user's request returns, the application deserializes the cookie to restore the session. If an attacker can intercept and modify this cookie, they can replace the legitimate UserSession object with a malicious one. This malicious object, designed to exploit specific vulnerabilities in the Java runtime or libraries, can trigger arbitrary code execution during the deserialization process [6][7].

The deserialization process often involves dynamic class loading and instantiation. Languages like Java and .NET provide mechanisms to load classes based on their fully qualified names present in the serialized data. If an attacker can control these names, they can point the deserializer to arbitrary classes, including those designed for malicious purposes [8][15].

The Role of Gadgets and Gadget Chains

A critical aspect of many deserialization exploits is the use of "gadgets." Gadgets are existing classes within an application's classpath that, when chained together through specific method calls triggered during deserialization, can achieve a malicious outcome like remote code execution [16][17][9][18][19][13][20][21][7]. Attackers don't need to inject new code; they abuse the legitimate code already present in libraries and frameworks.

For example, in Java, popular libraries like Apache Commons Collections offer classes that, when deserialized under specific conditions, can lead to arbitrary method invocations. A common attack vector involves a sequence like:

1. A deserialization routine calls readObject() on a malicious object. 2. This object, designed using a gadget chain, internally calls a method on another object. 3. This second object's method, in turn, calls another method, eventually reaching a "sink" gadget. 4. The sink gadget performs the attacker's desired action, such as executing an OS command via Runtime.getRuntime().exec() [17][9][13].

Tools like ysoserial for Java and ysoserial.net for .NET automate the discovery and generation of these gadget chains, making exploitation more accessible [22][23][24][19][15][25].

Language-Specific Examples

Notable Techniques and Attack Vectors

Deserialization vulnerabilities manifest in various ways, often depending on the language, the libraries in use, and the application's specific implementation.

Detection and Prevention Strategies

Mitigating insecure deserialization requires a multi-layered approach, focusing on both code-level security practices and runtime monitoring.

Secure Coding Practices

Runtime and Detection Measures

Tooling for Analysis and Exploitation

A robust ecosystem of tools exists to aid in the discovery, analysis, and exploitation of deserialization vulnerabilities.

Recent Developments and Emerging Trends

The landscape of deserialization vulnerabilities is constantly evolving, with new research uncovering novel attack vectors and mitigations.

Where to Go Deeper

For those looking to deepen their understanding and defensive capabilities regarding deserialization vulnerabilities, the following resources offer comprehensive insights:

Sources cited in this guide

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