Add lint to detect UTF8 Replacement Character in the Subject DN (for any kind of certificates) - #1070
Merged
christopher-henderson merged 8 commits intoAug 9, 2026
Conversation
christopher-henderson
requested changes
Aug 2, 2026
christopher-henderson
left a comment
Member
There was a problem hiding this comment.
This is a cool lint! I only hold exception to the panics.
|
|
||
| var rdnSeq []asn1.RawValue // RDNSequence ::= SEQUENCE OF RDN | ||
| if _, err := asn1.Unmarshal(c.RawSubject, &rdnSeq); err != nil { | ||
| panic(err) |
Member
There was a problem hiding this comment.
Panics from lints are caught-and-recovered. However, if you don't mind, I believe that should prefer propagating a lint.Fatal with the Detail being the error.
| for _, rdn := range rdnSeq { | ||
| var atvs []attributeTypeAndValue // RDN ::= SET OF AttributeTypeAndValue | ||
| if _, err := asn1.UnmarshalWithParams(rdn.FullBytes, &atvs, "set"); err != nil { | ||
| panic(err) |
christopher-henderson
approved these changes
Aug 9, 2026
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.
Inspired by a recent incident, I put together this lint that checks for the UTF8 Replacement Character (Unicode 0xFFFD) in any Subject attribute, which signals that something went wrong when the CA assigned a value to that attribute. For example, a first name like Müller might end up in the givenName as "M\U+FFFDller" due to some Latin-1 to UTF8 conversion error. There are a couple of occurrences in the test corpus, in very old certificates, but there are likely more in the wild.
This lint scans all subject attributes that are actually tagged as UTF8String, regardless of whether this tag is legit for each particular attribute (it's not this lint's job to check that).