Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is Insecure Deserialisation?

Insecure deserialisation occurs when an application rebuilds objects from untrusted data, allowing an attacker to control which classes are instantiated and what code runs as a result.

Illustration for the cybersecurity term Insecure Deserialisation
Home / Blog / Cybersecurity Terms / What Is Insecure Deserialisation?
17 November 2026

What Is Insecure Deserialisation?

What Is Insecure Deserialisation?

Serialisation converts an in-memory object into bytes that can be stored or transmitted; deserialisation reverses it. The security problem is that native deserialisation does not simply copy values, it reconstructs objects, which means it calls constructors, setters, and lifecycle methods chosen by whoever wrote the byte stream. If that stream came from a user, the user is deciding which code runs inside your process.

Gadget Chains

An attacker rarely has a convenient class that executes commands. Instead they build a gadget chain: a sequence of ordinary classes already present on the application’s classpath, each with a method invoked automatically during deserialisation, arranged so the combination produces execution. No single class in the chain is vulnerable, and none was written with this use in mind. That is what makes the problem structural rather than a bug in any one library.

The canonical example is Apache Commons Collections. CVE-2015-7501 described how its transformer classes could be assembled into a chain that ran an arbitrary command the moment a crafted object was deserialised, and the ysoserial tool shipped ready-made payloads for dozens of such chains. Equivalent toolkits exist for other ecosystems: phpggc for PHP gadget chains and a well-documented set of patterns for .NET formatters.

Where It Appears, by Platform

The data itself turns up in cookies, hidden form fields, view state, authentication tokens, cache entries, and message queues, often base64-encoded. Java streams begin with the bytes AC ED 00 05, which appear as rO0 once base64-encoded, and that four-character prefix is one of the most productive things to search for in traffic captures and log files.

Consequences Beyond Code Execution

Remote code execution is the headline, and it is not the only outcome. Deserialisation can be used to escalate privilege by tampering with a serialised role or user object, to cause denial of service through objects that consume enormous memory or CPU during reconstruction, and to trigger server-side request forgery by instantiating a class that opens a connection. Because the damage happens during reconstruction, it occurs before any application-level validation runs.

Designing It Out

  1. Do not deserialise untrusted data with a native format. This is the only complete fix, and everything below is mitigation for code that cannot be changed yet.
  2. Use a data-only format. JSON, Protocol Buffers, or MessagePack map to fields rather than to arbitrary types. Switch off polymorphic type handling where the library offers it, because features such as Jackson’s default typing reintroduce exactly the problem being avoided.
  3. Apply an allow-list of permitted classes through JEP 290 filters in Java or the allowed_classes option in PHP.
  4. Add integrity protection. Signing or encrypting a serialised blob stops tampering, provided the signature is verified before deserialisation rather than after, and provided the key is not in the repository.
  5. Keep dependencies current with software composition analysis, since each new library version may add or remove gadgets.
  6. Run the service with least privilege and restrict its outbound network access, so a successful chain has somewhere less useful to go.

Finding It

Static analysis locates the dangerous sinks reliably, because the function names are a short list. Dynamic testing is harder: most cases are blind, confirmed through a timing delay or an out-of-band callback rather than a visible response, with Burp Suite’s Java Deserialization Scanner and collaborator-style interaction servers doing the work. Reviewing where serialised data crosses a trust boundary is a standard part of our web application security testing, and a worthwhile question to ask during secure code review before anything reaches production.

FAQ – Frequently Asked Questions

Is JSON Deserialisation Safe?

By default, mostly yes, because JSON describes data rather than types and a parser maps it onto a structure you define. The exception is polymorphic type handling, where a library is configured to read the target class name from the document itself. Jackson’s default typing and similar features in other libraries turn a data format into an object format and reintroduce the vulnerability.

Does Signing the Serialised Data Fix the Problem?

It prevents tampering by an outsider, which closes the common attack path, and it depends on two things holding. The signature must be verified before deserialisation begins, not after, and the key must be genuinely secret rather than committed to the repository or shared across environments. It also offers nothing against data that was already malicious when legitimately produced.

How Do I Spot Serialised Data in Traffic?

Look for recognisable prefixes. Java object streams start with the hexadecimal bytes AC ED 00 05, which become rO0 when base64-encoded. PHP serialised strings begin with a type letter and a colon, such as O:8. .NET view state and Python pickles have their own signatures. Searching cookies, hidden fields, and tokens for these markers finds most instances quickly.

If No Known Gadget Chain Exists, Are We Safe?

No, only unexploited for now. Gadget chains are discovered continuously, and adding a dependency, or upgrading one, can introduce a chain into an application that had none. Relying on the absence of a published chain means your security posture changes whenever someone else publishes research. Remove the untrusted deserialisation instead.

Related Terms

You May Be Interested In These

What Are EDR, MDR, XDR and EPP?

Cybersecurity Terms

18 January 2022

What Are EDR, MDR, XDR and EPP?

Read More
What Is an IMDS Attack?

Cybersecurity Terms

17 November 2026

What Is an IMDS Attack?

Read More
What Is the DREAD Risk Scoring Model?

Cybersecurity Terms

17 November 2026

What Is the DREAD Risk Scoring Model?

Read More