Repository navigation
Enforce signature length and input bounds across note verifiers - #301
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
- 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.
d3d4b45 to
3ad2729
Compare
|
Thank you, @mhutchinson, for the fix and for the credit. I ran the reproducer from the report against One separate point, not a security issue, in case it is useful: |
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.
|
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 |
- 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.
Summary
note/note_rfc6962.go): Require RFC 6962 note signatures to contain both the 8-byte timestamp and the 4-byte TLSDigitallySignedheader (hAlg,sAlg, and 2-bytesigLen) before reading them inverifyRFC6962andRFC6962STHTimestamp, preventing anindex out of rangepanic when verifying 8..11 byte signature payloads after the 4-byte key hash (orRFC6962STHToCheckpointinputs with 0..3 bytetree_head_signature).note/note_rfc6962.go): Usetime.UnixMilliinRFC6962STHTimestampinstead oftime.Unix(0, int64(ms*1000))(which interpreted milliseconds as microseconds).note/note_rfc6962.go): Validate the normalized log name inRFC6962VerifierStringafter strippinghttp(s)://and trailing/so bare scheme URLs (e.g.https://) are rejected instead of producing an empty-name vkey.note/note_cosigv1.go): Enforce the C2SPtlog-cosignaturetimestamp upper bound (<= 2^63 - 1) informatEd25519CosignatureV1(matchingformatMLDSACosignatureV1andCosignatureTimestamp), and require exact Ed25519 or ML-DSA-44 cosignature lengths inCosignatureTimestamp.note/note_verifier.go): ValidateisValidName(parts[0])inNewECDSAVerifierto match all other verifier constructors innote.Thanks to Roberto Locatelli (@robertolocatelli81-dev) for reporting the RFC 6962 signature bounds and timestamp conversion issues.