Skip to content

Raise ValueError when an SCT list is too large to encode - #15658

Merged
reaperhulk merged 5 commits into
mainfrom
claude/magical-ride-0mfmq7-sct-length
Sep 19, 2026
Merged

reaperhulk merged 5 commits into
mainfrom
claude/magical-ride-0mfmq7-sct-length

Conversation

@alex

@alex alex commented Sep 17, 2026

Copy link
Copy Markdown
Member

encode_scts wrote the RFC 6962 SignedCertificateTimestampList length prefix with a truncating length as u16 cast. An extension whose serialized SCTs total more than 65535 bytes (roughly 550 typical SCTs) was therefore silently encoded with a length wrapped modulo 65536: public_bytes() and CertificateBuilder.sign() succeeded, but the result is rejected by our own parser (ValueError: Invalid SCT length) and by OpenSSL.

A list that size has no valid encoding (sct_list<1..2^16-1>), so the list length now goes through u16::try_from and raises ValueError. The per-entry length is bounded by that check and uses try_into().unwrap(). The regression test repeats the SCT from badssl-sct.pem 1000 times and checks that public_bytes() raises for both extension classes.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-H08T92Y2.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HVLJ4Wp5FraEfACovDdSN6

encode_scts wrote the RFC 6962 list-length prefix with a truncating
`as u16` cast, so an extension whose serialized SCTs totalled more than
65535 bytes was silently encoded with a wrapped length. The result is
rejected by our own parser and by OpenSSL. Use u16::try_from for both
the list and per-entry lengths and raise ValueError instead.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-H08T92Y2.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVLJ4Wp5FraEfACovDdSN6
Comment thread tests/x509/test_x509_ext.py Outdated
Comment thread tests/x509/test_x509_ext.py Outdated
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVLJ4Wp5FraEfACovDdSN6
Comment thread CHANGELOG.rst Outdated
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVLJ4Wp5FraEfACovDdSN6
The total-length check already bounds every entry, and the branch could
never be hit, which failed the 100% coverage requirement.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVLJ4Wp5FraEfACovDdSN6
Comment thread src/rust/src/x509/extensions.rs Outdated
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVLJ4Wp5FraEfACovDdSN6
@reaperhulk
reaperhulk merged commit fd822db into main Sep 19, 2026
70 checks passed
@reaperhulk
reaperhulk deleted the claude/magical-ride-0mfmq7-sct-length branch September 19, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants