Skip to main content
Menu
Advisories

Ditto authentication bypass

GHSA-F779-CV8J-4P59Published Updated GitHub

Description

The nginx reverse proxy configurations shipped with Eclipse Ditto (Helm chart, deployment/docker docker-compose setup, Kubernetes and OpenShift deployment files) contain locations that proxy to the Ditto gateway without nginx authentication and without overwriting or clearing the x-ditto-pre-authenticated header, most notably location /api/2/connections. nginx selects the location on the normalized request URI, but forwards the raw request URI to the gateway. The gateway does not treat an encoded slash (%2f) as a path separator, but resolves a following dot segment (/..).

A crafted path is therefore routed by nginx through such an unauthenticated location and by the gateway to the regular Things / Policies HTTP API, where the attacker-supplied x-ditto-pre-authenticated header is trusted. An unauthenticated remote attacker can impersonate arbitrary policy subjects whenever pre-authentication is enabled, which is the default of the official Helm chart (global.jwtOnly: false) and of the docker-compose setup.

In addition, when the optional Ingress of the Helm chart is enabled (ingress.enabled: true, since Ditto 3.9.0 / chart 4.0.0) together with pre-authentication, the Ingress routes /api and /ws directly to the gateway and forwards a client-supplied x-ditto-pre-authenticated header, so no path manipulation is needed at all.

This also affects Ditto 3.9.9 / 3.8.15, the versions that fixed CVE-2026-120753 (GHSA-chwq-wg27-qvfr), which has the same impact class. That advisory stated the docker-compose setup is not impacted; it is impacted by this variant.

Severity: Critical (CVSS 4.0 9.1).

Details

1. nginx locations forward a client-supplied pre-authentication header

/api/2/connections is intentionally left without nginx authentication, because the gateway protects the connections API with devops credentials (RootRoute.java#L274-L298). It forwards all request headers unchanged, including x-ditto-pre-authenticated:

In the docker-compose, Kubernetes and OpenShift configurations, the unauthenticated /devops, /health and (where present) /stats locations have the same properties (no auth, header not cleared, proxy_pass without a URI part) and can be used in the same way:

In the Helm chart, /health, /status, /stats and /devops use proxy_pass with a URI part, so nginx forwards the normalized URI and these locations are not exploitable. Only /api/2/connections is.

Pre-authentication is enabled by default in the Helm chart (gateway-deployment.yaml#L236-L237: ENABLE_PRE_AUTHENTICATION = enablePreAuthentication OR (NOT jwtOnly), with global.jwtOnly: false) and in the docker-compose (docker-compose.yml#L192), Kubernetes (ditto-cluster.yaml#L469-L470) and OpenShift (ditto-cluster.yaml#L343-L344) deployment files.

The gateway trusts the header value by design, relying on the proxy to set it from a verified identity (PreAuthenticatedAuthenticationProvider.java#L84-L127). The value is split on ,, so a single request can claim several subjects.

2. nginx and the gateway interpret the request path differently

For the raw request path

/api/2/things/victim:thing1/x%2f..%2f..%2f..%2fconnections%2fy/..
  • nginx decodes %2f and resolves dot segments when matching locations: /api/2/things/victim:thing1/x/../../../connections/y/.. → /api/2/connections, which selects the unauthenticated location /api/2/connections. Because proxy_pass has no URI part, nginx forwards the original raw URI.
  • The gateway (Apache Pekko HTTP) keeps x%2f..%2f..%2f..%2fconnections%2fy as a single path segment. When building the effective request URI, the following /.. removes exactly that segment, so the request is routed to /api/2/things/victim:thing1/: the regular "retrieve Thing" route, authenticated via the attacker's x-ditto-pre-authenticated header.

With one more .., the same construction reaches the /devops, /health or /stats locations of the docker-compose / Kubernetes / OpenShift configurations, e.g. /api/2/things/victim:thing1/x%2f..%2f..%2f..%2f..%2f..%2fdevops%2fy/...

The trailing /.. is not even needed for routes whose last path part is decoded by the gateway (attribute and feature property JSON pointers, message subjects). For example, nginx resolves /api/2/things/victim:thing1/inbox/messages/x%2f..%2f..%2f..%2f..%2f..%2fconnections to /api/2/connections, while the gateway sends a live message to the device victim:thing1 in the name of the impersonated subject. Likewise, /api/2/things/victim:thing1/attributes/a%2f..%2f..%2f..%2f..%2fconnections modifies an attribute of the victim's Thing (under a JSON pointer containing the .. parts).

3. Helm chart Ingress forwards a client-supplied pre-authentication header

Since Ditto 3.9.0 (Helm chart 4.0.0), the chart provides optional, controller-independent Ingress resources (ingress-api.yaml, ingress-ws.yaml, ingress-devops.yaml) which route /api, /ws, /devops and other gateway paths directly to the gateway, bypassing the bundled nginx. With ingress.enabled: true and the default global.jwtOnly: false, pre-authentication is enabled in the gateway, but nothing sets or removes the x-ditto-pre-authenticated header, unless the operator configured the ingress controller to do so. Any client can then send the header itself.

The Helm charts of Ditto 3.3.0 to 3.8.15 (chart versions up to 3.8.15) contain a different, ingress-nginx based Ingress (ingress.enabled: true). Its api Ingress applies basic auth and sets the header from the basic auth user via a configuration-snippet annotation, which the devops Ingress reuses. The ws Ingress (nginx-ingress-ws.yaml) also applies basic auth, but does not set the header. With pre-authentication enabled (global.jwtOnly: false), any user with valid basic auth credentials can therefore open the WebSocket endpoint /ws with a client-supplied x-ditto-pre-authenticated header and act as any other subject.

Proof of concept

Reported and verified by S4lmon against the official eclipse/ditto-*:3.9.9 images, behind (a) the nginx.conf rendered from Helm chart 4.9.0 with default values and (b) the nginx.conf of deployment/docker. Pre-authentication enabled, only nginx reachable.

  1. As the legitimate user ditto (subject nginx:ditto), create a Thing:

```sh curl -u ditto:ditto -X PUT -H 'Content-Type: application/json' \ localhost/api/2/things/victim:thing1 \ -d '{"attributes":{"secret":"s3cr3t"}}'

-> 201 Created

```

  1. Exploit (read): no credentials, spoofed header, confused path (--path-as-is stops curl from normalizing /..):

```sh curl -i --path-as-is -H 'x-ditto-pre-authenticated: nginx:ditto' \ 'localhost/api/2/things/victim:thing1/x%2f..%2f..%2f..%2fconnections%2fy/..'

-> 200 OK, body contains "secret":"s3cr3t"

```

  1. Exploit (write / delete): S4lmon used the same construction (with the number of %2f.. adjusted to the path depth) to modify the victim's attribute (204), read the victim's Policy (200), list the victim's Things (200), delete the victim's Thing (204) and create a new Thing as nginx:admin, a subject that does not exist in nginx.htpasswd (201).

Gateway log for the unauthenticated request:

PreAuthenticatedAuthenticationProvider - Pre-authentication has been applied resulting in AuthorizationContext <ImmutableAuthorizationContext [type=pre-authenticated-http, authorizationSubjects=[nginx:ditto]]>.

Negative controls:

RequestResult
No credentials, normal path401 (nginx Basic auth)
No credentials, spoofed header, normal path401 (nginx Basic auth)
No credentials, confused path, without the spoofed header401 (gateway: gateway:authentication.failed)

Impact

This is an authentication bypass by spoofing (CWE-290), caused by an interpretation conflict between proxy and backend (CWE-436), and leads to impersonation of arbitrary policy subjects on the HTTP API.

An unauthenticated network attacker who knows or guesses a policy subject (subjects follow the predictable form <issuer>:<name>, e.g. nginx:<basic-auth-user>, and several can be sent comma-separated per request) can read, modify and delete all Things granted to that subject, use the search API to enumerate them, read Policies and create new entities under a subject of their choice. If the subject holds WRITE on policy:/, Policies can be rewritten to keep access. The WebSocket endpoint is not reachable this way, as the affected locations do not forward the Upgrade header.

Impacted are deployments that use one of the nginx configurations shipped with Ditto (or a derived one) and have pre-authentication enabled:

  • installations of the official Ditto Helm chart with default settings (global.jwtOnly: false),
  • the deployment/docker docker-compose setup,
  • the Kubernetes and OpenShift deployment files,
  • Helm chart installations with the Ingress enabled (ingress.enabled: true) and pre-authentication enabled, unless the ingress controller sets or removes the header on every path (no path manipulation needed),
  • Helm chart installations of Ditto 3.3.0 to 3.8.15 with the Ingress enabled and pre-authentication enabled: any basic auth user can impersonate other subjects via the WebSocket endpoint /ws,
  • custom reverse proxy setups that forward the client's x-ditto-pre-authenticated header on any location that reaches the gateway.

Additionally, Helm chart installations with global.jwtOnly: true and explicitly gateway.config.authentication.enablePreAuthentication: true forward a client-supplied header on /api and /ws directly, without any path confusion.

Not impacted:

  • deployments with pre-authentication disabled (ENABLE_PRE_AUTHENTICATION=false, the gateway's built-in default),
  • Helm chart installations with global.jwtOnly: true and gateway.config.authentication.enablePreAuthentication: false (also with the Ingress enabled).

Workarounds

Until a patched version is deployed, do one of the following:

  • disable pre-authentication in the gateway (ENABLE_PRE_AUTHENTICATION=false), or, with the Helm chart, configure global.jwtOnly: true (keeping gateway.config.authentication.enablePreAuthentication: false), or
  • add proxy_set_header x-ditto-pre-authenticated ""; to every nginx location that proxies to the gateway and does not set the header from a verified identity itself (/api/2/connections, /devops, /health, /status, /stats). It has to be added to each location, because a location that defines its own proxy_set_header directives does not inherit server-level ones.
  • with the Helm chart Ingress enabled: set global.jwtOnly: true, or configure the ingress controller to set the header from a verified identity or remove it on every path. For the 3.8.x charts, e.g. add a nginx.ingress.kubernetes.io/configuration-snippet with proxy_set_header x-ditto-pre-authenticated "nginx:$remote_user"; to ingress.ws.annotations.

Operators of custom reverse proxies should make sure that the proxy overwrites or removes x-ditto-pre-authenticated on every route that reaches the gateway.

Patches

Not patched yet; a fix is in preparation for Ditto 3.9.10 and 3.8.16:

  • nginx (Helm chart, docker-compose, Kubernetes, OpenShift): x-ditto-pre-authenticated is cleared in every location which proxies to the gateway without setting it from a verified identity.
  • Gateway: requests whose raw path contains dot segments (. or .., also percent-encoded or delimited by a percent-encoded slash %2f) are rejected with 400, so a proxy and the gateway can no longer resolve such a path to different resources.
  • Helm chart: rendering fails if an Ingress routing to the gateway is enabled while pre-authentication is enabled, unless ingress.preAuthenticationHeaderSanitized: true confirms that the ingress controller handles the header (or global.jwtOnly: true is used).
  • Helm chart 3.8.x: the ws Ingress sets the header from the basic auth user, like the api Ingress.
  • Documentation: the reverse proxy (or ingress controller) must set or clear the header in every location reaching the gateway.

References

GitHub · eclipse-ditto/ditto