Skip to content

Enforce signature length and input bounds across note verifiers - #301

Merged
mhutchinson merged 4 commits into
transparency-dev:mainfrom
mhutchinson:rfc6962-sig-bounds
Nov 17, 2026
Merged

mhutchinson merged 4 commits into
transparency-dev:mainfrom
mhutchinson:rfc6962-sig-bounds

Conversation

@mhutchinson

@mhutchinson mhutchinson commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • RFC 6962 signature bounds (note/note_rfc6962.go): Require RFC 6962 note signatures to contain both the 8-byte timestamp and the 4-byte TLS DigitallySigned header (hAlg, sAlg, and 2-byte sigLen) before reading them in verifyRFC6962 and RFC6962STHTimestamp, preventing an index out of range panic when verifying 8..11 byte signature payloads after the 4-byte key hash (or RFC6962STHToCheckpoint inputs with 0..3 byte tree_head_signature).
  • RFC 6962 millisecond timestamp conversion (note/note_rfc6962.go): Use time.UnixMilli in RFC6962STHTimestamp instead of time.Unix(0, int64(ms*1000)) (which interpreted milliseconds as microseconds).
  • RFC 6962 verifier name validation (note/note_rfc6962.go): Validate the normalized log name in RFC6962VerifierString after stripping http(s):// and trailing / so bare scheme URLs (e.g. https://) are rejected instead of producing an empty-name vkey.
  • Cosignature/v1 timestamp & length bounds (note/note_cosigv1.go): Enforce the C2SP tlog-cosignature timestamp upper bound (<= 2^63 - 1) in formatEd25519CosignatureV1 (matching formatMLDSACosignatureV1 and CosignatureTimestamp), and require exact Ed25519 or ML-DSA-44 cosignature lengths in CosignatureTimestamp.
  • ECDSA verifier key name validation (note/note_verifier.go): Validate isValidName(parts[0]) in NewECDSAVerifier to match all other verifier constructors in note.

Thanks to Roberto Locatelli (@robertolocatelli81-dev) for reporting the RFC 6962 signature bounds and timestamp conversion issues.

@mhutchinson
mhutchinson requested a review from a team as a code owner November 16, 2026 15:19
@mhutchinson
mhutchinson requested a review from phbnf November 16, 2026 15:19
@codecov-commenter

codecov-commenter commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.46%. Comparing base (fa00c16) to head (c5a0710).
⚠️ Report is 208 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #301      +/-   ##
==========================================
+ Coverage   82.57%   92.46%   +9.88%     
==========================================
  Files           5       10       +5     
  Lines         241     1101     +860     
==========================================
+ Hits          199     1018     +819     
- Misses         30       83      +53     
+ Partials       12        0      -12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mhutchinson
mhutchinson requested a review from AlCutter November 16, 2026 15:35
- Require RFC 6962 note signatures to contain the 8-byte timestamp and
  4-byte TLS DigitallySigned header (hash algorithm, signature algorithm,
  and 2-byte signature length) before reading them in verifyRFC6962 and
  RFC6962STHTimestamp, preventing an index-out-of-range panic on 8..11
  byte signature payloads.
- Validate the normalized log name in RFC6962VerifierString after
  stripping the URL scheme and trailing slash so bare scheme URLs (e.g.
  "https://") are rejected.
- Enforce the C2SP tlog-cosignature timestamp bound (<= 2^63-1) in
  formatEd25519CosignatureV1 and require exact Ed25519/ML-DSA-44
  cosignature lengths in CosignatureTimestamp.
- Validate key names with isValidName in NewECDSAVerifier.

Thanks to Roberto Locatelli (@robertolocatelli81-dev) for reporting the
RFC 6962 signature bounds issue.
@robertolocatelli81-dev

Copy link
Copy Markdown

Thank you, @mhutchinson, for the fix and for the credit. I ran the reproducer from the report against 3ad2729: the inputs that panicked on main (255e483), nine cases through the public API, now return errors with no panic.

One separate point, not a security issue, in case it is useful: RFC6962STHTimestamp still returns time.Unix(0, int64(ms*1000)). That reads the RFC 6962 millisecond timestamp as microseconds, so an STH from 2026-11-15T00:00Z comes back as a date in January 1970. time.UnixMilli(int64(ms)) would match the comment above it. The existing test in note_rfc6962_test.go uses the same formula, so it does not catch this. I am happy to open an issue or a small PR, whichever you prefer.

Use time.UnixMilli instead of time.Unix(0, int64(ms*1000)), which
interpreted the millisecond STH timestamp as microseconds.

Thanks to Roberto Locatelli (@robertolocatelli81-dev) for reporting this
issue.
Comment thread note/note_cosigv1.go Resolved
Comment thread note/note_rfc6962.go Resolved
Comment thread note/note_rfc6962.go Resolved
Comment thread note/note_rfc6962.go Resolved
Comment thread note/note_rfc6962.go Resolved
Comment thread note/note_rfc6962.go Resolved
@AlCutter

Copy link
Copy Markdown
Collaborator

TBH, we should just remove the RFC6962 support: it's clearly not been used in anger (or the timestamp issue would have been discovered), and is essentially obsolete now anyway.

I'll note that formats is still a v0 repo, so perfectly fine to kill it/make the timestamp magnitude change.

- Define named constants for the 4-byte TLS 1.2 DigitallySigned header
  (tlsHashAlgSize + tlsSigAlgSize + tlsSigLenSize) with spec references.
- Reject timestamps > math.MaxInt64 in RFC6962STHTimestamp and
  verifyRFC6962 to prevent uint64-to-int64 wraparound.
- Deduplicate len(r) in CosignatureTimestamp.
@mhutchinson
mhutchinson merged commit ac46c38 into transparency-dev:main Nov 17, 2026
14 checks passed
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.

5 participants