Skip to content

CN constraints fix#10223

Open
rlm2002 wants to merge 2 commits intowolfSSL:masterfrom
rlm2002:zd21611
Open

CN constraints fix#10223
rlm2002 wants to merge 2 commits intowolfSSL:masterfrom
rlm2002:zd21611

Conversation

@rlm2002
Copy link
Copy Markdown
Contributor

@rlm2002 rlm2002 commented Apr 14, 2026

Description

Applies DNS name constraints to Subject CN when SAN is unavailable.

Fixes zd#21611

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@rlm2002 rlm2002 self-assigned this Apr 14, 2026
@rlm2002 rlm2002 marked this pull request as ready for review April 14, 2026 19:12
@rlm2002 rlm2002 changed the title CN constraints and Signature length check CN constraints fix Apr 14, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

MemBrowse Memory Report

gcc-arm-cortex-m4-min-ecc

  • FLASH: .text +64 B (+0.1%, 59,189 B / 262,144 B, total: 23% used)

gcc-arm-cortex-m4-tls12

@rlm2002
Copy link
Copy Markdown
Contributor Author

rlm2002 commented Apr 15, 2026

retest this please Jenkins: history deleted

@rlm2002
Copy link
Copy Markdown
Contributor Author

rlm2002 commented Apr 16, 2026

Retest this please Jenkins. generic-config-parser failed

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10223

Scan targets checked: wolfcrypt-api_misuse, wolfcrypt-bugs, wolfcrypt-compliance, wolfcrypt-concurrency, wolfcrypt-consttime, wolfcrypt-defaults, wolfcrypt-mutation, wolfcrypt-portability, wolfcrypt-proptest, wolfcrypt-src, wolfcrypt-zeroize

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 wolfcrypt/src/asn.c
Comment on lines +17663 to 17673
/* When no SAN is present, apply DNS name constraints to the
* Subject CN. */
if (cert->subjectCN != NULL && cert->altNames == NULL) {
subjectDnsName.next = NULL;
subjectDnsName.type = ASN_DNS_TYPE;
subjectDnsName.len = cert->subjectCNLen;
subjectDnsName.name = cert->subjectCN;
}
break;
case ASN_IP_TYPE:
/* IP addresses are stored in altNames with type ASN_IP_TYPE */
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 [Medium] Surviving deletion mutation: subjectDnsName CN fallback has no test for permitted CN
Category: Surviving deletion mutations

The new test test_wolfSSL_CertManagerNameConstraint_DNS_CN only verifies that a CN violating the DNS name constraint (evil.attacker.com) is rejected. It does not test that a CN matching the permitted constraint (e.g., wolfssl.com or example.com) is accepted when no SAN is present. This means the entire subjectDnsName population block (lines 17663-17673) could be replaced with an unconditional return ASN_NAME_INVALID_E (or a hardcoded failure for missing SAN) and the test would still pass. A mutation that deletes the subjectDnsName.name = cert->subjectCN assignment and instead forces a constraint violation would survive all existing tests. A positive test case — a leaf cert with CN=wolfssl.com and no SAN that is expected to pass verification — is needed to confirm the CN-to-constraint matching logic actually works correctly rather than simply always rejecting certs without SANs.

if (cert->subjectCN != NULL && cert->altNames == NULL) {
    subjectDnsName.next = NULL;
    subjectDnsName.type = ASN_DNS_TYPE;
    subjectDnsName.len  = cert->subjectCNLen;
    subjectDnsName.name = cert->subjectCN;
}

Recommendation: Add a test case in test_wolfSSL_CertManagerNameConstraint_DNS_CN that creates a leaf cert with CN=wolfssl.com (a permitted name), no SAN extension, and verifies that wolfSSL_CertManagerVerifyBuffer returns WOLFSSL_SUCCESS (not ASN_NAME_INVALID_E). This ensures the CN fallback path correctly matches permitted names, not just rejects disallowed ones.

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.

4 participants