Eclipse Ditto JavaScript payload mapper sandbox escape allows arbitrary code execution in the connectivity service
Description
Connections of the Ditto connectivity service can use the JavaScript payload mapper, which runs the user-supplied incomingScript / outgoingScript of a connection in a Mozilla Rhino JavaScript engine. The documentation describes this engine as sandboxed and states that mapping scripts have no access to Java packages or classes.
This restriction does not hold. The Rhino engine is configured without a ClassShutter, which is the mechanism Rhino relies on to keep Java classes out of reach of scripts. When a script catches an error raised by the engine itself (for example a property access on null), Rhino attaches the underlying Java exception object to the caught JavaScript error. Without a ClassShutter, the script can call methods on that Java object and use Java reflection to load and invoke arbitrary Java classes and methods in the connectivity service.
A user who may create or modify connections can therefore execute arbitrary code in the connectivity service process. In the default configuration this requires credentials of the Ditto DevOps realm. Code executed this way has access to everything the connectivity service has access to, e.g. its environment and configuration (including MongoDB credentials and the credentials of all connections), the Pekko cluster of the other Ditto services and the network of the deployment.
Severity: Critical (CWE-693, CWE-94).
Details
JavaScriptMessageMapperRhino.doConfigure creates a SandboxingContextFactory and initializes the script scope with initSafeStandardObjects() (default, allowUnsafeStandardObjects = false) or initStandardObjects() (allowUnsafeStandardObjects = true). SandboxingContextFactory.makeContext only configures interpreter mode, an instruction observer limiting the execution time and the maximum stack depth. It installs no ClassShutter and no restrictive WrapFactory.
initSafeStandardObjects() omits the LiveConnect entry points (Packages, java, getClass, JavaAdapter, ...), so at first glance no Java object is reachable from a script. However, when a script catches an EcmaError, EvaluatorException or wrapped Java exception, Rhino's ScriptRuntime.newCatchScope defines the properties rhinoException (and javaException for wrapped Java exceptions) on the caught error object, containing the wrapped Java exception. Rhino only omits these properties if a configured ClassShutter hides the exception class from scripts:
private static boolean isVisible(Context cx, Object obj) {
ClassShutter shutter = cx.getClassShutter();
return shutter == null || shutter.visibleToScripts(obj.getClass().getName());
}As no ClassShutter is configured, the script receives a live Java object. Via getClass() it obtains a java.lang.Class instance and from there, using the public reflection API of java.base, any class and method of the JVM. Neither the execution time limit, the stack depth limit nor the script size limit prevent this, and Java 25 has no SecurityManager which could restrict reflection.
The mapping script is evaluated with Context.evaluateString when the payload mapper is configured, i.e. top-level code of the script runs when the connection is opened, and code inside the mapping functions runs for each mapped message.
The JavaScript mapper is enabled by default (connectivity.conf). Connections are managed via /api/2/connections and DevOps piggyback commands, which require authentication in the DevOps realm (ConnectionsRoute.java#L110).
The sandbox restriction is documented in the payload mapping documentation ("No access to Java packages or classes"). The vulnerability affects all Ditto versions since the JavaScript payload mapper was introduced in 0.3.0-M1, independent of the bundled Rhino version.
Impact
A user with permission to create or modify connections can execute arbitrary code in the Ditto connectivity service:
- read the configuration and environment of the connectivity service, including database credentials and the credentials of all connections,
- send arbitrary messages within the Pekko cluster to the other Ditto services, bypassing authorization,
- access the network of the deployment, the file system of the container and, in Kubernetes, the service account of the connectivity pod,
- disrupt or take over the connectivity service.
In a default deployment, connection management requires DevOps credentials. The vulnerability turns these into code execution in the connectivity service and access to resources outside of Ditto's permission model. Deployments which delegate the management of connections or of mapping scripts to less trusted users (e.g. per-tenant connection management on top of Ditto) are affected the most.
Patches
The fix installs a deny-by-default ClassShutter for all JavaScript mapping executions, independent of the allowUnsafeStandardObjects setting, so that no Java object becomes visible to mapping scripts.
Patched versions: 3.9.10 and 3.8.16.
Workarounds
- Disable the
JavaScriptpayload mapper by removingorg.eclipse.ditto.connectivity.service.mapping.javascript.JavaScriptMessageMapperRhinofromditto.connectivity.mapping.message-mapper-provider.extension-config.message-mappersin the connectivity configuration. Connections using JavaScript payload mapping can then no longer be opened. - Restrict access to the DevOps realm (
/api/2/connections,/devops) to fully trusted administrators, and review theincomingScript/outgoingScriptof existing connections.
Credits
Ditto thanks Jiwoo Kim (@arpe1618) for reporting this vulnerability.
References
- CVE-2026-135203
- Rhino
ClassShutter