Skip to content

fix: enforce pathLenConstraint regardless of keyUsage extension - #1142

Closed
eddieran wants to merge 1 commit into
digitalbazaar:mainfrom
eddieran:fix/pathlen-constraint
Closed

eddieran wants to merge 1 commit into
digitalbazaar:mainfrom
eddieran:fix/pathlen-constraint

Conversation

@eddieran

Copy link
Copy Markdown
Contributor

Summary

Fixes GHSA-h8mc-2r26-8398. This replaces #1141.

The pathLenConstraint check in verifyCertificateChain was gated on the keyUsage extension being present (keyUsageExt !== null). When a CA certificate omitted the keyUsage extension but included basicConstraints with a pathLenConstraint, the constraint was silently skipped — allowing certificate chains that exceeded the maximum permitted intermediate CA depth.

Changes

In lib/x509.js, the condition guarding the pathLenConstraint enforcement now checks for bcExt !== null instead of keyUsageExt !== null, so the constraint is enforced whenever basicConstraints is present, regardless of whether keyUsage is also present.

The pathLenConstraint check in the certificate chain validation was
gated on the keyUsage extension being present. When a CA certificate
omitted the keyUsage extension but included basicConstraints with a
pathLenConstraint, the constraint was silently skipped, allowing
chains that exceeded the maximum permitted depth.

Remove the keyUsage guard so pathLenConstraint is enforced whenever
basicConstraints is present.
davidlehn added a commit that referenced this pull request Oct 27, 2026
- [x509] Enforce `basicConstraints` `pathLenConstraint` in chain
  verification for CA certificates without a `keyUsage` extension.
- Based on the fix in PR #1142 (eddieran).
- Address GHSA-h46v-rmh6-fq4f:
  - GHSA-h46v-rmh6-fq4f
- Add submitted PoC.
- Add tests.

Co-authored-by: ran <edding.suree@gmail.com>
@davidlehn

Copy link
Copy Markdown
Member

Thank you. The fix in node-forge 1.4.1 enforces pathLenConstraint without keyUsage as this PR does, with tests added. The commit lists you as co-author, and you're credited in GHSA-h46v-rmh6-fq4f. Closing, as the fix landed in a combined security release.

@davidlehn davidlehn closed this Oct 27, 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.

2 participants