fix(crt): honor wildcard nonProxyHosts entries in CRT-based clients - #7249
Open
zoewangg wants to merge 2 commits into
Open
fix(crt): honor wildcard nonProxyHosts entries in CRT-based clients#7249zoewangg wants to merge 2 commits into
zoewangg wants to merge 2 commits into
Conversation
zoewangg
force-pushed
the
zoewang/crt-nonproxyhosts-wildcard
branch
from
August 10, 2026 21:34
88feb25 to
a1cee23
Compare
CRT-based clients silently ignored wildcard nonProxyHosts entries: the shared parser rewrites glob * to the Java-regex .*?, which the native curl-style matcher cannot read, so *.example.com and bare * matched no host and those hosts were routed through the proxy. Source the raw glob tokens for the CRT path and translate them to the curl dot-suffix form at the CRT sink; the Java-regex clients (Netty, Apache, url-connection) are untouched.
zoewangg
force-pushed
the
zoewang/crt-nonproxyhosts-wildcard
branch
from
August 10, 2026 21:53
a1cee23 to
e2f8c52
Compare
RanVaknin
reviewed
Aug 11, 2026
| EventLoopGroup.closeStaticDefault(); | ||
| HostResolver.closeStaticDefault(); | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
Can we add a test that asserts the proxy routing behavior when no_proxy is supplied with comma space arguments?
RanVaknin
reviewed
Aug 11, 2026
| } | ||
|
|
||
| @ParameterizedTest(name = "builder nonProxyHost \"{0}\" -> curl \"{1}\"") | ||
| @CsvSource({ |
Contributor
There was a problem hiding this comment.
Does this support IPv6 inputs?
CRT-based clients support only an exact host, a leading *. suffix wildcard, a bare *, or a CIDR range in nonProxyHosts. A wildcard in any other position (e.g. 192.168.*, internal*) is not matched by the native matcher, so the host is routed through the proxy. Log this at WARN during proxy resolution instead of failing silently.
zoewangg
force-pushed
the
zoewang/crt-nonproxyhosts-wildcard
branch
from
August 12, 2026 00:08
cc1dd5c to
8bcead0
Compare
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.
Motivation and Context
nonProxyHostslets a client bypass the proxy for hosts a customer lists (viahttp.nonProxyHosts, theno_proxyenvironment variable, or the client builder). On CRT-based clients, wildcard entries were not applied: a*.example.comentry or a bare*did not match, so a request to a host the entry was meant to cover connected through the proxy rather than directly.This affects the CRT-based clients —
AwsCrtHttpClient,AwsCrtAsyncHttpClient, and the S3/CRT client — when a proxy is configured and a wildcardnonProxyHosts/no_proxyentry is used. Exact-host and CIDR entries were already applied correctly and are unchanged. The behavior is pre-existing (not a regression). Because a matching host was routed through the proxy instead of connecting directly, traffic a customer intended to keep off the proxy could pass through it; the fix makes wildcard entries behave the same way they do on the other clients.Root cause. There is one shared
nonProxyHostsparser and several downstream matchers with different expectations. The shared parser (SdkHttpUtils) rewrites each glob token by replacing*with the Java-regex fragment.*?. That is correct for the Netty/Apache/url-connection clients, which match withhost.matches(regex). The CRT client hands the same set to the native aws-c-http matcher viaHttpProxyOptions.setNoProxyHosts; that matcher is curl-style (exact host, dot-anchored suffix, CIDR, bare*) and cannot interpret a Java regex. So*.example.comreached CRT as.*?.example.com, which the native matcher matches against no host, and bare*reached it as.*?, likewise matching nothing.Modifications
Fix scoped to the CRT path only; the Java-regex clients (Netty, Apache, url-connection) are not modified.
ProxyConfigProvidergains arawNonProxyHosts()accessor that returns the split, lowercased tokens WITHOUT the* -> .*?rewrite. It is adefaultthat throwsUnsupportedOperationException(not abstract) to preserve backward compatibility for this@SdkProtectedApiinterface; the two concrete providers (ProxySystemPropertyConfigProvider,ProxyEnvironmentVariableConfigProvider) override it, delegating the shared split to a new@SdkInternalApiProxyNonProxyHostParserhelper.CrtProxyConfigurationsourcesrawNonProxyHosts(), andCrtConfigurationUtils.resolveProxytranslates each token to the curl form before callingsetNoProxyHosts: a leading-*wildcard (*.example.com) becomes the dot-anchored suffix (.example.com); a bare*, exact host names, and CIDR ranges pass through unchanged. Builder-supplied values were already raw, so both CRT input paths (system property / environment variable, and the client builder) are normalized to the same form before translation.nonProxyHosts(Set)/addNonProxyHost(String)docs (crt-coreCrtProxyConfiguration.Builderand the aws-crt-clientProxyConfiguration.Builderoverride) now describe the accepted forms in plain language and note the whitespace requirement.Supported forms (same as the
http.nonProxyHostssystem property): an exact host name such asexample.com; a leading-*wildcard such as*.example.com; a single*for all hosts; a CIDR range such as10.0.0.0/8. Entries must not carry surrounding whitespace: a leading or trailing space is treated as part of the host and prevents matching (this affects the common comma-spaceno_proxy=a.com, *.foo.comspelling and is documented rather than silently trimmed, since the shared parser feeds the untouched Java-regex clients too).Testing
CrtProxyWildcardNonProxyHostsTest, aws-crt-client): a WireMock proxy observes the routing decision via its request journal (no live destination needed).CrtConnectionUtilsTest): parameterized glob-to-curl translation for the builder and system-property paths, multi-entry mixed sets, both-input-paths-converge, and the null-token filter.Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License