hyperledger-firefly / hyperledger-firefly/firefly

Incorrect PATCHing of Node Identity Profile can cause Network Member Namespaces to Crash

Open
#1,450 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
602
Forks
246
Avg merge
18h 47m
Merged PRs (30d)
6

Description

Following up from https://github.com/hyperledger/firefly/pull/1074, if you attempt to PATCH a node's identity profile for say a cert rotation:
```
PATCH /api/v1/identities/{iid}
{
"profile": { "cert": "..." }
}
```

This will update a raw string / JSON column in the `identities` table and be broadcasted on the blockchain + IPFS. This profile is then fed to each FireFly who passes it to the FFDX plugin: https://github.com/hyperledger/firefly/blob/fd542c0b1dd74dd9d7d009f62aa7f601a136d1fa/internal/dataexchange/ffdx/ffdx.go#L343-L348

So if the profile omits an `id`, then it will `PUT /api/v1/peers` rather than `PUT /api/v1/peers/{id}`. This will error depending on your DX implementation. If your FireFly is then restarted, the namespace will be stuck `initializing` due to the errors for example:
```
[2024-01-23T04:06:03.482Z] DEBUG ==> PUT https://some-dx:3000/api/v1/peers/ breq=KqvrqLx4 dx=https pid=1
[2024-01-23T04:06:03.484Z] ERROR <== PUT https://some-dx:3000/api/v1/peers/ [404] (1.93ms) breq=KqvrqLx4 dx=https pid=1
```

And so, we need to 1) put protections on the PATCH profile to ensure all the data is either always provided or better yet it JSON patches (or some other merge strategy) the profile with the existing one, 2) determine if a namespace should stay in initializing or not if one of the DX peers cannot be added.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.