offensive-deserialization
4. Isolate deserialization code under least privilege and sandboxing; timeouts/memory limits.
- License 许可
- MIT
- 最近更新
- 2026-09-01
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- offensive-deserialization
- domain
- cybersecurity
- description
- 4. Isolate deserialization code under least privilege and sandboxing; timeouts/memory limits.
02 资源文件 1
- 参考文档index.json568 B
03 SKILL.md 正文
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.
04 同仓库更多 Skills
devel-jb-algorithmic-art
- Embed algorithms inline in the HTML artifact (don't create separate .
services-wmi-persistence-detect
Detect WMI event subscription persistence by enumerating ActiveScriptEventConsumer, CommandLineEventConsumer, and permanent subscriptions in the WMI repository.
services-wmi-exec-exploit
Perform lateral movement across Windows networks using WMI-based remote execution techniques including Impacket wmiexec.py, CrackMapExec, and native WMI commands for stealthy post-exploitation during red team engagements.
registry-artifact-extract
Extract and analyze Windows Registry hives to uncover user activity, installed software, autostart entries, and evidence of system compromise.
processes-token-impersonate-detect
Detect Windows token impersonation and privilege abuse including SeImpersonatePrivilege exploitation via Potato attacks and token stealing techniques.
processes-thread-injection-detect
Detect Windows thread injection techniques including CreateRemoteThread, QueueUserAPC, NtCreateThreadEx, and thread hijacking via process memory analysis.