Repository navigation
Merged
Conversation
…uncated certificate fails to parse (#1056) Root cause: der_read_tl (lib/std/crypto/x509.w) checked that a tag and its length bytes fit buf_len, never that the content they claim does. A certificate cut inside its trailing signature parsed with rc=1 and a signature range 251 bytes past its 520-byte buffer, and every reader of the parsed offsets (the TBS hash, the RSA and ECDSA reads, oid_match) read past it. Content longer than the rest of the buffer (or a long-form length that overflows) is an error, content_start = -1, in both length forms; every der_read_tl and der_skip caller already fails closed on it. No regression test: x509_parse is private to std and its only caller, std.tls, reads the parsed key point within its 16640-byte record buffer, so no observable program behavior separates the cases; the audit's openssl-generated certificate cut at 520 bytes is what the bound answers.
ehartford
marked this pull request as ready for review
October 25, 2026 23:05
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.
Root cause: der_read_tl (lib/std/crypto/x509.w) checked that a tag and its
length bytes fit buf_len, never that the content they claim does. A
certificate cut inside its trailing signature parsed with rc=1 and a
signature range 251 bytes past its 520-byte buffer, and every reader of the
parsed offsets (the TBS hash, the RSA and ECDSA reads, oid_match) read past
it.
Content longer than the rest of the buffer (or a long-form length that
overflows) is an error, content_start = -1, in both length forms; every
der_read_tl and der_skip caller already fails closed on it.
No regression test: x509_parse is private to std and its only caller,
std.tls, reads the parsed key point within its 16640-byte record buffer, so
no observable program behavior separates the cases; the audit's
openssl-generated certificate cut at 520 bytes is what the bound answers.
Closes #1056