Repository navigation
Rework pairing attempt gating - #194
Conversation
maximmaxim345
left a comment
There was a problem hiding this comment.
Have two security concerns with this PR, left inline comments for both of them.
|
Edit: the |
Dynamic pairing code: replace gesture-gated escalation with a time-based backoff after 5 failures, and drop the counter's persistence across reboots - rebooting requires the same physical presence a gesture proves. Static pairing code: the window admits up to 5 attempts per gesture instead of one, so a typo no longer costs a walk to the device. The pairing window is now a static-code-only concept. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5390ded to
8260423
Compare
|
Good example of something to add to the implementation guide. cooldown strategy should be client concern so we should not mandate it at all |
No escalation and no backoff: how a client throttles failed dynamic pairing attempts is its own concern. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
The change to static pairing code to 5 attempts per window is fine. The change to dynamic pairing code going from gesture-gating after escalation to cool down is not a good idea. We could, if anything, in light of the other changes go in the opposite direction now and gesture-gate already from the first attempt. |
@arturpragacz was thinking about this a bit. What I'm definitely against is 3067218 in its form. That's basically dropping the constants were IMO good enough, so a client implemented to spec can be brute forced in under a day. Gesture gating is a good idea, but forcing it onto any manufacturer also feels invasive. What I'm fearing is that we have a protocol thats secure, but with limited adoption because of that. I think there is no "best" solution here so we need to compromise somewhere... I have another idea though that should allow security conscious devices to stay secure (or even more secure as before this PR and other recent changes), but still allows manufacturers more flexibility. What do you think about ce32049: What if we keep With the recommended cooldown from ce32049, from my calculations it's a 50% chance of getting in after ~20 years. With no limit it's about 20 ms per attempt, so a 98.7% chance of getting in within a day. |
As written a client with no limit at all is conformant, a server that aborts before the code finishes playing is never counted, and a count kept per server is bypassed by rotating keys. After 20 consecutive failed attempts the client now MUST hold attempts back until a deliberate operator action, with a power cycle qualifying so no device is locked out. Counting starts when emission starts and the count is global. The cooldown schedule is dropped: how a client paces attempts before the limit is its own choice, reported through `retry_after_ms` and `message`. Also caps `message` at 200 characters and lets a server cancel instead of outlasting `retry_after_ms`.
With no recommended cooldown and a hard stop at 20 attempts the duration served no security purpose, and `message` already tells the operator what the client waits for.
Removes the digit audio pack that #173 introduced. During initial pairing the pack came from an unauthenticated peer, which thereby chose what the client's speaker played and drove the client's audio decoders before any trust was established. Speaking clients return to their own bundled voice, choosing the language against the server's `languages` hint in `server/hello` under RFC 4647 Lookup matching, as before #173. Hand revert rather than `git revert`: #179, #194 and #237 have since rewritten the surrounding text, and the `languages` move from `server/activate` to `server/hello` in #173 stays, since `client/pair-pending`'s `message` field relies on it. Changes, all in `messaging.md` and `pairing.md` with `README.md` regenerated: - Binary message ID `2` returns to the reserved `2-3` range. - `server/activate` `pairing.format?` no longer conditions `digits` on fitting a pack. - Sequence diagram, Digits emission, Protocol Errors, the `dynamic_pairing_code` descriptor (`digit_audio` removed; `out_channels` unchanged), the Messages intro, `client/pair-init` and `server/pair-init` lose their pack references. - The `Server → Client: Digit Audio Clip (Binary)` section is removed. Closes #203 --------- Co-authored-by: Maxim Raznatovski <nda.mr43@gmail.com>
# What does this implement/fix? <!-- Quick description and explanation of changes. --> A mistyped dynamic pairing code ended the whole pairing attempt, and after 10 failures every attempt needed the pairing window, with no way to reset the count. Now a wrong code starts another round with the same code. After 20 rounds without a correct code, attempts wait until the app calls `releasePairingHold()` on a deliberate action on the device, which also resets the count. This also fixes a few other gaps with the spec: - The static pairing window now stays open across attempts, so a timed-out or cancelled attempt no longer needs a new gesture. It closes on a completed pairing, the fifth wrong code, a drop of the connection that used it, or `cancelPairing()`. - Pairing messages that arrive out of sequence now close the connection instead of being ignored. Messages still in flight after the client's own `pair/abort` are still dropped. - The sample player shows the dynamic code as `123-456` and speaks it with a pause between groups. This is a breaking change: `isDynamicPinEscalated()` is now `isRoundLimitReached()`, and `releasePairingHold()` replaces `openPairingWindow()` for releasing held-back dynamic pairing attempts. **Related issue or spec PR (if applicable):** - Sendspin/spec#194 - Sendspin/spec#237 - Sendspin/spec#312 ## Types of changes <!-- Tick exactly one box. CI (.github/workflows/pr-labels.yaml) applies the matching label, and the release notes use it to sort this change. --> - [ ] Bugfix (non-breaking change which fixes an issue): `bugfix` - [ ] New feature (non-breaking change which adds functionality): `new-feature` - [ ] Enhancement to an existing feature: `enhancement` - [x] Breaking change (changes the public API or the protocol in a way that is not backwards compatible): `breaking-change` - [ ] Refactor (no behavior change): `refactor` - [ ] Documentation only: `documentation` - [ ] Maintenance / chore: `maintenance` - [ ] CI / workflow change: `ci` - [ ] Dependencies bump: `dependencies`
<!-- Describe the change and why it is needed. --> A recognized message can carry a value outside its field's fixed range, such as `output_delay_ms` above 5000 in `client/state` or a controller `volume` of 101. Most fields don't say what the receiver does with one. This makes such a value a protocol error, and the receiver MUST close the connection. Only a broken implementation sends one, and closing matches how the spec treats other protocol errors. The rule only covers fixed ranges and length limits. Bounds relative to another value, like the visualizer `rate_max` or the player timing bounds, can be crossed by a message in flight, and the receiver often can't check them reliably. A field or message with its own rule keeps it: the server still ignores a `seek` outside 0 to `seek_max_ms`, a bad `client/init` is still an init failure, and the #344 `client/hello` caps keep their MAY close. This also removes handling the rule now covers: - truncating an over-long server `name` or `group_name` (from #339) and `client/pair-pending` `message` (from #194) - the SHOULD close for an artwork `channels` array longer than 4 - the player clamp rules for `output_delay_ms` and `min_buffer_ms`, since their 0-5000 field ranges already bind the sender It also adjusts text the rule would otherwise break: - an artwork client that truncates its `channels` array keeps at least one entry - metadata `track` states its range (at least 1), and `year` no longer says "YYYY format" - values inside ignored inactive-role objects are left unvalidated - sending a value outside a range or length limit an earlier revision defined needs negotiation, like a new field So plain text over its byte cap now closes the connection too, including a client `name` or `device_info` string over 64 bytes. - [x] I accept the [Contributor License Agreement](../blob/main/CONTRIBUTOR-LICENSE-AGREEMENT.md) for this contribution.
Reworks how code-based pairing attempts are gated, from the #183 lockout discussion.
Dynamic pairing code: the persisted failure counter and its escalation to gesture-gating are gone. A failed attempt is one where the client started emitting the code and the attempt ended without a successful
server_kcverification. After 20 consecutive failed attempts the client MUST hold attempts back until a deliberate, manufacturer-defined operator action; which action is the manufacturer's choice, with guidance tracked in #205. The count is global across servers and addresses and resets on success or on that action. How a client paces attempts before the limit is its own choice, and it MAY be stricter, including a gesture from the first attempt. Since any deliberate action qualifies, no device is locked out, and since a client with no limit is not conformant, manufacturers have a spec section to point a test lab at (ETSI EN 303 645 provision 5.1-5, EN 18031-1 AUM-6).Static pairing code: the window admits up to 5 attempts instead of one, all on the connection that carries the first, so a typo no longer costs a walk to the device. It closes on a completed pairing, the fifth failed attempt, drop of that connection, operator cancellation, or lifetime expiry, and the lifetime pauses while an attempt is in progress. The pairing window is now a static-code-only concept and its section moves under the Static Pairing Code Flow.
client/pair-pendingnow covers both cases, a gesture awaited or a dynamic attempt held back, and gains an optionalmessage: a plain-text sentence for the operator of at most 200 characters, preferably in one of the server'slanguages, shown as device text with no markup interpreted. The server SHOULD surface the pending state and the message to the operator and apply its own timeout.An abandoned attempt does not count against a window and counts as a failed dynamic attempt only if the code was already being emitted.