Skip to content

Add lint to detect UTF8 Replacement Character in the Subject DN (for any kind of certificates) - #1070

Merged
christopher-henderson merged 8 commits into
zmap:masterfrom
defacto64:utf8_replac_char_in_subj
Aug 9, 2026
Merged

Add lint to detect UTF8 Replacement Character in the Subject DN (for any kind of certificates)#1070
christopher-henderson merged 8 commits into
zmap:masterfrom
defacto64:utf8_replac_char_in_subj

Conversation

@defacto64

Copy link
Copy Markdown
Contributor

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).

@christopher-henderson christopher-henderson left a comment

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.

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)

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.

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)

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.

Same as above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, done.

@christopher-henderson
christopher-henderson merged commit e918cd9 into zmap:master Aug 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants