Skip to content

X509 validation fixes#10737

Open
kareem-wolfssl wants to merge 4 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd21998
Open

X509 validation fixes#10737
kareem-wolfssl wants to merge 4 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd21998

Conversation

@kareem-wolfssl

Copy link
Copy Markdown
Contributor

Description

Fixes zd#21998

Testing

Built in tests + added tests

Checklist

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

@kareem-wolfssl kareem-wolfssl self-assigned this Jun 18, 2026
Copilot AI review requested due to automatic review settings June 18, 2026 22:19

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

This PR addresses X.509 validation correctness issues reported by x509-limbo (zd#21998) by tightening hostname wildcard matching rules and enforcing BasicConstraints pathLenConstraint during wolfSSL_X509_verify_cert() chain validation.

Changes:

  • Enforce RFC 6125/RFC 9525 + CA/Browser Forum wildcard placement restrictions in MatchDomainName().
  • Add pathLenConstraint enforcement over the assembled chain in wolfSSL_X509_verify_cert() (OpenSSL-compat path).
  • Add regression tests for wildcard placement and pathLenConstraint behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/api/test_ossl_x509.h Registers a new API test entry for wildcard placement regression coverage.
tests/api/test_ossl_x509.c Adds wildcard placement regression tests for MatchDomainName().
tests/api/test_ossl_x509_str.c Adds regression tests ensuring wolfSSL_X509_verify_cert() enforces BasicConstraints path length.
src/x509_str.c Implements pathLenConstraint checking over the built verification chain and integrates it into wolfSSL_X509_verify_cert().
src/internal.c Adds wildcard placement validation and applies it within MatchDomainName().

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

Comment thread src/x509_str.c Outdated
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m3

  • FLASH: .text +76 B (+0.1%, 121,485 B / 262,144 B, total: 46% used)

gcc-arm-cortex-m4

  • FLASH: .text +64 B (+0.0%, 199,116 B / 262,144 B, total: 76% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +64 B (+0.0%, 179,864 B / 1,048,576 B, total: 17% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +320 B (+0.0%, 768,452 B / 1,048,576 B, total: 73% used)

gcc-arm-cortex-m4-pq

  • FLASH: .text +64 B (+0.0%, 278,000 B / 1,048,576 B, total: 27% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +64 B (+0.0%, 323,536 B / 1,048,576 B, total: 31% used)

gcc-arm-cortex-m4-tls12

  • FLASH: .text +64 B (+0.1%, 122,253 B / 262,144 B, total: 47% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +128 B (+0.1%, 234,814 B / 262,144 B, total: 90% used)

gcc-arm-cortex-m7

  • FLASH: .text +64 B (+0.0%, 199,116 B / 262,144 B, total: 76% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +64 B (+0.0%, 278,576 B / 1,048,576 B, total: 27% used)

gcc-arm-cortex-m7-tls13

Frauschi added 2 commits June 19, 2026 10:48
- Break out of the chain-build loop after the partial-chain fallback accepts
  a caller-trusted terminus, so it is pushed to ctx->chain once instead of
  twice; X509StoreCheckPathLen's anchor-skip is now defensive, not load-bearing.
- Drop the now-dead cert == anchor guard and refresh the comment.
- Rework the pathLen regression tests: reuse the existing certs/test-pathlen
  chains (chainF rejects, chainB verifies) instead of inlined report certs.
X509StoreCheckPathLen() consumed a unit of the issuer's path length budget
for any non-self-issued intermediate. Gate the RFC 5280 sec. 6.1.4 (l)
decrement on cert->isCa so only CA certificates count, matching
ParseCertRelative() (wolfcrypt/src/asn.c) and the (m) tightening step. This
prevents a false PATH_LENGTH_EXCEEDED when a non-CA intermediate is tolerated
via verify_cb.
@Frauschi

Copy link
Copy Markdown
Contributor

Jenkins retest this please

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.

3 participants