Skip to content

Reject non-CA peer intermediate certs#1021

Merged
padelsbach merged 2 commits into
wolfSSL:masterfrom
ejohnstown:sf8
Jun 15, 2026
Merged

Reject non-CA peer intermediate certs#1021
padelsbach merged 2 commits into
wolfSSL:masterfrom
ejohnstown:sf8

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor
  • Add CertManIntermediateIsCA: require isCA and, for non-self-signed intermediates that carry a KeyUsage extension, the keyCertSign bit before promoting a cert.
  • Add regression tests: non-CA intermediate is not promoted, and a valid CA intermediate (with and without KeyUsage) still is.

Issue: F-5851

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds stricter rules for promoting peer-supplied intermediate certificates into the cert manager trust store, preventing promotion of non-CA intermediates and adding regression coverage for issue F-5851.

Changes:

  • Introduces CertManIntermediateIsCA() to gate intermediate promotion on BasicConstraints CA=TRUE (and KeyUsage keyCertSign when present).
  • Updates certificate chain verification to avoid trusting non-CA intermediates.
  • Adds unit tests that reproduce the non-CA intermediate promotion attack and validate promotion of legitimate CA intermediates.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
tests/unit.c Adds regression/positive tests that exercise intermediate promotion behavior using forged ECC certificates.
src/certman.c Adds CA-check helper and gates intermediate promotion during chain verification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/certman.c
Comment thread src/certman.c
Comment thread tests/unit.c Outdated
Comment thread tests/unit.c
Comment thread tests/unit.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #1021

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread tests/unit.c
Comment thread src/certman.c
Comment thread tests/unit.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #1021

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/certman.c
- Add CertManIntermediateIsCA: require isCA and, for non-self-signed
  intermediates that carry a KeyUsage extension, the keyCertSign bit
  before promoting a cert.
- Only promote a verified intermediate into the trust store when it is
  actually a CA; otherwise fail with WS_CERT_NO_SIGNER_E.
- Prevents a peer-supplied end-entity cert at an intermediate position
  from being trusted to issue certs for arbitrary SSH principals.
- Gate keyCertSign on ALLOW_INVALID_CERTSIGN and on the KeyUsage
  extension being present, matching wolfSSL's AddCA loader.
- Add regression tests: non-CA intermediate is not promoted, and a
  valid CA intermediate (with and without KeyUsage) still is.

Issue: F-5851
OCSP_NEED_URL meant the cert has no AIA OCSP URL and no
default responder is set, so OCSP cannot run. Treat it as
not-revoked instead of failing the whole verification.

This softens revocation from hard-fail to soft-fail for that case
only. The AIA URL is part of the signed certificate and is not
attacker-strippable, so a malicious peer cannot use this to bypass
an otherwise-enforced OCSP check.
@padelsbach padelsbach merged commit df6e81c into wolfSSL:master Jun 15, 2026
125 checks passed
@ejohnstown ejohnstown deleted the sf8 branch June 15, 2026 23:54
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.

5 participants