portswigger-all-labs

Complete PortSwigger Web Security Academy Lab Writeups Detailed, categorized solutions for every lab — from APPRENTICE to EXPERT — covering all 30 vulnerability types.

View on GitHub

Insecure Deserialization

📦 What is Serialization?

Serialization (also known as marshaling, pickling, freezing, or flattening) is the process of converting complex data structures (like objects and their attributes) into a stream of bytes or string format that can be:

Common formats include:

Binary Formats

Hybrid Formats

Readable Formats


⚠️ What is Insecure Deserialization?

Insecure deserialization happens when user-controllable serialized data is deserialized by the application without proper validation or integrity checks.

This can allow an attacker to:

image


Common Scenarios & Examples

PHP Example:

Serialized Object:

O:4:"User":2:{s:8:"username";s:6:"carlos";s:7:"isAdmin";b:0;}

Payload after tampering:

O:4:"User":2:{s:8:"username";s:6:"carlos";s:7:"isAdmin";b:1;}

If the code does:

$user = unserialize($_COOKIE['user']);
if ($user->isAdmin) {
  // Show admin panel
}

The attacker gains unauthorized admin access.


Java Example:

Serialized Java objects use a binary format:

Payloads can be crafted using tools like:

Watch for:


How to Identify Serialized Data


Common Attacks


Lab-Based Exploit Examples


🔗 Tools


🧠 Summary

Serialization is necessary for transmitting objects but introduces risk when mishandled. Insecure deserialization can lead to severe vulnerabilities such as RCE, privilege escalation, or complete application compromise. Use strict validation, limit deserialization from untrusted sources, and prefer secure serialization formats.

Stay alert. Always validate and verify before you deserialize.