fix(pairing): enforce TXT record value formats#94
Open
kirollosnct wants to merge 2 commits into
Open
Conversation
…on 5.4
Validate() only checked the enum fields (alg, parType, type, trustCurve).
The hexadecimal values were accepted in any case and length: forPar was
matched case-insensitively, trustPar was never validated at all, and
trustNonce/digest only had to survive a lenient hex decode.
This matters because the shippairing digest is calculated over the TXT
values as announced: a record whose values are malformed in a way that
survives lenient parsing — lowercase hex, wrong-length nonce — carries a
digest that still verifies, so format validation is the only gate that
can reject it. TC_SPS_TXT_009 of the pairing test spec V1.0.0 tests
exactly this (digest computed over already-malformed values) and its
final release extends the trustNonce matrix with valid-hex wrong-length
errors (E14/E15) that a hex decode cannot catch.
Enforce the formats of pairing spec section 5.4, Table 1 in Validate():
forPar, trustPar and digest must be 64 uppercase hexadecimal digits,
trustNonce 32; forId and trustId must be non-empty; txtvers must be "1".
Validate() runs at the mDNS discovery gate, in the listener and on our
own announcements, so every evaluation path is covered by one change.
Test fixtures with placeholder values ("trust-1-par", short nonces) are
updated to conforming formats; a new matrix test mirrors every row of
TC_SPS_TXT_009 Table 5 with the error types of test spec section 2.8.9.
Slicing s.Fingerprint[:8] panics when the fingerprint is shorter than 8 characters. Only truncate for a valid 64-character (hex-encoded SHA-256) fingerprint, and add a unit test covering the short/invalid and valid cases.
kirollosnct
marked this pull request as ready for review
July 19, 2026 11:01
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.
Validate() only checked the enum fields (alg, parType, type, trustCurve). The hexadecimal values were accepted in any case and length: forPar was matched case-insensitively, trustPar was never validated at all, and trustNonce/digest only had to survive a lenient hex decode.
This matters because the shippairing digest is calculated over the TXT values as announced: a record whose values are malformed in a way that survives lenient parsing — lowercase hex, wrong-length nonce — carries a digest that still verifies, so format validation is the only gate that can reject it. TC_SPS_TXT_009 of the pairing test spec V1.0.0 tests exactly this (digest computed over already-malformed values) and its final release extends the trustNonce matrix with valid-hex wrong-length errors (E14/E15) that a hex decode cannot catch.
Enforce the formats of pairing spec section 5.4, Table 1 in Validate(): forPar, trustPar and digest must be 64 uppercase hexadecimal digits, trustNonce 32; forId and trustId must be non-empty; txtvers must be "1". Validate() runs at the mDNS discovery gate, in the listener and on our own announcements, so every evaluation path is covered by one change.
Test fixtures with placeholder values ("trust-1-par", short nonces) are updated to conforming formats; a new matrix test mirrors every row of TC_SPS_TXT_009 Table 5 with the error types of test spec section 2.8.9.