Repository navigation
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
Pending signers and restored caches can bypass issuer EKU checks, and repeated checks can invalidate certificate-specific callback overrides.
3 open issues
What changed in this PR
This PR extends TLS issuer Extended Key Usage checks to CAs loaded in the CertManager, aiming to make validation independent of which intermediates the peer sends.
Changes:
- Records EKU extension presence on cached signers.
- Walks issuer ancestors to enforce the TLS purpose while exempting self-signed trust anchors.
- Adds leaf-only chain tests for server/client authentication, callback overrides and trust-anchor handling.
| File | Description |
|---|---|
wolfssl/wolfcrypt/asn.h |
Adds signer EKU presence state and declares the shared issuer lookup. |
wolfcrypt/src/asn.c |
Populates the new state and exposes the existing ancestor lookup. |
tests/api/test_ssl_cert.c |
Extends the handshake harness and adds cached-issuer test cases. |
src/internal.c |
Adds issuer-chain EKU validation during peer certificate processing. |
Review effort: Balanced
390159a to
a1cb314
Compare
|
retest this please |
1 similar comment
|
retest this please |
a1cb314 to
e3b30a9
Compare
e3b30a9 to
b8b3171
Compare
|
Rebased onto current master. The review threads are answered. The checks passed. |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11873
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Coverage: 5 of 5 in-scope changed file(s) opened by the reviewer
Findings: 5
5 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Max
9d1f092 to
5e3af6e
Compare
|
The tiny TLS compile failure is fixed in 5e3af6e. The branch is one commit, rebased onto 3fd873c.
The earlier review threads stay answered on the previous commit. The cross-library jobs failed in |
There was a problem hiding this comment.
🟡 Changes recommended
Critical gaps in deferred issuer-error handling, certificate-specific callback waivers, and cached-chain issuer matching can bypass certificate purpose restrictions.
3 open issues
3 resolved since last review
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11873
Scan targets checked: wolfssl-src, wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 3 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_ssl_cert.c, wolfssl/internal.h
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
A CA loaded into the certificate manager can carry an Extended Key Usage that does not allow it to issue. The issuer walk reports that purpose error. A verify callback can accept it for that certificate. The waiver matches the subject name, the subject key id and the public key, so a different certificate that reuses the key is not waived. The purpose error stays out of the leaf result until the leaf checks have run, so a hostname mismatch or a key-size check cannot hide it. A self-signed user CA stays the trust anchor. The waiver list is omitted from builds with no certificates. Those builds do not define SIGNER_DIGEST_SIZE or KEYID_SIZE.
5e3af6e to
bdefd80
Compare
|
The four review notes are in bdefd80. The branch is one commit, rebased onto current master.
|
There was a problem hiding this comment.
🟡 Changes recommended
With DER retention disabled, the waiver can incorrectly suppress a distinct pinned issuer’s certificate error, and the ancestor-only regression fails when IGNORE_NAME_CONSTRAINTS is enabled.
2 open issues
3 resolved since last review
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11873
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Coverage: 3 of 4 in-scope changed file(s) opened by the reviewer; not opened: wolfssl/internal.h
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
CA_TYPE parsing leaves selfSigned clear for that root, and the issuer walk was rejecting it. The waiver fingerprint is compared whenever the signer still holds the certificate.
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because trust-anchor recognition under IGNORE_NAME_CONSTRAINTS can incorrectly reject certificates issued directly by trusted roots.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11873
Scan targets checked: wolfssl-src, wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: wolfssl/internal.h
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
| return 0; | ||
| if (ca->selfSigned) | ||
| return 1; | ||
| #if !defined(NO_SKID) && !defined(IGNORE_NAME_CONSTRAINTS) |
There was a problem hiding this comment.
Trust anchor exemption for AKID==SKID roots compiled out under IGNORE_NAME_CONSTRAINTS / NO_SKID · Preprocessor-conditional security bypass
ParseCertRelative leaves selfSigned clear for a CA_TYPE root whose AKID equals its SKID, and the only fallback that marks it as an anchor is compiled out with IGNORE_NAME_CONSTRAINTS or NO_SKID. In those builds, CheckSignerExtKeyUsage checks the root's own Extended Key Usage, so a leaf issued directly by a root whose Extended Key Usage leaves out the TLS purpose now fails with EXTKEYUSE_AUTH_E.
Suggested fix: Give Signer an anchor marker that does not depend on name-constraint fields, or check the self-signature for this case, so the anchor exemption holds in every build configuration.
Basis: RFC 5280 section 6.1.1(d): trust anchor information is an input to path validation, and the trust anchor's own certificate is not itself validated.
Related known findings (similar but distinct; listed for context, not part of this finding)
- Earlier finding on this pull request: (1) File/function: same function, SignerIsTrustAnchor in src/internal.c, and the same EKU walk in CheckSignerExtKeyUsage. (2) Operation: both are a false EXTKEYUSE_AUTH_E rejection, because the walk applies the purpose check to an AKID==SKID root that has selfSigned=0. (3) Root cause: -7 is the missing anchor exemption itself, which b350882 addressed with a fallback. The candidate says that fallback sits under
#if !defined(NO_SKID) && !defined(IGNORE_NAME_CONSTRAINTS), so builds with either


Description
ProcessPeerCerts()checks the Extended Key Usage of CA certificates against the TLS purpose (serverAuthwhen verifying a server,clientAuthwhen verifying a client), but only for CAs the peer sends in its Certificate message. When the peer sends only its leaf and the issuing CA is already loaded in the CertManager, that CA's Extended Key Usage is not checked. The same chain is therefore rejected withEXTKEYUSE_AUTH_Ewhen the intermediate is sent and accepted when it is omitted.This change makes the result independent of which CAs the peer sends:
Signergains anextExtKeyUsageSetbit, set byFillSigner(), so an absent extension can be told apart from one that grants none of the known purposes.CheckSignerExtKeyUsage()walks from the leaf's issuer up to the self-signed trust anchor and applies the TLS purpose to every CA on the way. The trust anchor stays exempt, as inCheckChainCAExtKeyUsage(). The walk reuses the name constraints ancestor lookup, now exported aswolfssl_local_FindSignerByAkidOrName(), with the same cycle guard andWOLFSSL_MAX_CHAIN_DEPTHlimit.WOLFSSL_TRUST_PEER_CERT), whose chain is not used.IGNORE_NAME_CONSTRAINTStheSignerhas no issuer lookup data, so only the leaf's direct issuer is checked.TLSX_CSR2_GetPendingSigners(), the same listProcessPeerCertParse()uses. A pending issuer does not stop the walk before a cached ancestor.EXTKEYUSE_AUTH_Efor a CA that the peer sent, the handshake records that chain index in a mask inProcPeerCertArgs. The walk skips that CA and still checks the ancestors that the peer did not send. The sharedSigneris not changed.This change does not change the persisted cert cache. #11875 rebuilds each CA from its DER, so a restored CA keeps its Extended Key Usage. Merge this change after #11875.
Testing
test_wolfSSL_chain_ca_ext_key_usagegains aleafOnlyoption, where the peer sends only the leaf and the CAs are loaded into the verifier. New cases:codeSigningandclientAuthCA rejected, andserverAuth, no extension andanyExtendedKeyUsageaccepted, when verifying a servercodeSigningandserverAuthCA rejected, andclientAuthand no extension accepted, when verifying a clientEXTKEYUSE_AUTH_E, showing that the callback is given that errorcodeSigningtrust anchor with a leaf-only chain, which stays acceptedcodeSigningCA that the peer did not sendBuilt and run with the default configure flags plus cert generation, and with each of
OPENSSL_EXTRA,OPENSSL_EXTRA+WOLFSSL_CHAIN_VERIFY_CB,IGNORE_NAME_CONSTRAINTS,WOLFSSL_ASN_ORIGINAL,WOLFSSL_ALT_CERT_CHAINSwith CRL/OCSP and status request,WOLFSSL_TRUST_PEER_CERT, andNO_SKID. A trusted peer leaf whose issuer name matches a restricted CA in the CertManager still connects with the example client (-E). The new cases fail without the library change. The full--apisuite passes in the default andOPENSSL_EXTRAbuilds.NO_SKIDnote: the existing self-issued rollover cases in this test already fail on master withNO_SKID(ASN_SIG_CONFIRM_E); this change does not affect them.How to reproduce
Build and run the test:
The test reports
Failed/Skipped/Passed/All: 0/0/1/1.To see the bug, keep the new test cases and put back the library files from master (
originis the wolfSSL/wolfssl remote):The test reports
Failed/Skipped/Passed/All: 1/0/0/1with:The leaf-only handshake with a restricted CA in the CertManager succeeds, but the test expects
EXTKEYUSE_AUTH_E(-386).Tested on macOS arm64 (Apple clang) at 390159a.
Checklist