Skip to content
Back to skills

Php Object Injection

ASecurity

PHP Object Injection — unserialize() (or phar:// file ops) on attacker data triggers magic methods and POP gadget chains for RCE/file-ops. Covers __wakeup/__destruct chains, phpggc, phar deserialization, and type-juggling bypass. Tier 1. Payloads: payloads/deserialization.md. Use when PHP apps unserialize cookies/params/tokens or perform file ops on user-controlled paths.

  • 16 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 17, 2026
securityrustphpswiftshellsqlbackend

Works with

  • cli
  • mcp

Security analysis

A100/100

Scanned November 17, 2026

npx -y skills add AnandJogawade/Zazy-Pentest-Plugin-for-Claude --skill php-object-injection --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Php Object Injection?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Php Object Injection
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/anandjogawade-php-object-injection/badge)](https://www.skillsdirectory.com/skills/anandjogawade-php-object-injection)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: php-object-injection
description: "PHP Object Injection — unserialize() (or phar:// file ops) on attacker data triggers magic methods and POP gadget chains for RCE/file-ops. Covers __wakeup/__destruct chains, phpggc, phar deserialization, and type-juggling bypass. Tier 1. Payloads: payloads/deserialization.md. Use when PHP apps unserialize cookies/params/tokens or perform file ops on user-controlled paths."
---

# PHP Object Injection (POP chains)

`unserialize()` on attacker input (or any file op on a `phar://` path) instantiates objects whose magic methods you chain into a POP gadget for RCE or dangerous file ops.

## Trigger phrases
`php object injection, poi, unserialize, pop chain, phpggc, phar deserialization, wakeup destruct`

## Method
1. **Find the sink:** `unserialize($_COOKIE/$_POST/$_GET/...)`; serialized blobs look like `O:4:"User":...` / base64 `Tz`. Also any file op (`file_exists`, `fopen`, `getimagesize`, `file_get_contents`, `is_file`, `md5_file`) on a user-controlled path → `phar://` trigger. Enumerate per ${CLAUDE_PLUGIN_ROOT}/payloads/INJECTION-POINTS.md (cookies, params, hidden fields).
2. **Confirm injection:** supply a serialized object of a class that exists (fingerprint via error messages / source if leaked via `path-traversal`/`xxe`). Detect gadget presence with an OAST-reaching chain before RCE.
3. **Build the POP chain:** identify a class with a useful magic method (`__destruct`/`__wakeup`/`__toString`/`__call`/`__invoke`/`__get`/`__unserialize`) that reaches a sensitive sink (file write, `eval`, `call_user_func`, SQL). Prefer **phpggc** pre-built chains: Laravel, Symfony, Monolog, Guzzle, Doctrine, SlimPHP, SwiftMailer.
   ```
   phpggc monolog/rce1 'phpinfo();' -s
   phpggc Monolog/RCE2 system 'id' -p phar -o /tmp/evil.ini
   phpggc swiftmailer/fw1 /var/www/html/shell.php /tmp/data
   ```
4. **Type-juggling auth bypass:** `a:2:{s:8:"username";b:1;s:8:"password";b:1;}` (`true == "str"`).

## Modern / rare techniques
- [NEW] **Phar deserialization — no explicit `unserialize()`** — `phar://poc.phar/x` deserializes Phar **metadata** on any file op. Craft the phar with JPEG/GIF magic bytes before `__HALT_COMPILER();` to pass upload filters (chain `file-upload`), then trigger via a `phar://` path in an LFI/file param (chain `path-traversal`). Works even with `allow_url_include=Off`.
- [NEW] **New Laravel POP chain** (Quarkslab, 2024) — add to phpggc rotation for modern Laravel targets.
- Custom-class chain building when no phpggc chain fits: map declared classes + their magic methods from leaked source.

## Bypass / evasion
${CLAUDE_PLUGIN_ROOT}/payloads/waf-bypass.md: base64/gzip-wrap the blob, adjust declared string-length ints after edits, use phar trigger to avoid a filtered `unserialize`, `S:` (uppercase) serialized strings with hex escapes to dodge keyword filters.

## Escalation / chaining
RCE → `command-injection` → host/`cloud-pentest`. File-write gadget → webshell (`file-upload`). phar entry via upload+LFI → `file-upload` + `path-traversal`. Broader coverage/other languages → `deserialization`.

## Backend & tooling
Preferred Kali path (native / WSL+Kali / Kali-SSH / Kali-MCP / HexStrike): `phpggc`, PHP CLI to craft/verify blobs locally, interactsh for OAST confirmation, `curl`. If a Burp MCP is present, send the serialized cookie/param to Repeater. Windows-local last resort. See `zazy-orchestrator`.

## Verification (background, before reporting)
Re-confirm independently (second payload/tool/vantage or OAST callback) and reproduce before marking CONFIRMED. Land an OAST callback before concluding a sink is non-exploitable. Report true positives only.

## Evidence
The serialized/phar payload, the triggering request, magic-method/gadget path, resulting command output or file op (or OAST callback), affected input, impact. Remediation: never `unserialize()` untrusted input (use JSON + schema), set `allowed_classes => []`, block/validate `phar://` in file ops, keep phpggc-covered libs patched.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in security →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.