Repository navigation
Delete trust_level from client/hello - #158
Conversation
arturpragacz
left a comment
There was a problem hiding this comment.
After thinking about it some more I'm not sure it's a good idea to do this actually.
The problem is that there are some very weird edge cases, which are not going to happen in normal use, but someone could do it theoretically and so we have to handle them somehow. Consider for example:
- two servers, both already paired to the client
- the second one removes the pairing record for the first one
- it then sets the pairing PSK to the same PSK as the first server had
- now when the first server connects it thinks it is paired, but it actually isn't
So I think we should either go with the other solution (using paired field) or alternatively just leave it as is to make it easier to extend in the future if there is a need.
b3cd38d to
75ad081
Compare
|
Hmm, yea that's tricky to solve without any signal from the client Maybe there's another approach if we change the The rename to @arturpragacz Let me know which you prefer - the |
|
That's overkill and makes things more complicated. We don't need domain separation here. But I think I agree failing early is not a bad idea. So instead revert the psk_id changes and just add: to Noise 1 message (keep it exactly as above for same length). |
75ad081 to
8db2e97
Compare
|
Done, added the Also, I made a category mismatch a lookup miss rather than a hard handshake failure, so it lands in the Sentinel fallback and the server gets the credential-mismatch signal and re-pair prompt instead of a silent reconnect loop. |
Co-authored-by: Artur Pragacz <[email protected]>
# What does this implement/fix? Implements spec [#158](Sendspin/spec#158). Noise message 1 now carries `psk_category` alongside `psk_id`, naming which category the server is using the referenced PSK as. The client matches the `psk_id` only against candidates of that category, so a PSK it holds under a different one is a lookup miss. In exchange, `trust_level` leaves `client/hello`: the server reads trust off the PSK category it matched rather than being told by the client. NOTE: - **`ConnectionSecurity.trust_level` changes provenance.** It is now a property derived from `psk_category` rather than a value the client asserted. Consumers see the same attribute, but a client claiming `user` over a Sentinel connection reported `USER` and now reports `NONE`. No authorization gate moves — none of them read the field; they already read the PSK category. This is an API-honesty fix, not a hardening. - **`ClientHelloPayload`'s positional signature shifts**, since a field was removed. Keyword construction is unaffected. Backwards compatibility is a server concern here, and the server keeps it: a hello still carrying `trust_level` parses and the value is ignored. The client speaks the current spec and carries no second reading of it — `psk_category` is required, so a message 1 without it is a malformed payload and the handshake fails, and resolution is always scoped to the category the server declared. **Related issue (if applicable):** - n/a ## Types of changes - [x] Enhancement to an existing feature — `enhancement` ## Checklist - [x] The code change is tested and works locally. - [x] `pre-commit run --all-files` passes. - [x] `pytest` passes, and tests have been added/updated under `tests/` where applicable.
# What does this implement/fix? <!-- Quick description and explanation of changes. --> The spec removed trust level and made `psk_category` the only name for it, so `TrustLevel` and `ConnectionSecurity.trust_level` are removed. Use `ConnectionSecurity.psk_category` instead: `PskCategory.LONG_TERM` was trust level `user`, and anything else was `none`. Nothing changes on the wire. The server still accepts a `trust_level` key in `client/hello` from older clients. **Related issue or spec PR (if applicable):** - Sendspin/spec#158 - Sendspin/spec#159 ## 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`
# What does this implement/fix? <!-- Quick description and explanation of changes. --> Audio from a server that sends the spec's 13-byte audio chunk header was corrupted, since the client read the 4-byte `send_ahead` field as audio. The client also sent `trust_level` and player `supported_commands` in `client/hello`, which strict servers reject. The client now sends the rc1 `client/hello` and skips the full 13-byte header, and `send_ahead` doesn't affect playback. The operator's `languages` for a spoken pairing code are now read from `server/hello`, where the spec defines them. Breaking changes: - A server that still sends 9-byte audio chunk headers now plays corrupted audio. - `ClientHello` no longer has `trust_level` or player `supported_commands`, and `ActivatePairing` no longer has `languages`. Closing the connection on an audio message shorter than 13 bytes is left for a later PR. **Related issue or spec PR (if applicable):** - Sendspin/spec#158 - Sendspin/spec#167 - Sendspin/spec#177 - Sendspin/spec#241 ## 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`
The server already knows which PSK matched during the Noise handshake, so it can derive whether the session is paired instead of taking the client's word for it. Nothing consumed the field: every enforcement rule already keys on the matched PSK.
One gap made the field load-bearing until now: a management server could remove a record and then set its PSK as the client's pairing PSK, and the original server's next handshake would complete with the two sides disagreeing about the matched category -
trust_levelwas the only signal exposing that. This PR therefore addspsk_category: 'lt' | 'pr' | 'sn'to the Noise message 1 payload: the server declares which category it is using the referenced PSK as, and the client matchespsk_idonly among candidates of that category. A recategorized credential is now an ordinary lookup miss that lands in the Sentinel fallback, which already tells the server to re-pair, so paired state is fully derivable on both sides and the field can go. A miss during a re-handshake instead fails the handshake as before; the server's reconnect then takes the initial-handshake fallback path.Design notes: a category mismatch is deliberately a miss rather than a hard failure - the fallback turns it into an authenticated credential-mismatch signal with the re-pair path attached, where a hard failure would just produce a mute reconnect loop. The three codes share one length, keeping the encrypted payload's length independent of the category. The
psk_idderivation, the published Sentinel constant, and thealready_existsguards are all unchanged; the cross-category uniqueness rule stays, its rationale restated as what it actually protects (the pairing token distributes the pairing PSK in cleartext, so the same bytes must not also back a record).This PR also rewords the "trust level" term in the spec. This was a left over from when we had 3 (the additional owner level, whose management rights were merged into the user level - now called just paired).
unpaired_access.enabledremains because it is genuine client policy the server cannot derive.Breaking change
Existing pairing records and
psk_ids are untouched, so deployed pairings keep working. Breaking only when a client is updated before its server: an updated client requirespsk_categoryin Noise message 1 and no longer sendstrust_level, both of which an old server trips on. The reverse order is safe: receivers ignore unrecognized payload fields, so an updated server interoperates with old clients, which then simply don't enforce the category check.Closes #140
Alternative to #138, which keeps the field as a boolean
pairedinstead.