# GHSA-5HH9-QP4V-6F56: Eclipse Ditto JSON merge patch deletions and empty-object values bypass WRITE authorization on Things

- Database: GitHub
- Severity: CVSS 7.1 (High)
- Published: 2026-11-19
- Modified: 2026-11-19

## Tracked as

- [CVE-2026-129699](https://cve.now/CVE-2026-129699.md): Eclipse Ditto authorization bypass in JSON merge patch on Things

## Description

### Summary

The authorization check for JSON merge patch commands on Things (HTTP `PATCH` / Ditto Protocol `merge`) does not
check permissions for fields that a merge patch **deletes** or **sets to an empty object**:

1. Fields with a `null` value in the patch body (RFC 7396 deletion) are skipped entirely by the authorization check.
2. Ditto's regex-based key deletion extension, `{{ ~<regex>~ }}` with a `null` value, is not recognized by the
   authorization check with the documented and recommended `~` delimiter (only with the `/` delimiter).
3. Fields with an empty object value (`{}`) in the patch body are skipped by the authorization check as well, although
   applying the patch replaces an existing non-object value with the empty object, or creates the field.

An **authenticated user with `WRITE` permission on any part of a Thing** can therefore delete any other part of that
Thing, including fields or subtrees the policy explicitly **revokes** `WRITE` on and fields the user was never granted
`WRITE` on at all. For example, a subject only allowed to write `thing:/attributes/a` can delete all attributes,
features and the definition of the Thing with a single request. Such a subject can also overwrite any field with an
empty object, or create new fields as empty objects.

Setting fields to values other than `null` or `{}` without permission is still rejected.

Severity: **High** (CWE-863).

### Details

A `MergeThing` command is authorized by
[`ThingCommandEnforcement.enforceMergeThingCommand`](https://github.com/eclipse-ditto/ditto/blob/3.9.8/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingCommandEnforcement.java#L578-L596).
If the caller has no unrestricted `WRITE` on the patched path, but `WRITE` on some part below it, it collects the
"leaves" of the patch with
[`calculateLeaves`](https://github.com/eclipse-ditto/ditto/blob/3.9.8/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingCommandEnforcement.java#L598-L614)
and requires unrestricted `WRITE` on every leaf.

#### 1. `null` values produce no leaf (affects 2.0.0 and later)

`calculateLeaves` recurses into every value for which `isObject()` is `true`. In Ditto's JSON library the JSON `null`
literal reports `isObject() == true` and `asObject()` returns an empty object
([`ImmutableJsonNull.java#L52-L64`](https://github.com/eclipse-ditto/ditto/blob/3.9.8/json/src/main/java/org/eclipse/ditto/json/ImmutableJsonNull.java#L52-L64)).
A field with a `null` value therefore contributes **no leaf at all**. For a patch that only deletes fields the set of
leaves is empty, and
[`Enforcer.hasUnrestrictedPermissions(Set, ...)`](https://github.com/eclipse-ditto/ditto/blob/3.9.8/policies/model/src/main/java/org/eclipse/ditto/policies/model/enforcers/Enforcer.java#L72-L80)
returns `true` for an empty set (`allMatch`). The command is authorized and the merge deletes the fields.

#### 2. `{{ ~<regex>~ }}` is not recognized as regex deletion (affects 3.5.5 and later)

For a regex deletion key, `calculateLeaves` is meant to require `WRITE` on the enclosing object. The check
[`isMergeWithNulledKeysByRegex`](https://github.com/eclipse-ditto/ditto/blob/3.9.8/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingCommandEnforcement.java#L621-L630)
only accepts the `/…/` delimiter, while the merge patch implementation
([`JsonMergePatch.java#L207-L239`](https://github.com/eclipse-ditto/ditto/blob/3.9.8/json/src/main/java/org/eclipse/ditto/json/JsonMergePatch.java#L207-L239))
also accepts `~…~`, the delimiter the [documentation](https://eclipse.dev/ditto/httpapi-concepts.html) recommends.
A `{{ ~<regex>~ }}` key is treated as an ordinary field with a `null` value (see 1.), and the merge then deletes all
keys matching the regex. The same applies when the regex key is the last segment of the patched path (e.g. a merge on
`/attributes/{{ ~firmware~ }}` with value `null`): enforcement checks the literal, non-existing resource, which inherits
the caller's grant on `/attributes`.

#### 3. Empty objects produce no leaf (affects 2.0.0 and later)

For the same reason as in 1., an empty object value (`{}`) contributes no leaf. Applying the patch
([`JsonMergePatch.java#L152-L205`](https://github.com/eclipse-ditto/ditto/blob/3.9.8/json/src/main/java/org/eclipse/ditto/json/JsonMergePatch.java#L152-L205))
replaces an existing non-object value (string, number, boolean, array) with the empty object, and creates a missing
field as empty object. If the patch only consists of `null` and `{}` values, the set of leaves is empty and the command
is authorized (see 1.). Otherwise, a single other field the caller may write is enough to get the command authorized.

The authorized patch is applied by
[`MergeThingStrategy`](https://github.com/eclipse-ditto/ditto/blob/3.9.8/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/strategies/commands/MergeThingStrategy.java#L186-L187)
without a further permission check.

### Proof of concept

Thing `T` with attributes `firmware` (`"1.0"`) and `other`, and a feature `f`.

**Policy A** for subject `u`: `WRITE` granted on `thing:/attributes`, revoked on `thing:/attributes/firmware`.

```
PATCH /api/2/things/<T>/attributes
Content-Type: application/merge-patch+json

{ "firmware": null }
```

The request is authorized and `attributes/firmware` is deleted. `{ "{{ ~firmware~ }}": null }` and
`{ "{{ ~.*~ }}": null }` have the same effect (the latter deletes all attributes).
`{ "firmware": {} }` and `{ "firmware": {}, "other": 1 }` overwrite `firmware` with `{}`.

**Policy B** for subject `u`: `WRITE` granted only on `thing:/attributes/other`.

```
PATCH /api/2/things/<T>
Content-Type: application/merge-patch+json

{ "attributes": null, "features": null, "definition": null }
```

The request is authorized, and all attributes, all features and the definition of `T` are deleted.

| Policy | Merge                                                          | Result                                          |
|--------|----------------------------------------------------------------|-------------------------------------------------|
| A      | `/attributes` ← `{ "firmware": "x" }`                          | rejected (correct)                              |
| A      | `/attributes/firmware` ← `null`                                | rejected (correct)                              |
| A      | `/attributes` ← `{ "{{ /firmware/ }}": null }`                 | rejected (correct)                              |
| A      | `/attributes` ← `{ "firmware": null }`                         | **authorized**, `firmware` deleted              |
| A      | `/attributes` ← `{ "{{ ~firmware~ }}": null }`                 | **authorized**, `firmware` deleted              |
| A      | `/attributes/{{ ~firmware~ }}` ← `null`                        | **authorized**, `firmware` deleted              |
| A      | `/attributes` ← `{ "firmware": {} }`                           | **authorized**, `firmware` set to `{}`          |
| A      | `/attributes` ← `{ "firmware": {}, "other": 1 }`               | **authorized**, `firmware` set to `{}`          |
| B      | `/` ← `{ "features": "x" }`                                    | rejected (correct)                              |
| B      | `/` ← `{ "attributes": null, "features": null }`               | **authorized**, attributes and features deleted |
| B      | `/` ← `{ "attributes": { "other": 1, "x": {} } }`              | **authorized**, attribute `x` created           |

### Impact

This is an **incorrect authorization** (CWE-863) for deletions and empty-object values in JSON merge patches. The
regex variant is additionally caused by an **interpretation conflict** (CWE-436) between the merge patch
implementation and the authorization check.

Impacted are Eclipse Ditto deployments where subjects have `WRITE` permission on only a part of a Thing, e.g.:

- "may write everything except these fields" policies (`WRITE` granted on a parent, revoked on children),
- "may only write these fields" policies (`WRITE` granted on selected attributes or features only).

Such a subject can delete any attributes, features (including properties and desired properties) and the definition
of the Thing, overwrite any of these fields with an empty object, or create new fields as empty objects. This may break
other components or users relying on that data. The changes are persisted and published as regular `ThingMerged`
events.

Not impacted are subjects without any `WRITE` permission on the Thing. Read access control is not affected.

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

#### Workarounds

There is no configuration-based workaround. For untrusted subjects with partial `WRITE` permission, operators can
reject HTTP `PATCH` requests to the Things API in their reverse proxy. This does not cover `merge` commands sent via
the WebSocket API or connections.

### Credits

Thanks to Jiwoo Kim for reporting the regex deletion variant of this vulnerability. The more general `null` deletion
and empty object variants were identified by the Eclipse Ditto maintainers while analysing the report and reviewing
the fix.

## References

- https://github.com/eclipse-ditto/ditto/security/advisories/GHSA-5hh9-qp4v-6f56

Page: https://cve.now/GHSA-5HH9-QP4V-6F56
