Join our Newsletter — 33% off our NHI Course

Java Deserialization Vulnerability

A Java deserialization vulnerability happens when an application accepts serialized data from an untrusted source and rebuilds objects unsafely. In technical terms, crafted payloads can trigger unexpected code paths during object deserialization, leading to remote code execution, privilege abuse, denial of service, or data exposure, especially when dangerous classes are on the classpath.

What Java deserialization really does

java deserialization is the process of reconstructing objects from a byte stream. It is normal when trusted systems exchange state, but it becomes dangerous when an application accepts attacker-controlled data and tries to rebuild it without strict validation.

The core problem is that deserialization is not just data parsing. In Java, object graphs can trigger class loading, custom read logic, validation hooks, and other behavior while the object is being rebuilt. That means a malformed payload can influence execution before the application has a chance to treat the input as ordinary data.

Why unsafe deserialization becomes a security issue

Unsafe deserialization is dangerous because it can turn a data-handling feature into an execution path. If a vulnerable application accepts untrusted serialized input, an attacker may be able to reach code paths that were never intended to run for external data, especially when risky libraries or gadget chains are present on the classpath.

The practical impact ranges from remote code execution to privilege abuse, denial of service, and data exposure. The exact outcome depends on what classes are available, how the application handles object construction, and whether the payload can influence application logic during object restoration.

This is why deserialization bugs are often discussed alongside unsafe object trust, gadget exploitation, and classpath exposure. A system can be vulnerable even when the application never explicitly calls a shell or eval-like function, because the dangerous behavior happens inside the object lifecycle itself.

Where exposure usually comes from

Exposure typically starts when an application accepts serialized objects from a network request, message queue, file upload, cache entry, or another boundary that should not be trusted by default. The risk is higher when the application does not distinguish between internal state and attacker-supplied input.

Inventory matters because deserialization is often hidden inside frameworks, legacy services, middleware, and integration layers. Teams should identify where Java serialization is still in use, which endpoints accept it, and whether any component processes data from users, partners, or third-party systems.

When the vulnerable path is internet-facing, the attack window is usually much larger. For broader prioritisation and exploitation context, teams should cross-check vendor guidance and the Zero-Day and Exploited Vulnerabilities Guide, then verify whether any related issue appears in the CISA Known Exploited Vulnerabilities catalogue.

How defenders reduce the blast radius

Defence starts with removing unnecessary Java serialization handling, then restricting what the runtime will accept. Where serialization cannot be removed immediately, allowlisting and deserialization filters can reduce the chance that dangerous types or gadget chains are instantiated.

It is also important to harden the surrounding Java stack. The Java and Spring Security Guide is useful when deserialization risk sits inside a broader Spring application, because framework defaults, actuator exposure, and patch hygiene can all shape the exploit path.

Remediation should not stop at patching one library. Teams should review exposed endpoints, session tokens, integration clients, and any credentials or keys that may have been accessible if exploitation occurred. If the application may have been compromised, reassess logs, process activity, outbound connections, and unexpected object creation around the affected time window.

Risk and Threat Considerations

Unsafe deserialization matters because it can convert a routine input-handling feature into an attacker-controlled execution trigger. The danger is not limited to a single endpoint, since the same gadget-rich runtime can be reachable through multiple application paths and shared libraries.

Failure mechanism: An attacker supplies crafted serialized data that activates unexpected code during object reconstruction, then uses the resulting execution path to run commands, manipulate privileges, or destabilise the service.

Impact: Successful exploitation can lead to remote code execution, credential exposure, service disruption, lateral movement, and post-exploitation persistence if the application processes sensitive secrets or runs with broad privileges.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK and OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST SP 800-53 Rev 5, CIS Controls v8 and OWASP ASVS set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
NIST SP 800-53 Rev 5 SI-10 — Input Validation Deserialization is unsafe when untrusted input can trigger code paths.
CM-7 — Least Functionality Reducing available classes and features shrinks deserialization attack surface.
SC-18 — Mobile Code Serialized payloads can act like executable data that influences runtime behaviour.
Recommendation — Apply SI-10 to validate or reject untrusted serialized input before object reconstruction. Use CM-7 to remove unnecessary deserialization features and risky runtime capabilities. Restrict execution of untrusted code-like inputs with SC-18-style safeguards.
CIS Controls v8 CIS-2 — Inventory and Control of Software Assets Finding deserialization paths requires knowing where Java runtimes and libraries exist.
CIS-16 — Application Software Security Secure application design is central to preventing unsafe deserialization flaws.
Recommendation — Inventory Java applications and libraries so deserialization exposure can be identified and reduced. Build secure coding rules and review gates that eliminate unsafe deserialization patterns.
OWASP ASVS V2 — Validation and Business Logic Untrusted serialized input must be validated before it influences application logic.
V15 — Secure Coding and Architecture Secure architecture should avoid dangerous object reconstruction from attacker-controlled data.
Recommendation — Treat serialized input as untrusted data and validate it before processing. Design applications to avoid unsafe object deserialization and related gadget exposure.
MITRE ATT&CK T1027 — Obfuscated Files or Information Serialized payloads may conceal malicious content inside opaque data structures.
T1203 — Exploitation for Client Execution Malicious deserialization often aims to trigger code execution through application processing.
Recommendation — Hunt for suspicious opaque payloads and decoding activity that may precede exploitation. Map suspicious deserialization events to exploitation indicators and review follow-on execution.
OWASP Non-Human Identity Top 10 NHI-02 — Secret Leakage If exploitation occurs, serialized-object abuse can expose secrets handled by the application.
Recommendation — Review whether exploited code paths could have exposed credentials, tokens, or keys.

Practitioner Guidance

What to watch for: Treat any externally reachable Java deserialization path as a high-risk trust boundary, especially when the application accepts opaque binary input or depends on legacy frameworks that still reconstruct object graphs from untrusted sources.

Governance implication: Owners should be able to say where Java serialization exists, why it is still needed, and what compensating controls protect it. If they cannot answer that clearly, the path is usually a retirement or containment candidate rather than a tolerated exception.

Practitioner takeaway: The safest long-term fix is usually to replace Java serialization with a simpler, schema-driven format and keep deserialization away from untrusted input entirely.