Skip to main content
Menu
Advisories

Eclipse Ditto Thing events and subscription filters disclose field values the subscriber may not read

GHSA-3FX4-8JRP-7PQMPublished Updated GitHub

Description

Eclipse Ditto delivers Thing events (WebSocket, Server-Sent Events, connections) containing field values which the policy does not allow the subscriber to read, and which a retrieve of the same Thing correctly filters out. It also evaluates subscription filters, placeholders and enrichment on behalf of the subscriber on the unfiltered event. This affects:

  1. Subscribers with several subjects (e.g. a user subject and a group/role subject extracted from the same JWT, or a connection target with several authorization subjects): a READ revoke for one subject is not applied when another subject of the same authorization context is granted READ.
  2. Subscribers with partial READ access (since 3.9.0, partial access events): the event payload is filtered, but not everything evaluated on behalf of the subscriber.
  3. Receivers of live commands: a live command (e.g. a live ModifyAttributes) is delivered with its whole payload to every subscriber with READ on the command's path, even if READ is revoked for a part of the payload — also for a subscriber with a single subject.

Severity: High.

Details

When a Thing event is created, the things service attaches the subjects allowed to read it to the event's headers:

  • ThingCommandEnforcement#addEffectedReadSubjectsToThingSignal sets read-granted-subjects, determined for each subject on its own: a subject is included when it is granted READ on the event's resource (or, since 3.9.0, on some part of it), regardless of revokes of other subjects. No read-revoked-subjects are set for Thing events.
  • Since 3.9.0, the readable paths of each partially granted subject are attached as well, again per subject.

The event delivery then grants access to the whole subscriber as soon as one of its subjects is included:

  • StreamingSessionActor#isSessionAllowedToReceiveSignal (WebSocket, SSE) and connectivity's SignalFilter call AuthorizationContext#isAuthorized(readGrantedSubjects, readRevokedSubjects), which allows delivery if any subject is granted and none is revoked. As the revoked subjects are empty, one granted subject suffices.
  • PartialAccessPathResolver#resolveAccessiblePaths (3.9.x) returns the unfiltered payload if any subject of the subscriber has unrestricted READ, and otherwise the union of the readable paths of its subjects. A revoke of another subject is never subtracted.

Independently of the payload filtering, the following are evaluated on the unfiltered event, so they reveal fields the subscriber cannot read, also for a subscriber with a single, partially granted subject:

  • RQL filters of WebSocket/SSE subscriptions and of connection target topics (e.g. eq(attributes/secret,"s1") delivers the event only if the hidden value matches),
  • the _context of SSE events (fields=_context),
  • thing-json placeholders in connection header mappings and payload mapper conditions,
  • pre-defined extra fields of events and live messages, which are not filtered for revokes.

Furthermore:

  • live events are not filtered for partial READ access at all, and events deleting a field (or merging null into it) are delivered to subscribers who may not read that field;
  • live commands get their readers from LiveSignalEnforcement#addEffectedReadSubjectsToThingLiveSignal, which only considers the command's own path, and their payload is never filtered;
  • the readable paths of partially granted subjects are calculated with all policy entries, also with those restricted to other namespaces (namespaces), so such a grant widens what is delivered for Things in any namespace;
  • a partially granted subject which can read none of the fields of the Thing is not listed with the readable paths, and therefore treated as unrestricted, i.e. it receives the whole event.

Retrieving a Thing is not affected: there, the policy is evaluated for the authorization context as a whole, so the revoke of one subject applies to the request.

Proof of concept

Using the deployment/docker docker-compose setup, which enables pre-authentication and exposes the gateway directly on port 8081 (the gateway accepts several comma-separated pre-authenticated subjects, which stands in for e.g. a JWT yielding several subjects):

  1. Create a policy where nginx:alice is granted READ on thing:/, nginx:group-x has READ revoked on thing:/attributes/secret and nginx:carol is only granted READ on thing:/attributes/pub, plus a Thing using it:

```sh curl -u ditto:ditto -X PUT -H 'Content-Type: application/json' \ localhost/api/2/policies/org.example:poc -d '{ "entries": { "admin": { "subjects": { "nginx:ditto": { "type": "admin" } }, "resources": { "policy:/": { "grant": ["READ", "WRITE"], "revoke": [] }, "thing:/": { "grant": ["READ", "WRITE"], "revoke": [] } } }, "user": { "subjects": { "nginx:alice": { "type": "user" } }, "resources": { "thing:/": { "grant": ["READ"], "revoke": [] } } }, "restricted": { "subjects": { "nginx:group-x": { "type": "group" } }, "resources": { "thing:/attributes/secret": { "grant": [], "revoke": ["READ"] } } }, "partial": { "subjects": { "nginx:carol": { "type": "user" } }, "resources": { "thing:/attributes/pub": { "grant": ["READ"], "revoke": [] } } } } }'

curl -u ditto:ditto -X PUT -H 'Content-Type: application/json' \ localhost/api/2/things/org.example:poc \ -d '{ "policyId": "org.example:poc", "attributes": { "pub": "p0", "secret": "s0" } }' ```

  1. Retrieving the Thing as the authorization context {nginx:alice, nginx:group-x} correctly omits secret:

```sh curl -H 'x-ditto-pre-authenticated: nginx:alice,nginx:group-x' \ localhost/api/2/things/org.example:poc

{"thingId":"org.example:poc","policyId":"org.example:poc","attributes":{"pub":"p0"}}

```

  1. Subscribe for events of the Thing as the same authorization context, and as nginx:carol with a filter on the field she cannot read:

```sh curl -N -H 'Accept: text/event-stream' -H 'x-ditto-pre-authenticated: nginx:alice,nginx:group-x' \ 'localhost/api/2/things?ids=org.example:poc'

curl -N -H 'Accept: text/event-stream' -H 'x-ditto-pre-authenticated: nginx:carol' \ 'localhost/api/2/things?ids=org.example:poc&filter=eq(attributes/secret,"s2")&fields=thingId,attributes,_context' ```

  1. Modify the attributes as admin:

``sh curl -u ditto:ditto -X PUT -H 'Content-Type: application/json' \ http://localhost:8080/api/2/things/org.example:poc/attributes/secret -d '"s1"' curl -u ditto:ditto -X PUT -H 'Content-Type: application/json' \ http://localhost:8080/api/2/things/org.example:poc/attributes -d '{ "pub": "p2", "secret": "s2" }' ``

Vulnerable versions send both values of secret to {nginx:alice, nginx:group-x}:

`` data:{"thingId":"org.example:poc","attributes":{"secret":"s1"}} data:{"thingId":"org.example:poc","attributes":{"pub":"p2","secret":"s2"}} ``

and (3.9.x) an event to nginx:carol, confirming the value of secret and containing it in _context:

`` data:{"thingId":"org.example:poc","attributes":{"pub":"p2"},"_context":{"topic":"org.example/poc/things/twin/events/modified","path":"/attributes","value":{"pub":"p2","secret":"s2"},"headers":{...}}} ``

The correct result is no event for the first modification and {"pub":"p2"} for the second one to {nginx:alice, nginx:group-x}, and no event to nginx:carol, as her filter refers to a field she cannot read.

The same applies to a WebSocket session (START-SEND-EVENTS, START-SEND-LIVE-EVENTS) and to connection targets, and to all Thing events whose payload contains the restricted resource (e.g. ThingModified, ThingMerged, AttributesModified).

Impact

Incorrect authorization (CWE-863): disclosure of Thing field values to event subscribers and receivers of live commands which the policy does not allow them to read, either because a READ revoke applies to another subject of their authorization context, or because they are only partially granted READ. Only values of Things the subscriber may at least partially read are disclosed, and only while events for them are emitted. The severity is nevertheless rated High: with partial access events enabled (the default since 3.9.0), a subscriber with only partial READ receives the full values of non-readable fields of every emitted event and can select the fields to disclose via subscription filters, and as Things are usually updated frequently, this typically discloses all non-readable fields which are written.

Not impacted:

  • retrieving Things (GET, retrieve commands) and searching Things,
  • authorization of modifying commands and of live messages (only the delivery of live commands is affected, see above),
  • subscribers with unrestricted READ on the Thing and no revoked subject.

Workarounds

Until a patched version is deployed:

  • do not rely on a READ revoke for one subject to restrict what another subject of the same authorization context may read: add the revoke to the policy entry of every subject which is granted READ on the resource as well;
  • do not grant partial READ access on Things containing fields which must stay confidential towards these subjects, or disable partial access events (THING_EVENT_PARTIAL_ACCESS_EVENTS_ENABLED=false) — note that partially granted subjects then receive no events for these Things;
  • do not send live commands containing fields whose READ is revoked for subjects subscribed to live commands of the Thing;
  • do not restrict policy entries granting partial READ to namespaces (namespaces).

Patches

Fixed in Eclipse Ditto 3.9.9: the things service attaches, per subject, the paths whose READ is revoked to every Thing event, live event and modifying live command, calculated with the policy entries applicable to the Thing's namespace; partially granted subjects which can read nothing are no longer receivers. Gateway and connectivity remove the paths revoked for any subject of the subscriber, and evaluate filters, placeholders, _context and extra fields only on the part of the event the subscriber may read. An event is not delivered if the subscriber may read nothing at its path. A live command is never altered: it is not delivered to a subscriber who may not read all of it.

References

GitHub · eclipse-ditto/ditto