Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce lint for inconsistent KU and EKU #708

Conversation

vanbroup
Copy link
Contributor

This updated lint has been created and reviewed by several members of the @pkic and its addressing the issues with e_key_usage_and_extended_key_usage_inconsistent introduced in #497 (and refined in #528), see also #553 and #556.

We have tried to provide sufficient details in the error for debugging purposes:

{"e_key_usage_and_extended_key_usage_inconsistent":{"result":"error","details":"KeyUsage [DigitalSignature KeyEncipherment] (00000101) inconsistent with ExtKeyUsage serverAuth"}}

The lint has been tested against all valid certificates in yeti2024, most of yeti2023, and hundreds of millions in argon2023 without issues.

In the test corpus we identified 29960 certificates with an invalid combination:

Fingerprint Count
KeyUsage [DataEncipherment DigitalSignature KeyEncipherment] (00001101) inconsistent with multiple purpose ExtKeyUsage [clientAuth serverAuth] 28052
KeyUsage [ContentCommitment DigitalSignature KeyEncipherment] (00000111) inconsistent with multiple purpose ExtKeyUsage [clientAuth serverAuth] 723
KeyUsage [DigitalSignature KeyEncipherment] (00000101) inconsistent with ExtKeyUsage clientAuth 443
KeyUsage [DataEncipherment DigitalSignature KeyEncipherment] (00001101) inconsistent with multiple purpose ExtKeyUsage [clientAuth emailProtection] 327
KeyUsage [DataEncipherment DigitalSignature KeyEncipherment] (00001101) inconsistent with ExtKeyUsage serverAuth 233
KeyUsage [ContentCommitment DigitalSignature KeyEncipherment] (00000111) inconsistent with ExtKeyUsage serverAuth 88
KeyUsage [DataEncipherment DigitalSignature KeyAgreement KeyEncipherment] (00011101) inconsistent with multiple purpose ExtKeyUsage [clientAuth serverAuth] 55
KeyUsage [DataEncipherment DigitalSignature KeyEncipherment] (00001101) inconsistent with multiple purpose ExtKeyUsage [clientAuth emailProtection serverAuth] 9
KeyUsage [ContentCommitment DataEncipherment DigitalSignature KeyEncipherment] (00001111) inconsistent with multiple purpose ExtKeyUsage [clientAuth emailProtection] 7
KeyUsage [ContentCommitment DataEncipherment DigitalSignature KeyEncipherment] (00001111) inconsistent with multiple purpose ExtKeyUsage [clientAuth serverAuth] 7
KeyUsage [DigitalSignature KeyAgreement KeyEncipherment] (00010101) inconsistent with ExtKeyUsage serverAuth 4
KeyUsage [ContentCommitment DataEncipherment DigitalSignature KeyAgreement KeyEncipherment] (00011111) inconsistent with multiple purpose ExtKeyUsage [clientAuth emailProtection] 3
KeyUsage [ContentCommitment DataEncipherment DigitalSignature KeyEncipherment] (00001111) inconsistent with multiple purpose ExtKeyUsage [emailProtection serverAuth] 3
KeyUsage [ContentCommitment DigitalSignature] (00000011) inconsistent with multiple purpose ExtKeyUsage [clientAuth serverAuth] 2
KeyUsage [ContentCommitment DataEncipherment DigitalSignature KeyAgreement KeyEncipherment] (00011111) inconsistent with ExtKeyUsage clientAuth 1
KeyUsage [ContentCommitment DigitalSignature KeyEncipherment] (00000111) inconsistent with ExtKeyUsage clientAuth 1
KeyUsage [ContentCommitment DataEncipherment DigitalSignature KeyEncipherment] (00001111) inconsistent with ExtKeyUsage serverAuth 1
KeyUsage [ContentCommitment DataEncipherment DigitalSignature KeyAgreement KeyEncipherment] (00011111) inconsistent with multiple purpose ExtKeyUsage [clientAuth serverAuth] 1
Grand Total 29960

CC: @sandorszoke

@vanbroup
Copy link
Contributor Author

@christopher-henderson any comments on this PR?

@christopher-henderson
Copy link
Member

christopher-henderson commented Apr 23, 2023

@vanbroup thank you for your patience. I have been under some extreme duress outside of ZLint in the past month. This, coupled with not getting a push notification on this PR, left me somewhat derelict on the issue.

There are a lot of corrections to the expectations in the test corpus, which are typically a fair deal of work on me to independently verify vis-a-vis governing requirements. I will likely start there as the code itself is rarely a blocking issue.

Copy link
Member

@christopher-henderson christopher-henderson left a comment

Choose a reason for hiding this comment

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

Thank @vanbroup !

It seems that the most common breach is caused by attempts to double-bill client certificates. From what I've smoke checked so far that makes sense. Plus, it makes sense in general. I have some experience building infrastructure that relies on client certificates for techniques such as mTLS and it is pretty common for implementers to let the rules fly out the door when doing so.

Aside from that, my only sincere concern is the illegibility of multiPurpose. The boolean expressions involved in this requirement has a history of causing confusion, as-is. So I have a sincere interest in the surrounding logic being as clear as possible, both for the purposes of immediate verification as well as ensuring future generations are not left reverse engineering a difficult function while trying to troubleshoot an already difficult requirement.

v3/util/eku.go Show resolved Hide resolved
for _, extKeyUsage := range c.ExtKeyUsage {
var i int
if _, ok := eku[extKeyUsage]; !ok {
return &lint.LintResult{Status: lint.Pass}

Choose a reason for hiding this comment

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

Should this be continue rather than return? It seems slightly off to succeed fast if we hit an EKU we're not familiar with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we are not familiar with one of the EKU's it will be impossible to come to a conclusion, as the KU might be authorized by this EKU.

@vanbroup
Copy link
Contributor Author

Thanks for the review, I have not forgotten this but need to free some time to address the comments.

@vanbroup vanbroup force-pushed the e_key_usage_and_extended_key_usage_inconsistent branch from 5d1c794 to af55782 Compare August 21, 2023 16:25
@vanbroup
Copy link
Contributor Author

@christopher-henderson sorry for the delay, I think that your comments have been addressed

Copy link
Member

@christopher-henderson christopher-henderson left a comment

Choose a reason for hiding this comment

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

Thank you @vanbroup! Even with small changes, this is much easier to reason through than I recall it being (it is, indeed, a slightly tricky algorithm).

@christopher-henderson christopher-henderson merged commit 71d5e4b into zmap:master Aug 27, 2023
4 checks passed
@chrisbn
Copy link

chrisbn commented Jan 3, 2024

@vanbroup dataEncipherment is currently permitted by the TLS BRs for RSA keys (7.1.2.7.11 Subscriber Certificate Key Usage) but rejected by this lint. Although it's highlighted that this KU is Pending Prohibition, I'm not sure if this was intentional?

Perhaps the TLS BRs are overriding RFC5280 on purpose, or it's an error. Either way, the lint will block a currently permitted value by the BRs.

@vanbroup
Copy link
Contributor Author

vanbroup commented Jan 7, 2024

The lint follows RFC 5280 and by checking against the major CT logs we tried to identify any inconsistent implementations, we did not explicitly check the CA/Browser Forum requirements.

We checked this lint to hundreds of millions of certificates in the CT log's without finding any issues, do you know how often this happens across the ecosystem or are you running into this problem in a new certificate profile?

@christopher-henderson
Copy link
Member

@chrisbn hmmm...it's unfortunate that BRs and RFC5280 seem to be disagreeing here.

With regards to getting infra working again, there may be several options. The not-so-great option is to utilize zlint -excludeSources=RFC5280 cert.pem in some way (unfortunately, we do not have anything setup that can skip individual lints...this may be a nice feature enhancement).

Alternatively, consumers of the CLI tool can choose to parse out the printed JSON and decide if a failure in this lint is ok-or-not.

Consumers of the library can similarly choose whether-or-not they prefer the BRs interpretation over 5280.

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.

None yet

3 participants