Deserialization Vulnerability Audit
Purpose
Perform a targeted audit of deserialization attack surfaces across any language.
This skill provides structured knowledge of dangerous deserialization sinks, safe alternatives,
gadget chain indicators, and a step-by-step exploitation methodology.
This is a depth-first specialist skill — it goes deeper on deserialization than the
general eresus-manual-security-audit skill. Use it when the target application processes
serialized data from untrusted sources.
Universal Attack Methodology
Step 1: Identify the Deserialization Sink
Search the codebase for functions that convert serialized data back into objects.
Use grep_search with these patterns per language:
Java: ObjectInputStream, readObject, XStream, fromXML, Kryo, readClassAndObject
Python: pickle.load, pickle.loads, yaml.load, marshal.loads, shelve.open
Ruby: Marshal.load, YAML.load, Oj.load, Ox.load
PHP: unserialize, simplexml_load_string
.NET: BinaryFormatter, SoapFormatter, NetDataContractSerializer, LosFormatter
Node.js: node-serialize, funcster, cryo
Step 2: Trace the Input Source
For each sink found, trace backwards to determine:
- Does the serialized data come from an untrusted source? (HTTP request, file upload, message queue, database)
- Is there any validation or type filtering before deserialization?
- Can the attacker control the full serialized payload or only parts of it?
Step 3: Check for Type Control
The key question: can the attacker control which class/type gets instantiated?
- If the format allows arbitrary type specification (YAML tags, Java serialization, .NET TypeNameHandling),
it is almost certainly exploitable
- If the format is type-restricted (JSON without polymorphism,
yaml.safe_load), it may be safe
Step 4: Identify Available Gadgets
Look for classes on the classpath/load path that have dangerous side effects during deserialization:
- Classes with
__reduce__ / readObject / marshal_load methods
- Classes that perform I/O, execute commands, or make network requests during construction
- Classes that invoke callbacks or proxy methods during deserialization
Step 5: Build and Test
- Detection PoC first — construct a callback-based payload (DNS/HTTP) that proves the sink
processes attacker-controlled types
- RCE PoC second — only after confirming the sink is exploitable, construct a command execution payload
- Document the chain — show the full gadget chain from deserialized object to code execution
Per-Language Reference
Java
| Sink |
Risk |
Safe Alternative |
ObjectInputStream.readObject() |
Critical — arbitrary class instantiation |
ObjectInputFilter (Java 9+), allowlist |
XStream.fromXML() |
Critical — without type allowlist |
XStream.allowTypes() or XStream.setupDefaultSecurity() |
Kryo.readObject() |
High — without registration |
kryo.setRegistrationRequired(true) |
Jackson @JsonTypeInfo(use=CLASS) |
Critical — arbitrary class |
@JsonTypeInfo(use=NAME) with allowlist |
SnakeYAML.load() |
Critical — arbitrary class via !! tags |
new SafeConstructor() |
Gadget chain indicators in Java:
- Classes implementing
Serializable with readObject() or readResolve()
- Proxy classes:
InvocationHandler, DynamicProxy
- Known gadget libraries: Commons Collections, Commons BeanUtils, Spring, ROME
Python
| Sink |
Risk |
Safe Alternative |
pickle.loads(data) |
Critical — arbitrary code execution |
json.loads(), Pydantic models |
pickle.load(file) |
Critical — arbitrary code execution |
json.load(), Protocol Buffers |
yaml.load(data) |
Critical — arbitrary object instantiation |
yaml.safe_load(data) |
shelve.open(path) |
Critical — uses pickle internally |
Custom JSON-based storage |
marshal.loads(data) |
High — code object creation |
json.loads() |
Gadget chain indicators in Python:
- Classes with
__reduce__() or __reduce_ex__() methods
- The
os.system, subprocess.Popen classes are directly invokable via __reduce__
pickle can execute arbitrary code with just __reduce__ returning (os.system, ('cmd',))
Ruby
| Sink |
Risk |
Safe Alternative |
Marshal.load(data) |
Critical — RCE via universal gadget chain |
JSON.parse(data) |
YAML.load(data) |
Critical — RCE via Psych engine |
YAML.safe_load(data) |
Oj.load(data, mode: :object) |
Critical — arbitrary object instantiation |
Oj.load(data, mode: :strict) |
Ox.load(data, mode: :object) |
Critical — arbitrary object instantiation |
Ox.load(data, mode: :generic) |
Ruby universal gadget chain (works up to Ruby 3.3.x):
- Based on William Bowling's research (vakzz)
- Detection: callback payload that hits an URL when processed by vulnerable sink
- RCE: uses
zip command via GTFOBins technique
- Affects ALL four serialization libraries (Marshal, YAML/Psych, Oj, Ox)
PHP
| Sink |
Risk |
Safe Alternative |
unserialize($data) |
Critical — POP chain exploitation |
json_decode($data) |
simplexml_load_string($data) |
High — XXE |
libxml_disable_entity_loader(true) |
Gadget chain indicators in PHP:
- Classes with
__wakeup(), __destruct(), __toString(), __call() magic methods
- POP (Property-Oriented Programming) chains via autoloaded classes
- Frameworks like Laravel, Symfony have known gadget chains
.NET
| Sink |
Risk |
Safe Alternative |
BinaryFormatter.Deserialize() |
Critical — banned in .NET 9+ |
System.Text.Json |
SoapFormatter.Deserialize() |
Critical |
System.Text.Json |
NetDataContractSerializer |
Critical |
DataContractSerializer with known types |
ObjectStateFormatter |
Critical — ViewState attacks |
Encrypted/signed ViewState |
LosFormatter |
Critical |
System.Text.Json |
JsonSerializer with TypeNameHandling.All |
Critical |
TypeNameHandling.None |
Gadget chain indicators in .NET:
- Classes implementing
ISerializable
OnDeserializing / OnDeserialized attributes
- Known chains:
System.Windows.Data.ObjectDataProvider, System.Activities.*
Node.js
| Sink |
Risk |
Safe Alternative |
node-serialize.unserialize() |
Critical — direct eval() |
JSON.parse() |
funcster.deepDeserialize() |
Critical — function reconstruction |
JSON.parse() |
cryo.parse() |
High — object reconstruction |
JSON.parse(), superjson |
Red Flags Checklist
When reviewing any deserialization code, check for these red flags:
Tooling Constraints
Use ONLY these tools:
view_file — read source code to trace deserialization flows
grep_search — find deserialization sinks across the codebase
Do NOT use terminal commands like grep, rg, cat, sed, or any shell tools.
Integration
Use this skill when eresus-manual-security-audit or eresus-sast-scanner identifies
a deserialization entry point that needs deeper analysis.
This skill complements eresus-serialization-review which focuses on the broader
serialization attack surface (format confusion, schema validation, etc.).
1---
2name: eresus-deser-audit
3description: >
4 Deserialization vulnerability audit skill with gadget chain knowledge for all major languages.
5 Trigger when the user asks to: "audit deserialization", "check for insecure deserialization",
6 "find pickle vulnerabilities", "Marshal.load audit", "gadget chain analysis",
7 "check for unsafe YAML loading", or when reviewing code that processes serialized data
8 (JSON with type info, YAML, XML, binary formats).
9metadata:
10 source: https://skillmd.com/skills/aibot88/eresus-deser-audit
11 version: "1.0"
12 domain: application-security
13 mode: deserialization-audit
14 persona: exploit-developer
15---
16
17# Deserialization Vulnerability Audit
18
19## Purpose
20
21Perform a targeted audit of deserialization attack surfaces across any language.
22This skill provides structured knowledge of dangerous deserialization sinks, safe alternatives,
23gadget chain indicators, and a step-by-step exploitation methodology.
24
25This is a **depth-first specialist skill** — it goes deeper on deserialization than the
26general `eresus-manual-security-audit` skill. Use it when the target application processes
27serialized data from untrusted sources.
28
29---
30
31## Universal Attack Methodology
32
33### Step 1: Identify the Deserialization Sink
34
35Search the codebase for functions that convert serialized data back into objects.
36Use `grep_search` with these patterns per language:
37
38**Java:** `ObjectInputStream`, `readObject`, `XStream`, `fromXML`, `Kryo`, `readClassAndObject`
39**Python:** `pickle.load`, `pickle.loads`, `yaml.load`, `marshal.loads`, `shelve.open`
40**Ruby:** `Marshal.load`, `YAML.load`, `Oj.load`, `Ox.load`
41**PHP:** `unserialize`, `simplexml_load_string`
42**.NET:** `BinaryFormatter`, `SoapFormatter`, `NetDataContractSerializer`, `LosFormatter`
43**Node.js:** `node-serialize`, `funcster`, `cryo`
44
45### Step 2: Trace the Input Source
46
47For each sink found, trace backwards to determine:
48- Does the serialized data come from an untrusted source? (HTTP request, file upload, message queue, database)
49- Is there any validation or type filtering before deserialization?
50- Can the attacker control the full serialized payload or only parts of it?
51
52### Step 3: Check for Type Control
53
54The key question: **can the attacker control which class/type gets instantiated?**
55
56- If the format allows arbitrary type specification (YAML tags, Java serialization, .NET TypeNameHandling),
57 it is almost certainly exploitable
58- If the format is type-restricted (JSON without polymorphism, `yaml.safe_load`), it may be safe
59
60### Step 4: Identify Available Gadgets
61
62Look for classes on the classpath/load path that have dangerous side effects during deserialization:
63- Classes with `__reduce__` / `readObject` / `marshal_load` methods
64- Classes that perform I/O, execute commands, or make network requests during construction
65- Classes that invoke callbacks or proxy methods during deserialization
66
67### Step 5: Build and Test
68
691. **Detection PoC first** — construct a callback-based payload (DNS/HTTP) that proves the sink
70 processes attacker-controlled types
712. **RCE PoC second** — only after confirming the sink is exploitable, construct a command execution payload
723. **Document the chain** — show the full gadget chain from deserialized object to code execution
73
74---
75
76## Per-Language Reference
77
78### Java
79
80| Sink | Risk | Safe Alternative |
81|------|------|-----------------|
82| `ObjectInputStream.readObject()` | Critical — arbitrary class instantiation | `ObjectInputFilter` (Java 9+), allowlist |
83| `XStream.fromXML()` | Critical — without type allowlist | `XStream.allowTypes()` or `XStream.setupDefaultSecurity()` |
84| `Kryo.readObject()` | High — without registration | `kryo.setRegistrationRequired(true)` |
85| `Jackson @JsonTypeInfo(use=CLASS)` | Critical — arbitrary class | `@JsonTypeInfo(use=NAME)` with allowlist |
86| `SnakeYAML.load()` | Critical — arbitrary class via `!!` tags | `new SafeConstructor()` |
87
88**Gadget chain indicators in Java:**
89- Classes implementing `Serializable` with `readObject()` or `readResolve()`
90- Proxy classes: `InvocationHandler`, `DynamicProxy`
91- Known gadget libraries: Commons Collections, Commons BeanUtils, Spring, ROME
92
93### Python
94
95| Sink | Risk | Safe Alternative |
96|------|------|-----------------|
97| `pickle.loads(data)` | Critical — arbitrary code execution | `json.loads()`, Pydantic models |
98| `pickle.load(file)` | Critical — arbitrary code execution | `json.load()`, Protocol Buffers |
99| `yaml.load(data)` | Critical — arbitrary object instantiation | `yaml.safe_load(data)` |
100| `shelve.open(path)` | Critical — uses pickle internally | Custom JSON-based storage |
101| `marshal.loads(data)` | High — code object creation | `json.loads()` |
102
103**Gadget chain indicators in Python:**
104- Classes with `__reduce__()` or `__reduce_ex__()` methods
105- The `os.system`, `subprocess.Popen` classes are directly invokable via `__reduce__`
106- `pickle` can execute arbitrary code with just `__reduce__` returning `(os.system, ('cmd',))`
107
108### Ruby
109
110| Sink | Risk | Safe Alternative |
111|------|------|-----------------|
112| `Marshal.load(data)` | Critical — RCE via universal gadget chain | `JSON.parse(data)` |
113| `YAML.load(data)` | Critical — RCE via Psych engine | `YAML.safe_load(data)` |
114| `Oj.load(data, mode: :object)` | Critical — arbitrary object instantiation | `Oj.load(data, mode: :strict)` |
115| `Ox.load(data, mode: :object)` | Critical — arbitrary object instantiation | `Ox.load(data, mode: :generic)` |
116
117**Ruby universal gadget chain (works up to Ruby 3.3.x):**
118- Based on William Bowling's research (vakzz)
119- Detection: callback payload that hits an URL when processed by vulnerable sink
120- RCE: uses `zip` command via GTFOBins technique
121- Affects ALL four serialization libraries (Marshal, YAML/Psych, Oj, Ox)
122
123### PHP
124
125| Sink | Risk | Safe Alternative |
126|------|------|-----------------|
127| `unserialize($data)` | Critical — POP chain exploitation | `json_decode($data)` |
128| `simplexml_load_string($data)` | High — XXE | `libxml_disable_entity_loader(true)` |
129
130**Gadget chain indicators in PHP:**
131- Classes with `__wakeup()`, `__destruct()`, `__toString()`, `__call()` magic methods
132- POP (Property-Oriented Programming) chains via autoloaded classes
133- Frameworks like Laravel, Symfony have known gadget chains
134
135### .NET
136
137| Sink | Risk | Safe Alternative |
138|------|------|-----------------|
139| `BinaryFormatter.Deserialize()` | Critical — **banned in .NET 9+** | `System.Text.Json` |
140| `SoapFormatter.Deserialize()` | Critical | `System.Text.Json` |
141| `NetDataContractSerializer` | Critical | `DataContractSerializer` with known types |
142| `ObjectStateFormatter` | Critical — ViewState attacks | Encrypted/signed ViewState |
143| `LosFormatter` | Critical | `System.Text.Json` |
144| `JsonSerializer` with `TypeNameHandling.All` | Critical | `TypeNameHandling.None` |
145
146**Gadget chain indicators in .NET:**
147- Classes implementing `ISerializable`
148- `OnDeserializing` / `OnDeserialized` attributes
149- Known chains: `System.Windows.Data.ObjectDataProvider`, `System.Activities.*`
150
151### Node.js
152
153| Sink | Risk | Safe Alternative |
154|------|------|-----------------|
155| `node-serialize.unserialize()` | Critical — direct `eval()` | `JSON.parse()` |
156| `funcster.deepDeserialize()` | Critical — function reconstruction | `JSON.parse()` |
157| `cryo.parse()` | High — object reconstruction | `JSON.parse()`, `superjson` |
158
159---
160
161## Red Flags Checklist
162
163When reviewing any deserialization code, check for these red flags:
164
165- [ ] Serialized data comes from HTTP request body, headers, cookies, or query parameters
166- [ ] Serialized data comes from message queues, webhooks, or external APIs
167- [ ] Serialized data is stored in a database that may be compromised
168- [ ] No type filtering or allowlisting before deserialization
169- [ ] Using a serialization format that supports arbitrary type instantiation
170- [ ] Using `pickle`, `Marshal`, `BinaryFormatter`, or `ObjectInputStream` with user data
171- [ ] YAML loaded with `yaml.load()` instead of `yaml.safe_load()`
172- [ ] JSON deserialization with type handling enabled (`@JsonTypeInfo`, `TypeNameHandling`)
173- [ ] Session data stored in cookies using serialization (not encrypted/signed)
174- [ ] ViewState without encryption and MAC validation
175
176---
177
178## Tooling Constraints
179
180Use ONLY these tools:
181- `view_file` — read source code to trace deserialization flows
182- `grep_search` — find deserialization sinks across the codebase
183
184Do NOT use terminal commands like `grep`, `rg`, `cat`, `sed`, or any shell tools.
185
186---
187
188## Integration
189
190Use this skill when `eresus-manual-security-audit` or `eresus-sast-scanner` identifies
191a deserialization entry point that needs deeper analysis.
192
193This skill complements `eresus-serialization-review` which focuses on the broader
194serialization attack surface (format confusion, schema validation, etc.).