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

Add lint to cover TLS BR v2 EKU checks #833

Merged
merged 11 commits into from
Apr 28, 2024

Conversation

vanbroup
Copy link
Contributor

This introduces a new lint called e_sub_cert_eku_check and sets the ineffective date for e_sub_cert_eku_server_auth_client_auth_missing and w_sub_cert_eku_extra_values.

This update only covers subscriber certificates, the lints for CA certificates will also need to be reviewed.

The util.IsServerAuthCert did not consider certificates that attest the CA/Browser Forum Reserved Certificate Policy Identifiers as specified in section 7.1.6.1 of the BRs, but who did not include the serverAuth EKU. This has been addressed to cover the expectations of attesting a policy and to cover all test scenario's of this lint.

These lints are covered by the new `e_sub_cert_eku_check` lint that will lint according to the TLS BR v2 language.
…erAuth

The `util.IsServerAuthCert` did not consider certificates that attest the CA/Browser Forum policy OIDs but do not include the `serverAuth` EKU. This has been addressed and caused some mintor changes in the test corpus.
@vanbroup vanbroup force-pushed the e_sub_cert_eku_check branch from c38b81d to 15db930 Compare April 19, 2024 14:21
}
}

if (len(c.ExtKeyUsage) > 2 && !hasClientAuthEKU) || len(c.UnknownExtKeyUsage) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could set a variable in the default case in the range c.ExtKeyUsage loop and check that.

Choose a reason for hiding this comment

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

I may advocate for keeping a list of of OIDs found during the execution of the lint and cross referencing them at them end against the list of known OIDs.

var known = map[string]struct{}{
	"1.3.6.1.5.5.7.3.1": {},
	"1.3.6.1.5.5.7.3.2": {},
	"1.3.6.1.5.5.7.3.3": {},
	"1.3.6.1.5.5.7.3.4": {},
	"1.3.6.1.5.5.7.3.8": {},
	"1.3.6.1.5.5.7.3.9": {},
	"2.5.29.37.0": {},
	"1.3.6.1.4.1.11129.2.4.4": {},
}

func lint() {
    found := []string
    for _, eku := range c.ExtKeyUsage {
        found = append(found, eku.String()
        ....
        ....
        ....
    }
    for _, eku := range.UnknownExtKeyUsage {
        found = append(found, eku.String()
        ....
        ....
        ....
    }
    for _, oid := range found {
        _, ok := known[oid]
        if !ok {
            return &lint.LintResult{Status: lint.Warn, Details: "any other value than id-kp-serverAuth and id-kp-clientAuth is NOT RECOMMENDED"}
        }
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ExtKeyUsage and UnknownExtKeyUsage are not of the same type:

ExtKeyUsage        []ExtKeyUsage           // Sequence of extended key usages.
UnknownExtKeyUsage []asn1.ObjectIdentifier // Encountered extended key usages unknown to this package.

The lint currently checks for MUST, MUST NOT, MAY, and NOT RECOMMENDED, and returns the corresponding lint status and error.

We can create a map with each EKU and the requirement (i.e., MUST) and lookup the value while ranging over the two EKU lists, but I guess this would be less efficient

Choose a reason for hiding this comment

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

I reckon that this would be an efficiency modifier in the range of nanoseconds (possibly into ms) for each run of the lint. In general, legibility trumps such optimizations since correctness of the lint is paramount.

return &lint.LintResult{Status: lint.Error, Details: "id-kp-serverAuth MUST be present"}
}

if len(c.UnknownExtKeyUsage) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is not needed

}
}

if (len(c.ExtKeyUsage) > 2 && !hasClientAuthEKU) || len(c.UnknownExtKeyUsage) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ExtKeyUsage and UnknownExtKeyUsage are not of the same type:

ExtKeyUsage        []ExtKeyUsage           // Sequence of extended key usages.
UnknownExtKeyUsage []asn1.ObjectIdentifier // Encountered extended key usages unknown to this package.

The lint currently checks for MUST, MUST NOT, MAY, and NOT RECOMMENDED, and returns the corresponding lint status and error.

We can create a map with each EKU and the requirement (i.e., MUST) and lookup the value while ranging over the two EKU lists, but I guess this would be less efficient

@christopher-henderson christopher-henderson merged commit d5a09f8 into zmap:master Apr 28, 2024
4 checks passed
@vanbroup vanbroup deleted the e_sub_cert_eku_check branch April 30, 2024 13:07
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.

4 participants