Repository navigation
percent decode in URIs and enforce LDH - #12003
Open
sebastian-carpenter wants to merge 1 commit into
Open
sebastian-carpenter wants to merge 1 commit into
sebastian-carpenter wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The no-escape URI host path bypasses URI_HOST_MAX_SZ, allowing an oversized host that is rejected in its equivalent escaped form, and needs the same bound plus an unescaped boundary test.
1 open issue
What changed in this PR
This PR normalizes URI hosts before certificate name-constraint matching and restricts host characters to letters, digits, hyphens, and dots.
Changes:
- Decode escaped unreserved host characters and reject malformed or disallowed escapes.
- Add matcher and OpenSSL-compatible API tests for normalization and invalid hosts.
- Update white-box tests for the host parser’s new buffer parameter.
| File | Description |
|---|---|
wolfcrypt/src/asn.c |
Adds host percent-decoding and character validation before constraint matching. |
tests/unit-mcdc/test_asn_fault_whitebox.c |
Supplies the new host buffer to parser tests. |
tests/api/test_ossl_x509_ext.c |
Tests encoded and invalid hosts under permitted and excluded constraints. |
tests/api/test_asn.c |
Adds decoding, host-length, invalid-character, and malformed-base cases. |
Review effort: Balanced
|
sebastian-carpenter
force-pushed
the
perc-uri
branch
from
November 4, 2026 23:08
105e2b7 to
c337606
Compare
Contributor
Author
|
Jenkins retest this please. |
sebastian-carpenter
force-pushed
the
perc-uri
branch
from
November 5, 2026 16:19
c337606 to
37f6c6d
Compare
Contributor
Author
|
Jenkins retest this please. |
Contributor
|
@claude review |
sebastian-carpenter
force-pushed
the
perc-uri
branch
from
November 12, 2026 00:15
37f6c6d to
35d40f4
Compare
Contributor
Author
|
relaxed restriction on both '_' and '~' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Percent-decode the URI host before it is compared against 'Name Constraints'. Previously the comparison was done over the raw bytes.
Fix
-,.,_and~.The constraint base is never decoded, and IP literals in brackets aren't either.
Behavior
Constraint is
host.example.com:host.example.comother.example.comh%6Fst.example.comh_st.example.com,h~st.example.com,h%5Fst.example.comh!st.example.comand other sub-delims\, space, NUL, non-ASCII)%2F,%40,%25,%00,%C3%A9)%ZZ,%6Z,%6,%)12.31.2.3,[2001:db8::1])%31%32.31.2.3)urn:example:host.example.com)Constraint base is malformed, SAN host is valid:
h%6Fst.example.com,example..com,., emptyThese behave as they did before this branch. Such a base can't match a valid host, and RFC 5280 puts the FQDN requirement on the CA. So a malformed excluded base silently excludes nothing.
Host characters
Strict LDH (RFC 1123) would reject
_, which real hosts use (SPIFFE trust domains,my_host.example.com). Rejecting it would make any URI name constraint, even an unrelated excluded-only one, fail the whole chain. The accepted set is therefore exactly RFC 3986 unreserved, the same set that percent-decoding accepts, so%5Fand%7Edecode to characters that are then allowed. Sub-delims (! $ & ' ( ) * + , ; =) are valid in an RFC 3986 reg-name but are not DNS host characters, so they are rejected.For example,
https://my_host.example.com/still matches a permitted.example.com.Tests
test_wolfssl_local_MatchUriNameConstraint(tests/api/test_asn.c): matcher rows for decoding, malformed and reserved escapes,_and~hosts raw and escaped, sub-delim hosts, decoded length limits, ACE hosts and malformed bases.test_wolfSSL_NAME_CONSTRAINTS_uri(tests/api/test_ossl_x509_ext.c): escaped, malformed and invalid hosts under the permitted.wolfssl.comfrom a real certificate.test_wolfSSL_NAME_CONSTRAINTS_check_name(tests/api/test_ossl_x509_ext.c):h%6Fstunder a permitted and an excludedhost.example.comh%5Fst.example.compassing an unrelated excluded constrainth%6Fst.example.comas a malformed base in both directionstests/unit-mcdc/test_asn_fault_whitebox.c: updated for the newGetUriHost()signature.Fixes zd#22727
Testing
Run
./configure --enable-opensslallto pull in the extra tests otherwise default covers the non-openssl stuff. The changed tests can be run with:./tests/unit.test -test_wolfssl_local_MatchUriNameConstraint -test_wolfSSL_NAME_CONSTRAINTS_uri -test_wolfSSL_NAME_CONSTRAINTS_check_name.For mc-dc build with
./configure --enable-all --enable-static --disable-shared CPPFLAGS=-DWOLFSSL_TEST_STATIC_BUILD. Run the tests with./tests/unit-mcdc/run-whitebox-smoke.sh.Checklist