Skip to content

fix(pairing): enforce TXT record value formats#94

Open
kirollosnct wants to merge 2 commits into
devfrom
fix/pairing-txt-format-validation
Open

fix(pairing): enforce TXT record value formats#94
kirollosnct wants to merge 2 commits into
devfrom
fix/pairing-txt-format-validation

Conversation

@kirollosnct

Copy link
Copy Markdown
Member

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.

…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.
@coveralls

coveralls commented Jul 19, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 92.847% (-0.1%) from 92.972% — fix/pairing-txt-format-validation into dev

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
kirollosnct marked this pull request as ready for review July 19, 2026 11:01
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