fix: prevent CSR extensions from overriding CA-managed key usage in c…#1436
Merged
mitch292 merged 1 commit intoApr 17, 2026
Merged
Conversation
…opy_extensions When copy_extensions is enabled, CSR-provided X.509v3 extensions are copied into the certificate template's ExtraExtensions. Go's x509.CreateCertificate gives ExtraExtensions precedence over struct fields for the same OID, which means an attacker-crafted CSR could inject KeyUsage, ExtKeyUsage, and other security-critical extensions that silently override the signing profile's intended restrictions. Add a blocklist of CA-managed extension OIDs (KeyUsage, ExtKeyUsage, BasicConstraints, SKI, AKI, SAN, Name Constraints, CRL Distribution Points, Authority Info Access, Certificate Policies, Issuer Alt Name) that are never copied from CSR extensions. These extensions are authoritatively set by the CA's signing profile via FillTemplate and must not be overridable by a CSR submitter. Non-standard/private-use extensions continue to be copied through when copy_extensions is enabled.
jvaughan-cloudflare
approved these changes
Apr 16, 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.
…opy_extensions
When copy_extensions is enabled, CSR-provided X.509v3 extensions are copied into the certificate template's ExtraExtensions. Go's x509.CreateCertificate gives ExtraExtensions precedence over struct fields for the same OID, which means an attacker-crafted CSR could inject KeyUsage, ExtKeyUsage, and other security-critical extensions that silently override the signing profile's intended restrictions.
Add a blocklist of CA-managed extension OIDs (KeyUsage, ExtKeyUsage, BasicConstraints, SKI, AKI, SAN, Name Constraints, CRL Distribution Points, Authority Info Access, Certificate Policies, Issuer Alt Name) that are never copied from CSR extensions. These extensions are authoritatively set by the CA's signing profile via FillTemplate and must not be overridable by a CSR submitter.
Non-standard/private-use extensions continue to be copied through when copy_extensions is enabled.