> offensive-deserialization
offensive-deserialization skill from SnailSploit/Claude-Red
curl "https://skillshub.wtf/SnailSploit/Claude-Red/offensive-deserialization?format=md"SKILL: Insecure Deserialization
Metadata
- Skill Name: insecure-deserialization
- Folder: offensive-deserialization
- Source: https://github.com/SnailSploit/offensive-checklist/blob/main/insecure-deserialization.md
Description
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.
Trigger Phrases
Use this skill when the conversation involves any of:
deserialization, insecure deserialization, ysoserial, Java deserialization, PHP deserialization, .NET deserialization, pickle, gadget chain, magic method, ObjectInputStream
Instructions for Claude
When this skill is active:
- Load and apply the full methodology below as your operational checklist
- Follow steps in order unless the user specifies otherwise
- For each technique, consider applicability to the current target/context
- Track which checklist items have been completed
- Suggest next steps based on findings
Full Methodology
Insecure Deserialization
Happens when applications deserialize program objects without proper precaution. An attacker can then manipulate serialized objects to change program behavior and even execute code.
Shortcut
- Search source for deserialization that touches user input.
- If black-box, look for large, opaque blobs (cookies, headers, bodies) and unusual content-types.
- Identify features that must deserialize user-supplied data (session, jobs/queues, file metadata, tokens).
- If identity is embedded, tamper to attempt auth bypass.
- Try to escalate to RCE/logic abuse carefully and non-destructively.
Mechanisms
- 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.
- Prefer data formats that don’t instantiate code (JSON), and disable polymorphic typing.
Hunt
- Identify Potential Inputs:
- HTTP parameters/headers/cookies, file uploads, message queues, caches, DB‑stored user content
- Recognize Serialized Data:
- PHP:
O:<len>:"Class":...(often Base64), PHAR archives (phar://) - Java: hex
ac ed 00 05or Base64rO0; XMLDecoder/XStream flows - .NET: legacy
BinaryFormatter/SoapFormatter(unsafe/deprecated); Base64AAEAAAD///// - Python:
pickleopcodes; unsafeyaml.loadwithoutSafeLoader - Ruby:
YAML.loadunsafe; usesafe_load
- PHP:
- Source Review (if available):
- Java:
ObjectInputStream.readObject; enableObjectInputFilter, disable Jackson default typing; use allowlists - PHP:
unserialize(); file operations that dereferencephar:// - .NET: avoid
BinaryFormatter; useSystem.Text.Json - Python: avoid
picklefor untrusted data;yaml.safe_load - Node.js:
node-serialize,serialize-javascript,funcsterwith unsafe eval() - Golang:
encoding/gobwith interface{} type confusion - Ruby:
Marshal.load(),YAML.load()withoutsafe_load - Rust:
serdewith YAML/bincode,ron(Rusty Object Notation)
- Java:
- Dynamic Analysis: Intercept and mutate; watch for error stack traces, class names, and timing anomalies.
Bypass Techniques
- Alternate Gadgets/Classes: Switch payload chains if blocklists are present.
- Type Confusion: Change expected types to bypass weak validation.
- Indirect Paths: Sink data into storage that a different component later deserializes.
- Format Specific: PHAR wrappers, XML entity tricks, language‑specific unserialize quirks.
- Post‑deserialization Impact: Abuse magic methods that run before validation.
Language-Specific Details
Node.js
- node-serialize: RCE via
_$$ND_FUNC$$_IIFE pattern{"rce":"_$$ND_FUNC$$_function(){require('child_process').exec('whoami', function(error, stdout){console.log(stdout)});}()"} - serialize-javascript: Unsafe eval() when not properly escaped
- funcster: Arbitrary function serialization leads to code execution
- Detection: Look for
{"_$$ND_FUNC$$_or serialized function strings in cookies/tokens
Golang
- encoding/gob: Type confusion attacks when using
interface{}types// Vulnerable: accepts any type var data interface{} dec := gob.NewDecoder(buffer) dec.Decode(&data) - encoding/json: Generally safe but Unmarshal into
interface{}allows unexpected types - MessagePack: Unsafe reflection in
github.com/vmihailenco/msgpackwith custom decoders - Mitigation: Use concrete types, avoid
interface{}for untrusted data
Rust
- serde: Generally memory-safe but logic bugs possible with custom
Deserializeimplementations - bincode: Binary serialization - ensure versioning and size limits
- ron (Rusty Object Notation): Can deserialize into arbitrary types if schema not restricted
- YAML:
serde_yamlwith untrusted input can cause DoS via deeply nested structures - Best Practice: Use
#[serde(deny_unknown_fields)]and explicit type constraints
Additional Languages
- Ruby:
Marshal.load(): Gadget chains exist (e.g.,Gem::Requirement,Gem::RequestSet)- Tools:
Ruby Marshal RCE(exploit scripts)
- Python:
pickle: Extensive gadget chains,__reduce__magic method exploitationyaml.load(): Useyaml.safe_load()oryaml.load(data, Loader=yaml.SafeLoader)
- Java:
- Apache Commons Collections (InvokerTransformer chain)
- Spring Framework (PropertyPathFactoryBean)
- Tool:
ysoserial- generates payloads for 30+ gadget chains
Modern Attack Vectors
Container & Kubernetes
- ConfigMaps/Secrets: Applications deserializing YAML/JSON from ConfigMaps without validation
- Admission Webhooks: Kubernetes admission controllers deserializing
AdmissionReviewobjects- Test by submitting pods with malicious annotations or labels containing serialized payloads
- CRD Controllers: Custom Resource Definitions with unsafe deserialization in reconciliation loops
- Attack: Submit malicious Custom Resource → controller deserializes → RCE in cluster
Message Queues
- Kafka/RabbitMQ/Redis: Consumers blindly deserializing messages from queues
# Vulnerable consumer msg = consumer.receive() data = pickle.loads(msg) # Attacker controls msg - Testing: Publish crafted serialized objects to queues if you have producer access
- Impact: Compromise all consumers processing the poisoned queue
Serverless Functions
- AWS Lambda: Event payloads deserialized from S3 triggers, SNS, SQS
- Google Cloud Functions: HTTP request bodies automatically deserialized
- Azure Functions: Blob triggers with automatic deserialization
- Attack Vector: Upload malicious serialized object to S3 → Lambda deserializes → RCE in serverless context
CI/CD Pipelines
- Jenkins: Java deserialization in remoting protocol (multiple CVEs)
- GitLab Runners: YAML deserialization in
.gitlab-ci.ymlwith unsafe anchors/aliases - GitHub Actions: Workflow files with embedded serialized data in custom actions
- Build Artifacts: Deserializing cached build objects from untrusted sources
GraphQL / API Gateways
- Custom Scalars: GraphQL custom scalar types deserializing complex objects
- Input Coercion: API gateways converting JSON to language objects without validation
- Batch Operations: Bulk import/export features deserializing uploaded files
Vulnerabilities / Impacts
- RCE via gadget chains: Execute arbitrary code through chained object instantiation
- Arbitrary file access: Read/write files via path traversal in deserialization
- DoS via resource bombs: Billion laughs-style attacks with nested objects (zip bombs, XML bombs)
- Auth bypass via object field tampering: Modify
is_admin,role,user_idfields in session objects - Downstream SQLi with tainted fields: Deserialized objects used in SQL queries without sanitization
- Memory exhaustion: Allocate large data structures during deserialization
- Type juggling attacks: Language-specific type coercion vulnerabilities
Methodologies
- Identify → Format → Mutate/Fuzz → Exploit chain → Verify impact safely
- Tools:
ysoserial,phpggc,ysoserial.net, Burp Deserialization Scanner, Semgrep rules for dangerous sinks,marshalsec, gadget inspectors.
Remediation Recommendations
- Avoid deserializing untrusted input; use JSON with schemas.
- Verify integrity first (HMAC/signature) and only then deserialize; reject on mismatch.
- Use safe, specific serializers without polymorphic typing; implement allowlists.
- Isolate deserialization code under least privilege and sandboxing; timeouts/memory limits.
- Keep libraries updated; monitor for anomalies.
> related_skills --same-repo
> offensive-xxe
offensive-xxe skill from SnailSploit/Claude-Red
> offensive-xss
offensive-xss skill from SnailSploit/Claude-Red
> offensive-windows-mitigations
offensive-windows-mitigations skill from SnailSploit/Claude-Red
> offensive-windows-boundaries
offensive-windows-boundaries skill from SnailSploit/Claude-Red