Repository navigation
Conversation
…ered After an offer, the OTA provider enabled BDX for the requestor on the update storage without a transfer direction or file restriction. The requestor could therefore send a SendInit and write any file into the storage that all requestors share, including an image offered to other nodes, or read images it was not offered. BdxProtocol.Config gets allowedInitMessages and fileDesignators. An Init message the registration does not allow is answered with UNEXPECTED_MESSAGE, as the CHIP SDK does for an Init in the wrong direction; a designator outside the list gets FILE_DESIGNATOR_UNKNOWN. The OTA provider allows only ReceiveInit of the offered image. Without the new fields a registration keeps its old behaviour. A refused transfer now logs at info, because a peer can repeat it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change restricting OTA requestors to downloading only their offered image.
No open issues 🎉
What changed in this PR
This PR restricts OTA requestors to downloading only their offered image, preventing uploads into shared update storage and reads of other images. It adds optional BDX restrictions while preserving existing behavior for callers that omit them.
Changes:
- Add transfer-direction and exact file-designator checks before creating a BDX session.
- Configure the OTA provider to allow only downloads of the offered image.
- Add regression tests for refused transfers, unchanged storage, successful downloads, and parallel requestors.
The PR reports successful build, formatting, lint, and ESM tests across all 12 packages. These checks were not rerun here.
| File | Description |
|---|---|
packages/protocol/test/bdx/BdxTest.ts |
Tests direction restrictions, file restrictions, and permitted transfers. |
packages/protocol/test/bdx/bdx-helpers.ts |
Accepts protocol-level restrictions in the transfer helper. |
packages/protocol/src/bdx/BdxProtocol.ts |
Adds optional restrictions and logs refused transfers at info level. |
packages/node/test/behaviors/ota/OtaTest.ts |
Tests unauthorized transfers, storage integrity, and parallel downloads. |
packages/node/src/behaviors/ota-software-update-provider/OtaSoftwareUpdateProviderServer.ts |
Limits each requestor to downloading its offered image. |
CHANGELOG.md |
Documents the OTA protection and new BDX configuration options. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When the OTA provider offers an update over BDX, it registers the requestor for the update storage scope with
BdxProtocol.enablePeerForScope(). The registration stored neither a transfer direction nor a file, andBdxProtocolaccepts both SendInit and ReceiveInit. The requestor could therefore send a SendInit forota/<any name>and write into the storage that holds the images for all requestors, including overwriting an image that is later offered to other nodes. It could also read stored images it was not offered. A new test reproduces the overwrite on the code before this change: the upload succeeds.Design
BdxProtocol.Configgets two optional restrictions:allowedInitMessages: the Init messages the peer may start a transfer with. Any other Init is answered with UNEXPECTED_MESSAGE, which is what the CHIP SDK answers for an Init in the wrong direction (BdxTransferSession.cpp,HandleTransferInit).fileDesignators: the complete designators the peer may transfer. Any other designator is answered with FILE_DESIGNATOR_UNKNOWN, as the CHIP OTA provider does for an unknown designator.Both checks run before a BDX session is created, so a refused transfer starts no session and changes no OTA attempt state.
The OTA provider allows only ReceiveInit of the offered designator. The comparison is against the complete designator text, so variants with extra path parts or different encoding do not match.
Without the new fields a registration behaves as before.
enablePeerForScopeis part of the public API, and a permissive default keeps external callers working; the OTA provider is the only caller in this repository.Registrations stay per peer and scope, so parallel OTA transfers to different nodes keep working; a new test runs two downloads at the same time.
Behaviour change: if a requestor is offered a different image while its own transfer still runs, the registration differs and
enablePeerForScopereturns false, so the provider answers Busy. A node has one software version, andadmitQueryalready refuses or closes most of these overlaps earlier, so this is a narrow case.A refused transfer now logs at info instead of warn, because a peer can repeat it.
Tests
BdxTest: a SendInit on a ReceiveInit-only scope, a ReceiveInit for an existing file outsidefileDesignators, and a transfer that both restrictions allow.OtaTest: after a real offer, the requestor opens its own BDX exchange and tries to overwrite the offered image, to write a new file, and to read a stored image it was not offered. Each is refused with the expected status, the storage content is unchanged, and the requestor's own download and apply still complete. A characterization test runs two requestor downloads in parallel.Verification
🤖 Generated with Claude Code