AI pentesting guides / Vulnerability classes

Object injection

Insecure deserialization testing

Insecure deserialization testing checks whether an application turns attacker-controlled serialized data back into objects in a way that lets the attacker alter logic or execute code. It is CWE-502 (Deserialization of Untrusted Data) and sits under OWASP Top 10 2021 A08: Software and Data Integrity Failures.

The danger comes from gadget chains: classes already present in the application or its libraries whose methods run automatically during deserialization. Chained together, they can lead to remote code execution without the application ever calling attacker code directly.

Classification

  • CWE-502 Deserialization of Untrusted Data.
  • OWASP Top 10 2021: A08 Software and Data Integrity Failures.
  • Well-known instances include Java native serialization, .NET BinaryFormatter, Python pickle, PHP unserialize and unsafe YAML loaders.

How it is found

Look for serialized data crossing the trust boundary: cookies, hidden fields, headers, message queues and API parameters. Recognisable markers help, such as Java's rO0 base64 prefix (AC ED in hex), .NET ViewState without a MAC, PHP's O: object notation, or pickled data in Python apps. Version fingerprinting matters too, since libraries with known gadget chains narrow what is exploitable. White-box review is especially effective: search for deserialization calls fed by request data.

What counts as proof

Proof should be safe. The usual technique is a gadget chain that performs a harmless observable action, typically a DNS lookup to a unique hostname you control, rather than running a command. An out-of-band callback from the target proves the payload was deserialized and the gadget executed. For logic-level object injection, proof is a changed property, such as a role, taking effect. Never use destructive gadgets on systems you do not own.

Remediation

Do not deserialize untrusted data with native object serializers. Use data-only formats such as JSON with explicit schemas. If native deserialization is unavoidable, sign and verify the data before deserializing, and use allow-list class filters (for example Java's ObjectInputFilter). Use safe loaders (yaml.safe_load). Keep libraries patched, since gadget chains often live in dependencies.

With Pentest-Swarm

How Pentest-Swarm tests for insecure deserialization

Deserialization and object injection are among the classes Pentest-Swarm reports.

  • ysoserial is integrated for Java gadget-chain payload generation within scope-checked chains.
  • Out-of-band verification through interactsh can confirm that a gadget fired, without destructive commands.
  • The LLM-driven exploit agent can chain a deserialization finding with earlier recon, for example a fingerprinted framework version, toward a proven impact.
  • Findings carry evidence, severity, CVSS and a sandboxed proof of concept where one can be generated.

Where it falls short

Deserialization is not one of the classes with a documented dedicated oracle producer today, so review each finding's evidence rather than relying on a VERIFIED badge. Formats other than Java, and custom serializers, are harder to test black-box. Source review with SAST (semgrep is integrated) and dependency analysis are more reliable for finding every deserialization sink.

Questions

Is JSON deserialization safe?

Mostly, when mapped to plain data types. Some JSON libraries support polymorphic type handling that reintroduces the risk, so keep it disabled.

What is a gadget chain?

A sequence of existing classes whose methods, triggered during deserialization, together perform an action such as running a command.

Does a WAF stop deserialization attacks?

Not reliably. Payloads can be encoded in many ways. Remove the unsafe deserialization instead.

Sources

  1. CWE-502
  2. OWASP A08:2021
  3. OWASP Deserialization Cheat Sheet