Java Deserialization

Insecure use of ObjectInputStream.readObject() (and JVM marshallers such as XStream, XMLEncoder, Hessian, Kryo, SnakeYAML, AMF stacks) on attacker-controlled bytes, where the class names in the stream decide which library callbacks run as the object graph is rebuilt.

How it works

  • Stream format. Java native serialization begins with the magic AC ED 00 05 (STREAM_MAGIC + STREAM_VERSION); base64 rO0AB, gzip+base64 H4sI; the HTTP content type application/x-java-serialized-object. An object typically continues with TC_OBJECT/TC_CLASSDESC, giving the common prefix rO0ABXNy.
  • Where the risk lives. ObjectInputStream reads the class name from the stream, loads that class from the classpath, and reconstructs it — invoking deserialization callbacks (readObject, readResolve) along the way. Collection types re-hash their keys while rebuilding, which is the implicit entry point for most gadget chains.
  • Impact depends on the classpath, not the sink. The identical vulnerable line is a full compromise on one deployment and inert on another, because exploitability is a function of which library versions are present. A clean scan means only that no chain the scanner carried matched this classpath — weak evidence. See Gadget Chains.
  • Gadget roles (Gigamon’s taxonomy around CVE-2017-9805): trigger, bypass (nested deserialization on an unfiltered stream), helper, and sink. The historically central JRE-internal sink is TemplatesImpl, which carries bytecode; outbound JNDI reference indirection is the other classic path.

CORBA/IIOP: the forgotten listener

WildFly’s full profiles open an IIOP listener (TCP 3528) that most web-focused testing never touches. In 32-35, the servant unmarshals EJB call parameters before the authentication check runs; the naming service also answers unauthenticated (WildFly two roads).

  • Remote class loading is dead on modern JDKs. ORBUseCodebaseOnly was left unset, but on JDK 17/21 codebase fetching requires a SecurityManager, which WildFly refuses to run with, so the no-gadget path does not work.
  • Local gadgets still work. A PriorityQueue + BeanUtils comparator chain reaching TemplatesImpl runs a static initializer during unmarshalling. The client sees a CORBA marshalling exception after the code ran, so the error is not evidence of failure.
  • serialVersionUID must match. CORBA rejects a gadget built against a different library version (BeanUtils 1.9.4 in 32-35).
  • Preconditions: IIOP enabled and reachable, an EJB exported over IIOP with a suitable parameter type, a usable gadget library, and reflective access to the XML internals for TemplatesImpl.
  • Fix: authenticate before deserializing parameters and force ORBUseCodebaseOnly on.

Formats beyond ObjectInputStream

The JVM deserialization cheat sheet catalogues the same weakness across Java native, XMLEncoder, XStream, Kryo, Hessian/Burlap, Castor, json-io, Jackson, Fastjson, Genson, Jodd, the AMF stacks (Red5, Apache Flex BlazeDS, GraniteDS, WebORB) and YAML (SnakeYAML, jYAML, YamlBeans). XStream can rebuild non-Serializable classes, widening the exposure (Struts REST plugin, CVE-2017-9805). JSON/YAML type-binding variants are covered in Polymorphic Deserialization.

Modern JDK reality (17+)

Münch (OWASP Stuttgart 2024) and the Black Hat “Friday the 13th” research describe how the landscape shifted:

ChangeEffect
JPMS strong encapsulation (default JDK 16, enforced from LTS 17)The JRE-internal sink becomes unreachable through reflection; many published chains stop working out of the box
Remote JNDI object-factory loading disabled (8u191 / 11.0.1)The classic remote-codebase path is closed; attention moves to local object-factory abuse (Tomcat BeanFactory, hardened in 9.0.63 / 8.5.79 / 10.0.21)
Commons Collections 3.2.2Functor serialization disabled unless an unsafe system property is set

Verification still works via URLDNS (a JRE-only DNS lookup, no gadget library required). Exploitation remains possible but resembles memory-corruption work: the standalone Xalan-J library sidesteps the module restriction, and JDBC-connection sinks (H2) were used against SolarWinds SEM (CVE-2024-0692). The Waratek and GadgetHunter/FLASH research notes that AI-assisted tooling now discovers novel chains cheaply, which undermines blocklist and denylist defences — see AI-Accelerated Gadget Discovery.

Detection

  • Passively decode cookies, hidden fields, RMI/JMX/T3/IIOP ports, message queues and caches, looking for the magic prefix.
  • Prefer URLDNS for a first confirmation; a response-identical handler can run code and still return a generic error, so an out-of-band signal is the reliable proof — see Out-of-Band Detection.
  • Engineer detections around the vulnerability (serialized or XML body reaching a deserializer, known gadget class families) rather than exploit artefacts; Gigamon showed that path- and keyword-based Struts rules were trivially evaded. Static tooling: GadgetInspector, Tabby, FLASH (USENIX 2025), Serianalyzer.
  • Gadgecy (Kreyssig & Bartel, EASE 2024) checks a project’s JARs and pom.xml for the dependency and JDK prerequisites of 46 known gadget chains (Ysoserial main and newgadget branches, open PRs, CVE-2022-36944). Only 4 chains (JRMPClient, JRMPListener, URLDNS, Jdk7u21) need nothing beyond the JDK. Prerequisites appeared in 10.76% of 2,211 Apache projects and 9.12% of 400 popular GitHub projects. It checks prerequisites only: exploitation still needs untrusted input reaching ObjectInputStream.readObject().

Notable cases

CVE / IDProductNote
CVE-2015-4852WebLogicCommons Collections wave; also CVE-2017-3248, CVE-2018-2628 (T3)
CVE-2016-1000027Spring-web HttpInvokerServiceExporterUnfixed until Spring 6.0.0
CVE-2017-9805Apache Struts REST pluginXStream over application/xml; Equifax-adjacent class
CVE-2025-20124Cisco ISECVSS 9.9; exploitable by any admin account, incl. read-only
CVE-2025-24813Apache TomcatSession-file write + deserialization
CVE-2026-33439OpenAMPre-auth, bypassing the WhitelistObjectInputStream added after CVE-2021-35464
CVE-2026-118636Apache MINAJavaNativeMessageDecoder, no fix for 3.0 (migrate to 2.2.x)
CVE-2026-114938OpenJDK “Java4Shell”Base64-decoder memory corruption; adjacent RCE class, not a gadget chain
CVE-2026-33728dd-trace-javaRMI endpoint without serialization filter
— (fixed after 41.0.0.Final, backported to 41.0.1)WildFly 32-35 IIOPEjbCorbaServant reads EJB method parameters before authenticating; pre-auth on TCP 3528 in full profiles (chern0b.it)

Also: SAP jConnect (CVE-2025-42928), IBM webMethods (CVE-2025-36072), Gradle pre-auth daemon, Apache TomEE passivation files (CVE-2026-111241), AWS Advanced JDBC Wrapper cache poisoning (CVE-2026-14265), and the Oracle Coherence + Xalan blocklist-bypass chain (UltraRed).

  • CVEs cover only 14 of the 46 known gadget chains (58.70% have no CVE at all), so CVE-driven SCA misses most gadget-bearing dependency versions (EASE 2024).

Prevention

  • Do not deserialize untrusted data with native formats; prefer a data-only format with an explicit schema.
  • Inventory platform listeners the profile enables (IIOP, RMI, JMX, T3) and disable or firewall the ones the app doesn’t use; authenticate before any parameter unmarshalling.
  • Where unavoidable, apply an allowlist serialization filter — ObjectInputFilter / JEP 290 (jdk.serialFilter), with !* as the default-deny. Allowlisting still runs allowed classes’ callbacks, so audit those too.
  • Keep gadget-bearing libraries patched, segment RMI/JMX ports, and treat a leaked signing key for a signed blob as a deserialization finding.

Sources