Reject CONTEXT-SPECIFIC tag class in serial number parser#249
Open
afldl wants to merge 7 commits into
Open
Conversation
Collaborator
|
You can ignore the clippy & audit failings in CI. I believe both are going to be fixed by #223 Please just keep the commits related to the issue/fix. |
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.
Problem
parse_serial()checks that the tag number equalsTag::Integerbut does not verify the tag class. A CONTEXT-SPECIFIC[2]tag byte (0x82) has the same tag number as UNIVERSAL INTEGER (0x02) but a different class per X.690 §8.1.2. This makes the parser accept certificates with mismatched tag classes.13 of 14 tested X.509 implementations reject this mutation. Only x509-parser and mbedTLS accept. See #248.
Fix
Check
any.class() == Class::Universalbefore comparing the tag number.Test
Single-byte PoC: offset 0x0d of a standard RSA-2048 self-signed cert, tag byte changed from
0x02to0x82.Test added:
test_serial_rejects_context_specific_tag. All 66 existing tests pass.