Skip to content

fix: enforce pathLenConstraint regardless of keyUsage extension#1141

Closed
eddieran wants to merge 1 commit intodigitalbazaar:mainfrom
eddieran:fix/pathlen-constraint-bypass
Closed

fix: enforce pathLenConstraint regardless of keyUsage extension#1141
eddieran wants to merge 1 commit intodigitalbazaar:mainfrom
eddieran:fix/pathlen-constraint-bypass

Conversation

@eddieran
Copy link
Copy Markdown

Summary

The pathLenConstraint check in _verifyCertificateChain (lib/x509.js) was gated on keyUsageExt !== null, allowing a CA certificate without the keyUsage extension to bypass path length constraints entirely. OpenSSL correctly rejects the same chain.

This changes the condition from keyUsageExt !== null to bcExt !== null, ensuring pathLenConstraint from basicConstraints is always enforced on CA certificates.

Security Advisory

Ref: GHSA-h8mc-2r26-8398

Details

Before (vulnerable):

if(error === null && keyUsageExt !== null &&
  'pathLenConstraint' in bcExt) {

A CA cert that omits keyUsage but sets basicConstraints.pathLenConstraint = 0 can still issue intermediate CA certs, violating the path length limit.

After (fixed):

if(error === null && bcExt !== null &&
  'pathLenConstraint' in bcExt) {

The pathLenConstraint is now checked whenever basicConstraints is present, regardless of whether keyUsage exists.

The pathLenConstraint check in the certificate chain verification was
gated on keyUsageExt !== null, meaning a CA certificate without the
keyUsage extension could bypass path length constraints. This changes
the condition to check bcExt !== null instead, ensuring
pathLenConstraint from basicConstraints is always enforced on CA
certificates regardless of whether keyUsage is present.

Ref: GHSA-h8mc-2r26-8398
@eddieran eddieran closed this by deleting the head repository Apr 11, 2026
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.

1 participant