deserialization-security
Skill22 starsChanged 5 months agoMITView on GitHub
Block unsafe deserialization and unsafe XML parsing in Java, Python, .NET, PHP, and Ruby: gadget chains, unrestricted type resolution, external entity expansion, and safer formats. Use when parsing or deserializing data from an untrusted source, wiring cookies, sessions, queues, or RPC payloads, or reviewing pickle, unserialize, Marshal, ObjectInputStream, BinaryFormatter, or XML parser configuration.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- awarexone/AXguardtheir own version, first seen Sep 15, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- awarexone/AXguard★ 18same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository36 other files it gives its agents.
- AGENTS.mdAGENTS.md
- dist/AGENTS.mdAGENTS.md
- dist/CLAUDE.mdCLAUDE.md
- dist/copilot-instructions.mdCopilot instructions
- docs/llms-full.txtllms.txt
- docs/llms.txtllms.txt
- api-securitySkill
- auth-securitySkill
- cicd-securitySkill
- container-securitySkill
- cors-securitySkill
- crypto-misuseSkill
- database-securitySkill
- dynamic-verificationSkill
- electron-securitySkill
- error-handling-securitySkill
- file-upload-securitySkill
- frontend-securitySkill
- graphql-securitySkill
- iac-securitySkill
- iam-best-practicesSkill
- llm-app-securitySkill
- logging-securitySkill
- ml-securitySkill
- mobile-securitySkill
- protocol-securitySkill
- saas-securitySkill
- secret-detectionSkill
- secure-code-reviewSkill
- security-regression-testsSkill
- serverless-securitySkill
- ssrf-preventionSkill
- supply-chain-securitySkill
- template-injectionSkill
- threat-modelingSkill
- websocket-securitySkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 33
Prefer data-only serialization formats — JSON, Protobuf, MessagePack with an explicit type map — over formats that reconstruct arbitrary …
- Very specific: line 40
Treat an object-reconstructing deserializer crossing a trust boundary as high risk: pickle, ObjectInputStream, BinaryFormatter, …
- Distinctive: line 65
Treat a type or object-graph filter as a process sandbox.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Deserialization Security
Rules (for AI agents)
ALWAYS
- Prefer data-only serialization formats — JSON, Protobuf, MessagePack with an explicit type map — over formats that reconstruct arbitrary runtime objects. What makes a format safe here is not schema validation; it is whether the parser can instantiate a class the payload names.
- Constrain polymorphic type resolution to an explicit set of expected application types. Never let payload data choose the runtime class — that is the mechanism behind every gadget chain, whichever serializer is involved.
- Treat an object-reconstructing deserializer crossing a trust boundary as high risk:
pickle,ObjectInputStream,BinaryFormatter,unserialize,Marshal.loadand their framework equivalents. Adding one to a request-handling path needs explicit review — check the platform reference for the exact API and the version behaviour before accepting or remediating a use. - Disable external entity resolution and DTD processing on every XML parser that
receives untrusted input. A parser that resolves entities is a file-read and
server-side request primitive before it is a parser;
ssrf-preventionowns where the outbound request lands. - Where serialized state carries a signature or MAC, verify it before invoking the
deserializer — and treat that as defense in depth, not a licence to keep an unsafe
format.
crypto-misuseowns the signing key, its algorithm and its rotation. - Apply parser and object-graph limits — type filters, graph depth, array length, stream size — as defense in depth. Where legacy native deserialization is unavoidable and execution isolation is genuinely required, isolate at the OS, process or container boundary: a deserializer filter constrains what may be constructed, never what the constructed code may then do.
NEVER
- Deserialize attacker-controlled or unauthenticated bytes with a native, object-reconstructing format.
- Assume a MAC, a signature, TLS, or a trusted network makes an unsafe serializer safe. Some serializers cannot be made safe at any level of authentication, and their own vendors say so.
- Allow unrestricted class-name or type resolution from serialized input.
- Treat a type or object-graph filter as a process sandbox.
- Re-enable a serializer the platform vendor classifies as unsafe for compatibility alone. That needs a recorded legacy risk acceptance, strict filtering, a least-privilege execution boundary, and a migration plan — not a false-positive waiver.
- Copy a framework-specific deserialization example without checking it against the installed library version. Defaults in this area have moved repeatedly, and an example that was correct three releases ago may name an API that no longer exists.
KNOWN FALSE POSITIVES
- Build-time or configuration-time deserialization of files that ship in the repository — test fixtures, vendored config — provided they are never loaded from a download.
- A parser that is hardened by its library's current defaults is not a finding merely because an older release of the same library was unsafe. Check the installed version, not the library name.
- A cryptographically authenticated session format where the MAC genuinely gates the deserializer and the framework's own current default serializer is in use.
Context (for humans)
Object-reconstructing deserialization is the most reliable RCE primitive in modern
enterprise stacks. The economics are simple: when a serializer instantiates whatever
class the payload names, the application has already loaded thousands of classes, many
with side effects in readObject, __reduce__, __wakeup or Read* callbacks. A
gadget chain strings those side effects into execution. Mature tooling — ysoserial,
ysoserial.net, marshalsec, the pickle gadget catalogs — means "is this exploitable" is
almost always "yes, with what is already on the classpath."
The fix is a format that cannot instantiate arbitrary classes, not a better filter. XML belongs in the same skill for the same reason: an entity-resolving parser does more than parse, and the exploit needs no gadget at all.
Two things date fast here and are deliberately kept out of these rules: exact API names and version-dependent defaults. Both have moved repeatedly — safe-by-default constructors, flipped loader defaults, vendor-obsoleted serializers — and a rule that hard-codes them ages into a false positive or, worse, into an API that never existed. The platform references carry them, with the version each statement applies to.
References
references/verifying-findings.md— confirm or refute a finding, then lock itreferences/java.md— ObjectInputStream, Jackson polymorphic typing, SnakeYAML, XStream: current APIs, version gates, safe configurationreferences/python.md— pickle family, PyYAML loaders, numpy, ML checkpointsreferences/dotnet.md— BinaryFormatter and its relatives, vendor statusreferences/php-ruby.md—unserializemagic-method chains, Marshal, Psychreferences/xml.md— per-platform flags to disable DTD and external entitiesrules/unsafe_deserializers.json— build-time catalogue, not shipped to the agent- OWASP Deserialization Cheat Sheet.
- OWASP XXE Prevention Cheat Sheet.
- CWE-502 · CWE-611.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

