Skip to content

Require host approval before trusting paired peers - #143

Closed
benma-agent wants to merge 8 commits into
BitBoxSwiss:masterfrom
benma-agent:benma-agent/pairing-host-confirmation
Closed

benma-agent wants to merge 8 commits into
BitBoxSwiss:masterfrom
benma-agent:benma-agent/pairing-host-confirmation

Conversation

@benma-agent

@benma-agent benma-agent commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

The sequence counter is incremented after writing each continuation
frame. After frame 127 it becomes 128, causing the encoder to reject a
valid completed message. This affects payloads of 7,551 to 7,609 bytes.

Only report too many frames if there is still payload left to encode.
The encoder casts message lengths to u16 before checking the required
buffer size. Lengths above u16::MAX wrap, making that check unreliable;
other oversized messages are only rejected later by buffer or frame limits.

Reject payloads above the 7,609-byte U2F HID limit before narrowing the
length or writing any frames.
U2fHidCommunication::write unconditionally unwraps the framing result.
If a message is too large for U2F HID, encoding returns an error and the
library panics instead of returning a transport error.

Add U2fEncode and propagate encoding failures through ReadWrite::write.
Introduce a PairedBitBox enum with locked, unlocked and uninitialized
variants backed by a private session. Expose wallet operations only on
UnlockedBitBox, and consume UninitializedBitBox when restoring a wallet.

Keep device entry and unlock before pairing on every firmware version.
Validate the legacy unlock response to distinguish an unlocked wallet from
an uninitialized device. Reserve LockedBitBox::unlock for a later transition;
the connection flow cannot return that state yet.

Adapt existing examples and simulator helpers to the typed states.
Use paired protobuf unlock on firmware v9.28.0 and later, returning
LockedBitBox after pairing and completing the transition through
LockedBitBox::unlock. Keep legacy device entry on older firmware.

Add PassphraseConfig with asynchronous input and optional availability
callbacks. Integrations can offer a host-entry button while device entry
is available, or request host entry automatically. Invoke the input callback
only after approval on the device. Expire stale request handles and reset
the session when unlocking fails.

Copy the firmware protobuf definitions and regenerate the Rust bindings.
Add a simple automatic CLI example and a Cursive example with a host button.
Remove redundant mutex acquisitions from consuming unlock and restore transitions.
Keep serialization for calls using shared device references.
Rely on the payload size validation to bound the number of continuation frames.
The pairing flow currently persists the peer key after device confirmation alone. Require an
async host-confirmation callback before storing the key or returning a paired device state.
Rejecting or cancelling approval leaves saved peer trust unchanged, while verified reconnects
continue without prompting again.

Extend the typed-state pairing API with an explicit approval callback, and update the
documentation and examples, including both host-passphrase interfaces, to require a local
pairing-code comparison.
@benma-agent
benma-agent force-pushed the benma-agent/pairing-host-confirmation branch from 2f9e8d0 to d897433 Compare December 5, 2026 16:28
@benma benma closed this Dec 5, 2026
@benma-agent
benma-agent deleted the benma-agent/pairing-host-confirmation branch December 5, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants