Summary
dd-trace-java's RMI instrumentation in affected versions deserializes data from a custom RMI/JMX endpoint without applying serialization filters on JDK 16 and earlier.
With network access to the exposed JMX/RMI port and a suitable gadget chain on the classpath, an attacker could potentially achieve remote code execution on the instrumented JVM.
Affected context
This vulnerability affects JVMs running dd-trace-java as a Java agent (-javaagent) on JDK 16 or earlier where:
- A JMX/RMI port is explicitly enabled (e.g., via
-Dcom.sun.management.jmxremote.port) - That port is reachable from an attacker-controlled network segment
- Application or framework libraries on the classpath expose gadget chains exploitable via Java deserialization
The custom RMI endpoint registered by the dd-trace-java instrumentation becomes part of the remotely reachable attack surface in these conditions.
Exploit preconditions
- Attack surface: Exposed JMX/RMI management interface on the instrumented JVM.
- Required access: Network-level access to the configured JMX/RMI port; no application-level authentication is assumed for the vulnerable deserialization path.
- Execution environment:
- dd-trace-java attached as a Java agent on JDK <= 16
- JMX/RMI port configured via
-Dcom.sun.management.jmxremote.port - Gadget-chain-compatible classes present on the application classpath.
- Trigger point: Sending crafted serialized objects to the custom RMI endpoint introduced by the instrumentation.
- Why exploitation is possible: Incoming serialized data is deserialized without serialization filters or robust validation, allowing attacker-controlled object graphs to be instantiated and gadget chains to be executed.
Why this happens
The root cause is an unsafe deserialization pattern introduced by the RMI instrumentation in dd-trace-java.
The instrumentation registers a custom endpoint that deserializes data received over RMI/JMX using the standard Java serialization mechanism but does not apply serialization filters or a strict allowlist of types.
This aligns with CWE-502: Deserialization of Untrusted Data, where attacker-controlled serialized streams are processed as trusted objects, enabling the construction of malicious object graphs that trigger code execution through existing libraries (gadget chains).
Potential impact
- Remote execution of arbitrary Java or operating system commands within the JVM process.
- Full compromise of the instrumented application, including access to in-memory data and credentials.
- Lateral movement to other systems reachable from the compromised JVM.
- Manipulation or disablement of application monitoring and telemetry data.
- Use of the compromised JVM as a pivot for broader network intrusion.
General mitigation guidance
Effective mitigation centers on reducing trust in serialized inputs and minimizing exposed management surfaces:
- Prefer runtimes and configurations that enforce serialization filtering (e.g., JDKs with built-in
ObjectInputFiltersupport) and apply strict allowlists for classes that may be deserialized. - Limit or disable RMI/JMX endpoints in production whenever practical, especially when they are reachable from untrusted networks.
- Segment network access so that management ports (JMX/RMI) are only reachable from tightly controlled administration networks.
- Minimize gadget availability by avoiding unnecessary libraries on the classpath and removing legacy or unused components prone to deserialization gadgets.
- Run instrumented JVMs with least privilege (OS user permissions, restricted filesystem and network access) so that, if deserialization is abused, the impact is constrained.
- Consider alternative monitoring and management mechanisms that do not rely on Java native serialization over remote endpoints.
How teams detect issues like this
Detection can combine code, configuration, and runtime monitoring approaches:
- Static analysis:
- Search for use of Java native deserialization APIs (
ObjectInputStream, RMI/JMX invocation handlers) that process network data withoutObjectInputFilteror equivalent checks. - Flag custom RMI or JMX endpoints that accept arbitrary serialized payloads.
- Configuration review:
- Inventory JVMs with dd-trace-java attached and verify JMX/RMI port settings and exposure.
- Check for lack of access controls or filtering on management endpoints.
- Runtime and network monitoring:
- Monitor network traffic to JMX/RMI ports for unusual or large serialized payloads.
- Use intrusion detection systems capable of recognizing Java deserialization exploit patterns.
- Policy enforcement:
- Enforce CI/CD policies that require serialization filtering for any use of Java serialization on network-exposed paths.
- Integrate automated code review tools that highlight unsafe deserialization patterns and insecure RMI/JMX exposure.

