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); base64rO0AB, gzip+base64H4sI; the HTTP content typeapplication/x-java-serialized-object. An object typically continues withTC_OBJECT/TC_CLASSDESC, giving the common prefixrO0ABXNy. - Where the risk lives.
ObjectInputStreamreads 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.
ORBUseCodebaseOnlywas left unset, but on JDK 17/21 codebase fetching requires aSecurityManager, which WildFly refuses to run with, so the no-gadget path does not work. - Local gadgets still work. A
PriorityQueue+ BeanUtils comparator chain reachingTemplatesImplruns a static initializer during unmarshalling. The client sees a CORBA marshalling exception after the code ran, so the error is not evidence of failure. serialVersionUIDmust 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
ORBUseCodebaseOnlyon.
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:
| Change | Effect |
|---|---|
| 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.2 | Functor 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
URLDNSfor 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.xmlfor the dependency and JDK prerequisites of 46 known gadget chains (Ysoserial main andnewgadgetbranches, 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 reachingObjectInputStream.readObject().
Notable cases
| CVE / ID | Product | Note |
|---|---|---|
| CVE-2015-4852 | WebLogic | Commons Collections wave; also CVE-2017-3248, CVE-2018-2628 (T3) |
| CVE-2016-1000027 | Spring-web HttpInvokerServiceExporter | Unfixed until Spring 6.0.0 |
| CVE-2017-9805 | Apache Struts REST plugin | XStream over application/xml; Equifax-adjacent class |
| CVE-2025-20124 | Cisco ISE | CVSS 9.9; exploitable by any admin account, incl. read-only |
| CVE-2025-24813 | Apache Tomcat | Session-file write + deserialization |
| CVE-2026-33439 | OpenAM | Pre-auth, bypassing the WhitelistObjectInputStream added after CVE-2021-35464 |
| CVE-2026-118636 | Apache MINA | JavaNativeMessageDecoder, no fix for 3.0 (migrate to 2.2.x) |
| CVE-2026-114938 | OpenJDK “Java4Shell” | Base64-decoder memory corruption; adjacent RCE class, not a gadget chain |
| CVE-2026-33728 | dd-trace-java | RMI endpoint without serialization filter |
| — (fixed after 41.0.0.Final, backported to 41.0.1) | WildFly 32-35 IIOP | EjbCorbaServant 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.
Related
- Insecure Deserialization
- Gadget Chains
- Polymorphic Deserialization
- AI-Accelerated Gadget Discovery
- Remote Code Execution
- Log4Shell
Sources
- CVE-2026-33439: OpenAM Pre-Auth RCE via Deserialization · original
- CVE-2026-33728: dd-trace-java Unsafe Deserialization in RMI · original
- Deserialization Vulnerabilities in Java · original
- Exploiting Apache Struts: Writing Better Detections (Gigamon) · original
- Two roads to RCE in WildFly: pre-auth CORBA deserialization and JSON parser bypass · original
- Analyzing Prerequisites of Known Deserialization Vulnerabilities on Java Applications · original
- AWS advanced JDBC wrapper deserialization RCE · original
- CVE-2025-24813 PoC: Apache Tomcat Java Deserialization · original
- Gradle deserialization before authentication · original
- Java Deserialization Cheat Sheet · original
- SnakeYAML Deserialization Deep Dive (CVE-2022-1471) · original
- Java Deserialization Gadget Chains Explained · original
- Apache TomEE CVE-2026-111241 · original
- Exploiting deserialization in recent Java versions (OWASP Stuttgart) · original
- Cisco ISE Insecure Java Deserialization (CVE-2025-20124) · original
- CVE-2025-42928: SAP jConnect RCE via Deserialization · original
- CVE-2023-34040: Spring-Kafka Java Deserialization · original
- Insecure Reflection Practices in Java and C# · original
- Spring-web Java Deserialization: CVE-2016-1000027 · original
- Java Deserialization Tricks - Synacktiv · original
- The classes the blocklist forgot · original
- Apache MINA JavaNativeMessageDecoder unsafe deserialization RCE · original
- CVE-2026-114938 RCE in OpenJDK · original
- IBM webMethods Integration CVE-2025-36072 · original