$npx -y skills add SnailSploit/Claude-Red --skill offensive-deserializationWhen this skill is active: 1. Load and apply the full methodology below as your operational checklist 2. Follow steps in order unless the user specifies otherwise 3. For each technique, consider applicability to the current target/context 4. Track which checklist items have been
| 1 | # SKILL: Insecure Deserialization |
| 2 | |
| 3 | ## Metadata |
| 4 | - **Skill Name**: insecure-deserialization |
| 5 | - **Folder**: offensive-deserialization |
| 6 | - **Source**: https://github.com/SnailSploit/offensive-checklist/blob/main/insecure-deserialization.md |
| 7 | |
| 8 | ## Description |
| 9 | Insecure deserialization attack checklist: identifying deserialization sinks, Java/PHP/.NET/Python deserialization exploitation, ysoserial gadget chains, magic method abuse, and detection evasion. Use when testing deserialization endpoints or developing deserialization exploits. |
| 10 | |
| 11 | ## Trigger Phrases |
| 12 | Use this skill when the conversation involves any of: |
| 13 | `deserialization, insecure deserialization, ysoserial, Java deserialization, PHP deserialization, .NET deserialization, pickle, gadget chain, magic method, ObjectInputStream` |
| 14 | |
| 15 | ## Instructions for Claude |
| 16 | |
| 17 | When this skill is active: |
| 18 | 1. Load and apply the full methodology below as your operational checklist |
| 19 | 2. Follow steps in order unless the user specifies otherwise |
| 20 | 3. For each technique, consider applicability to the current target/context |
| 21 | 4. Track which checklist items have been completed |
| 22 | 5. Suggest next steps based on findings |
| 23 | |
| 24 | --- |
| 25 | |
| 26 | ## Full Methodology |
| 27 | |
| 28 | # Insecure Deserialization |
| 29 | |
| 30 | Happens when applications deserialize program objects without proper precaution. An attacker can then manipulate serialized objects to change program behavior and even execute code. |
| 31 | |
| 32 | ## Shortcut |
| 33 | |
| 34 | 1. Search source for deserialization that touches user input. |
| 35 | 2. If black-box, look for large, opaque blobs (cookies, headers, bodies) and unusual content-types. |
| 36 | 3. Identify features that must deserialize user-supplied data (session, jobs/queues, file metadata, tokens). |
| 37 | 4. If identity is embedded, tamper to attempt auth bypass. |
| 38 | 5. Try to escalate to RCE/logic abuse carefully and non-destructively. |
| 39 | |
| 40 | ## Mechanisms |
| 41 | |
| 42 | - Occurs when user-controlled data is deserialized without strict allowlists and integrity checks. Exploits often occur during deserialization (magic methods, constructors), before app logic runs. |
| 43 | - Prefer data formats that don’t instantiate code (JSON), and disable polymorphic typing. |
| 44 | |
| 45 | ## Hunt |
| 46 | |
| 47 | 1. **Identify Potential Inputs:** |
| 48 | - HTTP parameters/headers/cookies, file uploads, message queues, caches, DB‑stored user content |
| 49 | 2. **Recognize Serialized Data:** |
| 50 | - **PHP:** `O:<len>:"Class":...` (often Base64), PHAR archives (`phar://`) |
| 51 | - **Java:** hex `ac ed 00 05` or Base64 `rO0`; XMLDecoder/XStream flows |
| 52 | - **.NET:** legacy `BinaryFormatter`/`SoapFormatter` (unsafe/deprecated); Base64 `AAEAAAD/////` |
| 53 | - **Python:** `pickle` opcodes; unsafe `yaml.load` without `SafeLoader` |
| 54 | - **Ruby:** `YAML.load` unsafe; use `safe_load` |
| 55 | 3. **Source Review (if available):** |
| 56 | - **Java:** `ObjectInputStream.readObject`; enable `ObjectInputFilter`, disable Jackson default typing; use allowlists |
| 57 | - **PHP:** `unserialize()`; file operations that dereference `phar://` |
| 58 | - **.NET:** avoid `BinaryFormatter`; use `System.Text.Json` |
| 59 | - **Python:** avoid `pickle` for untrusted data; `yaml.safe_load` |
| 60 | - **Node.js:** `node-serialize`, `serialize-javascript`, `funcster` with unsafe eval() |
| 61 | - **Golang:** `encoding/gob` with interface{} type confusion |
| 62 | - **Ruby:** `Marshal.load()`, `YAML.load()` without `safe_load` |
| 63 | - **Rust:** `serde` with YAML/bincode, `ron` (Rusty Object Notation) |
| 64 | 4. **Dynamic Analysis:** Intercept and mutate; watch for error stack traces, class names, and timing anomalies. |
| 65 | |
| 66 | ## Bypass Techniques |
| 67 | |
| 68 | 1. **Alternate Gadgets/Classes:** Switch payload chains if blocklists are present. |
| 69 | 2. **Type Confusion:** Change expected types to bypass weak validation. |
| 70 | 3. **Indirect Paths:** Sink data into storage that a different component later deserializes. |
| 71 | 4. **Format Specific:** PHAR wrappers, XML entity tricks, language‑specific unserialize quirks. |
| 72 | 5. **Post‑deserialization Impact:** Abuse magic methods that run before validation. |
| 73 | |
| 74 | ## Language-Specific Details |
| 75 | |
| 76 | ### Node.js |
| 77 | |
| 78 | - **node-serialize**: RCE via `_$$ND_FUNC$$_` IIFE pattern |
| 79 | ```javascript |
| 80 | {"rce":"_$$ND_FUNC$$_function(){require('child_process').exec('whoami', function(error, stdout){console.log(stdout)});}()"} |
| 81 | ``` |
| 82 | - **serialize-javascript**: Unsafe eval() when not properly escaped |
| 83 | - **funcster**: Arbitrary function serialization leads to code execution |
| 84 | - **Detection**: Look for `{"_$$ND_FUNC$$_` or serialized function strings in cookies/tokens |
| 85 | |
| 86 | ### Golang |
| 87 | |
| 88 | - **encoding/gob**: Type confusion attacks when using `interface{}` types |
| 89 | ```go |
| 90 | // Vulnerable: accepts any type |
| 91 | var data interface{} |
| 92 | dec := gob.NewDecoder(buffer) |
| 93 | dec.Decode(&data) |
| 94 | ``` |
| 95 | - **encoding/json**: Generally safe but Unmarshal into `interface{}` allows unexpected types |
| 96 | - **MessagePack**: Unsafe reflection in `github.com/vmihailenco/msgpack` with custom decoders |
| 97 | - **Mitigation**: Use concrete types, avoid `interface{}` for untrusted data |
| 98 | |
| 99 | ### Rust |
| 100 | |
| 101 | - **serde**: Generally memory-safe but logic bugs possible with custom `Deserialize` implementations |
| 102 | - **bincode**: Binary serialization - |