Skip to content

reject trailing data when parsing signed certificate timestamps#15046

Open
dxbjavid wants to merge 1 commit into
pyca:mainfrom
dxbjavid:sct-reject-trailing-data
Open

reject trailing data when parsing signed certificate timestamps#15046
dxbjavid wants to merge 1 commit into
pyca:mainfrom
dxbjavid:sct-reject-trailing-data

Conversation

@dxbjavid

Copy link
Copy Markdown
Contributor

Signed Certificate Timestamps embedded in a certificate are parsed by a small hand-rolled TLS reader rather than the DER machinery. The reader walks the length-prefixed list and then each fixed SCT structure, but it never checks that it reached the end of either, so any bytes left over after the list, or after the final signature field inside an individual SCT entry, were quietly discarded. Since the SCT bytes come straight from an untrusted certificate extension, a malformed encoding with appended padding parsed as a valid SCT, and the leftover bytes still ended up in the stored raw data used for equality and hashing. I noticed it while comparing this reader against the DER and SSH parsers, both of which reject leftover input. The fix verifies each reader is empty once the expected fields have been consumed. I kept it inside parse_scts and added a regression test covering both leftover positions.

Comment thread src/rust/src/x509/sct.rs

// Builds a minimal but well-formed SCT body (version, log id, timestamp,
// empty extensions, hash/signature algorithm and an empty signature).
fn minimal_sct_body() -> Vec<u8> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, unless there's a compelling reason to do otherwise, we prefer to test things from the Python API.

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.

2 participants