Skip to main content
Menu
Advisories

Eclipse Ditto exposes non-readable Thing fields through condition and live-channel-condition headers

GHSA-X88M-JQ5C-JPCQPublished Updated GitHub

Description

Several requests accept client-supplied RQL conditions which reference Thing fields: the condition header and, for Thing query commands (e.g. HTTP GET /api/2/things/<id> / Ditto Protocol retrieve), the live-channel-condition header. They are evaluated against the full, unfiltered Thing, so the requester must have READ permission on all fields they reference, and responses must only contain fields the requester may read. This was not ensured in four cases:

  1. condition and live-channel-condition combined: when both headers are present on a Thing query command, only READ on the fields of condition is checked. The check for live-channel-condition is skipped.
  2. WoT Thing Description requests: requests with Accept: application/td+json skip the policy authorization (the Thing Description is treated as public information) when WoT TD permission filtering is disabled, which was the only behavior before 3.9.0. The condition and live-channel-condition headers are nevertheless evaluated.
  3. Live messages, claim messages and live events: the condition header of live signals is evaluated before publishing them, without checking READ on the referenced fields. Messages only require WRITE on the message resource, live events WRITE on the event's resource, and claim messages no permission at all.
  4. Smart channel twin responses: when the live-channel-condition of a Thing query command does not match, the twin response is returned to the requester without filtering it by the policy, i.e. including all fields of the Thing.

The result of an unchecked condition is returned to the requester (cases 1. to 3.): as 412 Precondition Failed versus a successful response for condition, and in the live-channel-condition-matched response header and through the channel Ditto answers on for live-channel-condition. In case 4. the field values are directly contained in the response.

An authenticated user can therefore read Thing fields they are not allowed to read:

  • via 1. and 4., a user with READ permission on any part of a Thing can read all other fields of that Thing, via
  1. with a single request,
  • via 3., a user with WRITE permission on any message or live event resource of a Thing can read all fields of that Thing, using claim messages even without any permission on the Thing,
  • via 2., a user without any permission on a Thing can read all fields of that Thing.

For cases 1. to 3., values are recovered by testing predicates (eq, gt, lt, like, …), one request at a time. Knowing the ID of the Thing is required in all cases.

Severity: High (CWE-863, CWE-200).

Details

1. live-channel-condition is not checked when a condition is present (affects 3.0.0 and later)

A ThingQueryCommand is authorized by ThingCommandEnforcement.authorizeByPolicyOrThrow, which enforces READ on the fields referenced by the conditions:

final var condition = dittoHeaders.getCondition();
if (!(command instanceof CreateThing) && condition.isPresent()) {
    enforceReadPermissionOnCondition(condition.get(), ...);
} else if ((command instanceof ThingQueryCommand)) {
    dittoHeaders.getLiveChannelCondition()
            .ifPresent(liveChannelCondition -> enforceReadPermissionOnCondition(liveChannelCondition, ...));
}

Because the two checks are in an if / else if, a command carrying a condition never reaches the check of the live-channel-condition. Both headers are read from external headers (DittoHeaderDefinition.java#L517-L535).

The bug was introduced in 3.0.0 when the enforcement was moved from the concierge to the things service. In 2.3.0 to 2.4.x, where live-channel-condition was introduced, both conditions were checked independently.

2. Conditions on WoT Thing Description requests are not authorized (affects 2.4.0 and later)

For RetrieveThing and RetrieveFeature commands with Accept: application/td+json, ThingCommandEnforcement forwards the command to the things persistence without any policy check (3.8.14, 3.9.8 with ditto.devops.feature.wot-td-permission-filtering-enabled=false), as the Thing Description is considered public information. The condition and live-channel-condition headers are forwarded as well and are evaluated against the full Thing before the Thing Description is generated (AbstractThingCommandStrategy.java#L102-L126).

This applies by default to 3.0.0 up to 3.8.14. In 2.4.x the WoT integration had to be enabled explicitly (ditto.devops.feature.wot-integration-enabled). Since 3.9.0, WoT TD permission filtering is enabled by default, so the request is authorized and only case 1. applies, unless the filtering is disabled.

3. Conditions on live messages and live events are not authorized (affects 3.1.0 and later)

LiveSignalEnforcement publishes claim messages without any enforcement and authorizes messages and live events by WRITE permission only, without checking READ on the fields referenced in a condition. Before publishing the live signal, SupervisorLiveChannelDispatching.evaluateCondition retrieves the Thing directly from the things persistence (unfiltered; up to 3.8.6 via SudoRetrieveThing) and evaluates the condition against it. A matching condition publishes the signal (e.g. ending in a 408 without a live subscriber), a non-matching one fails with 412 Precondition Failed.

4. Smart channel twin responses are not filtered (affects 3.0.0 and later)

A Thing query command carrying a live-channel-condition is processed by SupervisorSmartChannelDispatching. If the condition does not match, the twin response retrieved from the things persistence is sent to the requester directly (AbstractPersistenceSupervisor.java#L549-L560), bypassing the response filtering by the policy which is applied to all other twin query responses. The response contains all fields of the Thing (or of the queried sub-resource).

How condition results are exposed

Proof of concept

Thing T with attributes pub ("p") and secret ("A7"). Policy: subject reader has READ on thing:/attributes/pub only, subject messenger has WRITE on message:/ only, subject nobody has no permission.

1. condition and live-channel-condition combined

GET /api/2/things/<T>
live-channel-condition: eq(attributes/secret,"A7")

as reader is correctly rejected with 412 Precondition Failed (things:condition.failed), because reader may not read attributes/secret.

GET /api/2/things/<T>
condition: exists(attributes/pub)
live-channel-condition: eq(attributes/secret,"A7")

as reader is authorized:

live-channel-conditionResponse
eq(attributes/secret,"A0")200, live-channel-condition-matched: false, immediately
eq(attributes/secret,"A7")408, live-channel-condition-matched: true, after the timeout

2. WoT Thing Description request (e.g. Ditto 3.8.14, default configuration)

GET /api/2/things/<T>
Accept: application/td+json
condition: eq(attributes/secret,"A7")

as nobody:

conditionResponse
eq(attributes/secret,"A0")412 Precondition Failed
eq(attributes/secret,"A7")regular response of the Thing Description request

3. Claim message

POST /api/2/things/<T>/inbox/claim?timeout=3
condition: eq(attributes/secret,"A7")

as nobody (or POST /api/2/things/<T>/inbox/messages/ping as messenger):

conditionResponse
eq(attributes/secret,"B7")412 Precondition Failed
eq(attributes/secret,"A7")408, the message was published

4. Smart channel twin response

GET /api/2/things/<T>
live-channel-condition: eq(attributes/pub,"zzz")

as reader (the condition only references a readable field) returns:

HTTP 200
live-channel-condition-matched: false

{"thingId":"<T>","policyId":"<T>","attributes":{"pub":"p","secret":"A7"}}

whereas the same request without live-channel-condition returns {"thingId":"<T>","attributes":{"pub":"p"}}.

Impact

This is an incorrect authorization (CWE-863) of the condition and live-channel-condition headers and of smart channel twin responses, leading to an exposure of sensitive information to an unauthorized actor (CWE-200). It is exploitable via HTTP, the WebSocket API and connections.

Impacted are Eclipse Ditto deployments with subjects which must not read all fields of a Thing:

  • via 1. and 4. (3.0.0 and later, default configuration): subjects with READ permission on only a part of a Thing, e.g. policies revoking READ on specific attributes or features, or granting READ on selected attributes or features only,
  • via 3. (3.1.0 and later, default configuration): subjects with WRITE permission on messages or live events of a Thing, and any authenticated subject via claim messages,
  • via 2. (3.0.0 up to 3.8.x in the default configuration, 2.4.x with WoT integration enabled, 3.9.x with WoT TD permission filtering disabled): any authenticated subject.

Write access control is not affected.

Affected versions: 2.4.0 up to 3.8.14 and 3.9.0 up to 3.9.8.

Patches

Fixed in 3.8.15 and 3.9.9:

  • READ on the live-channel-condition is checked independently of the condition.
  • condition and live-channel-condition headers on WoT Thing Description requests are rejected with 400 Bad Request (header.invalid), as conditions are not supported for Thing Descriptions.
  • READ on the fields referenced in the condition of live messages and live events is checked, and a condition on claim messages is rejected with 400 Bad Request (header.invalid).
  • Smart channel twin responses are filtered by the policy like all other twin query responses.

Workarounds

There is no complete configuration-based workaround.

  • For case 2. on 3.9.x, make sure WoT TD permission filtering is enabled (the default). On older versions, disabling the WoT integration (environment variable DITTO_DEVOPS_FEATURE_WOT_INTEGRATION_ENABLED=false, Helm value global.featureFlags.wotIntegrationEnabled: false) prevents case 2., at the cost of the WoT features.
  • In a reverse proxy, operators can reject HTTP requests carrying a live-channel-condition header (cases 1., 2. and 4.), and requests to the message endpoints (/inbox, /outbox) carrying a condition header (case 3.). This does not cover commands sent via the WebSocket API or connections.

Credits

Thanks to Jiwoo Kim for reporting this vulnerability (case 1.). Case 2. was identified by the Eclipse Ditto maintainers while analysing the report, cases 3. and 4. by @hu-ahmed while reviewing the fix.

References

GitHub · eclipse-ditto/ditto