Skip to content

Add lint to check for certain extensions to have at least 1 element according to RFC 5280#1028

Merged
christopher-henderson merged 6 commits into
zmap:masterfrom
defacto64:ext_cannot_be_empty_seq
Mar 22, 2026
Merged

Add lint to check for certain extensions to have at least 1 element according to RFC 5280#1028
christopher-henderson merged 6 commits into
zmap:masterfrom
defacto64:ext_cannot_be_empty_seq

Conversation

@defacto64

Copy link
Copy Markdown
Contributor

Several standard PKIX extensions, defined in RFC 5280, have an ASN.1 syntax that requires their value to be a SEQUENCE OF... (something) with a minimum length of 1. For instance, in the case of the CertificatePolicies extension, the extension value is defined as follows:

certificatePolicies ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation

...and similarly for several other extensions. This means that, if such an extension is present in the certificate, its value MUST be a sequence that includes at least 1 element. ZLint does not currently perform this check specifically, so I thought it useful to propose this lint to fill the gap. In the test corpus, there are a couple dozen certificates that fail this lint, fortunately quite old. But you never know.

A note on my implementation: in theory, a certificate could contain more than one extension with the aforementioned flaw, so one might consider reporting them all in the error message (details). However, it seems quite unlikely that even a single extension with this flaw would be present in a certificate these days, so it should be acceptable to stop parsing extensions at the first occurrence of the problem.


SequenceOfSomething := []asn1.RawValue{}

for extOid := range targetExtensionsMap {

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.

Very easy to read, thank you!

Comment thread v3/integration/config.json Outdated
@christopher-henderson christopher-henderson merged commit 90f1337 into zmap:master Mar 22, 2026
4 checks passed
LintMetadata: lint.LintMetadata{
Name: "e_ext_cannot_be_empty_sequence",
Description: "Extensions whose value is SEQUENCE SIZE (1..MAX) OF must have at least 1 element",
Citation: "All of RFC 5280",

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 got a chuckle outta me 😆

"Which part?"
"Yes."

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