Repository navigation
Follow the spec rules for PSK matching and handshake failures - #199
Merged
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Authentication fallback, live session-key transitions, and breaking changes to stored credentials warrant final human protocol and security review.
No open issues 🎉
What changed in this PR
This PR aligns the SDK’s encrypted transport with the protocol’s PSK matching and handshake-failure rules, allowing clients with lost pairing records to reach re-pairing.
Changes:
- Validate handshake payloads and PSK categories, with Sentinel fallback for initial lookup misses.
- Close failed re-handshakes and queue outgoing traffic until activation, except
client/hello. - Require server-bound long-term PSKs and skip stored records without a server ID.
| File | Description |
|---|---|
tests/unit/transport.test.ts |
Tests fallback, category matching, server binding, and malformed payload rejection. |
tests/unit/transport-unpair.test.ts |
Removes obsolete shared-PSK unpair coverage. |
tests/unit/transport-rehandshake.test.ts |
Tests failure handling, callback isolation, and outbound queuing. |
tests/unit/transport-harness.ts |
Adds reusable handshake helpers with PSK categories. |
tests/unit/transport-activate.test.ts |
Updates calls to the server-bound handshake helper. |
tests/unit/noise/psk.test.ts |
Tests skipping stored PSKs without a server ID. |
tests/unit/core-encryption.test.ts |
Updates integration fixtures with categories and server-bound PSKs. |
src/types.ts |
Makes configured long-term PSK server IDs required. |
src/core/transport.ts |
Implements stricter matching, failure handling, and traffic queuing. |
src/core/noise/psk.ts |
Removes support for unbound long-term PSK records. |
src/core/core.ts |
Rejects configured long-term PSKs missing a server ID. |
README.md |
Updates the server ID configuration example. |
Review effort: Balanced
33 tasks done
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.
What does this implement/fix?
A client that lost its pairing record (cleared storage, an interrupted pairing) couldn't reconnect to a server that still had it paired, since it closed the handshake on an unknown
psk_idand stopped reconnecting.It also ignored
psk_category, accepted malformed handshake payloads, and kept running on the old keys when a re-handshake failed.Now an unknown
psk_id, or one the client holds under a different category, falls back to the Sentinel PSK in the initial handshake, so the server can offer re-pairing.Malformed payloads and failed re-handshakes close the connection, and outgoing messages are held during a re-handshake until the new
server/activate.Breaking changes:
longTermPsks[].serverIdis now required, since the spec no longer has long-term PSKs without aserver_id. Stored records without one are no longer used, so those servers need to be paired again.Related issue or spec PR (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies