August 27, 2026
That βRandom Tokenβ Is a Serialized Object β and Itβs RCE
Whatβs up everyone! Nitin here π

By Nitin yadav
2 min read
Insecure deserialization is intimidating to newcomers β it sounds academic and the exploitation looks like black magic. But the finding part is genuinely approachable: it comes down to spotting serialized data where it shouldn't be trusted, and recognizing which language produced it. Once you can fingerprint the blob, tooling handles most of the heavy lifting, and the payoff is frequently RCE. Let's demystify how to spot the insecure ones.
What deserialization is π
Serialization turns an in-memory object into a storable/transmittable byte string; deserialization rebuilds the object from those bytes. The vulnerability appears when an app deserializes attacker-controlled data using an unsafe deserializer. Because rebuilding an object can trigger constructors, magic methods, and property setters, a carefully crafted blob can chain existing code ("gadgets") into arbitrary behavior β up to remote code execution β without the app ever intending it.
Step 1: Find where the blobs live
Serialized data hides in plain sight. Check:
- Cookies (session blobs are a top spot)
- Hidden form fields and
__VIEWSTATE(.NET) - Query/body parameters that hold long encoded strings
- Auth tokens that aren't JWTs
- Caches, message queues, and API bodies
Anything that looks like a long base64/hex string flowing back and forth is a candidate.
Step 2: Fingerprint by magic bytes
Base64-decode the suspicious value and look at the first bytes β each language has a signature:
Java β rO0AB... (base64) or AC ED 00 05 (raw hex)
PHP β O:8:"stdClass":... or a:2:{...} (human-readable!)
.NET β AAEAAAD///// (BinaryFormatter) or a __VIEWSTATE blob
Python β gASV... or \x80\x04 (pickle)
Ruby β \x04\x08 (Marshal)Java β rO0AB... (base64) or AC ED 00 05 (raw hex)
PHP β O:8:"stdClass":... or a:2:{...} (human-readable!)
.NET β AAEAAAD///// (BinaryFormatter) or a __VIEWSTATE blob
Python β gASV... or \x80\x04 (pickle)
Ruby β \x04\x08 (Marshal)PHP serialization is even readable without decoding β O: (object), a: (array), s: (string). Spotting O:8:"User":... in a cookie is a giant flashing sign.
Step 3: Test, then craft a gadget chain
First, confirm the app actually deserializes your input (tamper a byte and watch for a deserialization error/stack trace). Then use the ready-made gadget tools β you rarely hand-craft these:
Java β ysoserial (CommonsCollections, etc.)
PHP β phpggc (Laravel, Symfony, Monolog chains)
.NET β ysoserial.net (ViewState, Json.NET, etc.)
Python β a pickle with a malicious __reduce__Java β ysoserial (CommonsCollections, etc.)
PHP β phpggc (Laravel, Symfony, Monolog chains)
.NET β ysoserial.net (ViewState, Json.NET, etc.)
Python β a pickle with a malicious __reduce__Start with the safest possible proof: a gadget that triggers a DNS lookup or a sleep to your collaborator. If your collaborator gets a hit, you've proven code execution during deserialization without running anything destructive β the ideal PoC.
Step 4: Understand impact
Deserialization impact ranges from tampering with the deserialized object's values (auth bypass, privilege changes) up to full RCE via gadget chains. Because it usually runs in the app's own process, RCE here is typically critical.
- You can tamper deserialized values (change a role/flag) β medium/high
- Gadget chain triggers a DNS/sleep (code execution proven) β high
- Full RCE via a known gadget β critical
Where the wins are
- Java apps with
rO0ABcookies/params and Commons-Collections on the classpath - PHP apps exposing
O:/a:serialized data in cookies or params - .NET
__VIEWSTATEwithout a validated MAC (or with a leaked key) - Python services deserializing pickle from user input (frighteningly common in internal tools/ML pipelines)
Conclusion β the deserialization playbook
- Bug = app deserializes attacker-controlled bytes with an unsafe deserializer.
- Hunt blobs in cookies, hidden fields,
__VIEWSTATE, tokens, params. - Fingerprint by magic bytes:
rO0AB/AC ED(Java),O:/a:(PHP),AAEAAAD(.NET), pickle/Marshal. - Confirm deserialization, then craft with ysoserial / phpggc / ysoserial.net.
- Prove safely with a DNS/sleep callback; impact is usually RCE = critical.
If you Love reading my blogs. Check my Youtube Channel too.