/security-agent-skills:hunting-php-object-injection-pop-chainsfrom security-agent-skills
Hunts PHP object injection by locating unserialize() calls on untrusted input and phar:// deserialization triggers, then traces POP chains through __wakeup, __destruct, __toString, and __call to file-write, command, or SQL sinks.
Ships in security-agent-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
PHP object injection follows the same shape as Java gadget chains but through a different trigger. When
unserialize runs on attacker-controlled data, it reconstructs arbitrary objects of any class already
loaded, and PHP's magic methods, __wakeup, __destruct, __toString, __call, run automatically
during or shortly after reconstruction. A property-oriented programming chain stitches these methods
across ordinary classes so that reconstruction alone drives a file write, a system command, or a query.
The same trigger hides inside phar:// stream handling: a filesystem function given an attacker-chosen
path deserializes the archive's metadata without any explicit unserialize call. You find these by
locating every deserialization trigger, explicit or implicit, and asking which loaded classes carry a
magic method that starts a chain.
unserialize on request data, a cookie, a cache entry, or a stored value.phar:// wrapper.Test object injection only against applications you own or are authorized to assess, on non-production data. A confirming chain runs a side effect on the target, a file write or a command, so treat each proof as a live intrusion within the authorized scope. If you can't name the authorization, stop.
Establish the deserialization triggers first. Inventory every unserialize on untrusted data and
every filesystem call, file_exists, fopen, md5_file, getimagesize, and their siblings, that
takes a path an attacker can steer into a phar:// wrapper. This is the false-positive killer: a
magic-method chain is inert unless one of these triggers fires on attacker input. Name the triggers,
then look for chains.
Trace untrusted input into each trigger. Follow request parameters, cookies, headers, cache
values, and database fields that an attacker previously wrote into the unserialize call, and follow
attacker-controlled paths into the filesystem functions. A serialized value the application produced
and never exposes is not a source; anything a client or an upstream writer can set is.
Enumerate reachable magic-method starters. Read the loaded application and library classes for
__wakeup, __destruct, __toString, and __call that do something exploitable: write a file,
invoke a command, build a query, or call another object's method with attacker-controlled arguments.
These are the chain's entry and exit points.
Assemble the chain from starter to sink. A usable POP chain begins at a magic method that fires on reconstruction and threads controlled property values through further calls until it reaches a dangerous operation. Confirm the attacker controls the properties at each hop and that the terminal call, a write, an exec, or a query, is actually reachable with values they set.
Check the defenses that actually stop it. Passing allowed_classes to unserialize, or replacing
native serialization with a data-only format such as JSON, removes object injection at the source. A
type check after reconstruction does not, because the magic method already fired. Determine whether the
trigger restricts classes, whether phar handling is disabled or gated, and whether the format is
data-only.
Confirm and record. Confirm by supplying a benign in-scope object whose chain proves it reaches the
terminal call, a controlled file write or an out-of-band signal, without a destructive payload. Kill
the lead if no untrusted data reaches a deserialization trigger, if unserialize restricts allowed
classes or the format is data-only, or if no reachable magic method starts a chain to a sink. Record
the source, the trigger, the chain, and the terminal call.
phar:// deserializes with no unserialize in sight. A filesystem function on an attacker path
triggers metadata deserialization silently; grepping only for unserialize misses it.__wakeup and __destruct run during and after
reconstruction, before any later validation the code performs.__toString fires from unexpected places. Any later string coercion of a reconstructed object, in
logging or concatenation, can launch a chain that reconstruction alone did not.Confirm. A caching layer stores serialized objects and reads them back with
unserializeand noallowed_classes. A reachable library class defines a__destructthat writes a property to a path built from another property. A crafted serialized value reconstructs into a chain that writes a controlled file to a web-served directory, proving reachability to the write. Confirmed object injection to arbitrary file write,critical, remediation = passallowed_classes: false(or an explicit small allowlist) to everyunserializeon stored data, and move the cache format to JSON.Kill. Every
unserializeon untrusted input passes an explicit allowlist limited to two plain data classes with no magic methods, and phar handling is disabled in the runtime configuration. No crafted string reconstructs a chain-bearing class. Killed,kill_reason= "unserialize restricted to magic-method-free data classes and phar deserialization disabled; no attacker object reaches a starter."
__wakeup and __destruct already ran. Validation
after reconstruction cannot undo a fired chain.__toString or __call that forwards controlled
values into another object can still terminate in a write, a query, or a command downstream.You need every deserialization trigger, explicit unserialize and implicit phar paths, the untrusted
inputs that reach each, the loaded classes with exploitable magic methods, and the class restriction at
each trigger if any. For each trigger, ask whether attacker data arrives, whether a reachable chain runs
from a magic method to a sink, and whether an allowlist stands between. Reading the trigger and the chain
shows intent; a benign controlled side effect shows the chain fires.
hunting-java-deserialization-gadget-chains - the same property-oriented idea in Java, triggered by
readObject rather than a magic method.hunting-unsafe-archive-extraction - phar handling overlaps with archive trust; both turn an
attacker-controlled path or archive into a side effect.hunting-server-side-prototype-pollution - another reconstruction-of-attacker-shaped-object class, in
JavaScript, where merged keys instead of magic methods drive the effect.adjudicating-taint-paths - use it to confirm untrusted data reaches an unserialize call or a phar path
through framework indirection.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub unboundcompute/security-agent-skills --plugin security-agent-skills194 skills in this plugin
/adjudicating-dependency-cve-reachabilityDecide whether a CVE in a dependency actually exposes your application before you scramble to patch: is the vulnerable function on a real call path from your code, do the trigger preconditions hold, and can an attacker control the input that reaches it. Use when an advisory, SCA scan, or dependency bot flags a CVE and you must separate a genuine exposure from unreachable noise, or justify why you are or are not affected. Covers pinning the vulnerable symbol, call-path reachability, precondition checks, and taint from your entry points./adjudicating-taint-pathsDecide whether a whitebox lead is a real bug by tracing taint from an untrusted source to a dangerous sink and confirming every hop against live source. Use after a scanner, a candidate list, or your own reading surfaces a "this looks dangerous" sink (SQL exec, system/exec, file open, deserialize, template render, redirect target, memcpy) and you must decide whether attacker- controlled input actually reaches it - or kill the lead with evidence. Covers forward and reverse taint, witness paths, sanitizer analysis, and the evidence rules that separate a finding from a false positive.Other plugins' skills for the same job