Pattern with leading and trailing * is a substring match
high
shExpMatch(host, "*example.com*") or shExpMatch(url, "*abc*") is true for any string that contains the characters anywhere. Over url this includes query strings an attacker controls; over host it includes look-alike domains.
Why it matters
A glob that starts and ends with * is a contains-test. shExpMatch(url, "*example.com*")
matches http://evil.test/?r=example.com; whoever controls a link controls the query
string, so the branch (typically DIRECT) is reachable for any destination. Over host,
*abc* matches abc.test, xyzabc.example and example.com.abc-attacker.test.
Which trick works depends on what the browser puts into url (lab, 2026-10-12):
- A query or path that contains the text (
http://evil.test/?r=example.com,http://evil.test/x.example.com) works in Chrome, Edge and Windows for http addresses. For https they pass onlyhttps://host:port/, and Firefox removes path and query everywhere, so there it does nothing. - A fake user name in front of the host (
https://example.com:x@evil.test/) works in Firefox for http and https, because Firefox keeps user name and password inurl. Chrome, Edge and Windows remove them, from http and https addresses alike.
So every major browser has at least one way to reach the branch, and the finding stays.
Patterns that contain :// or end in /* are anchored at the scheme or path boundary and
are not flagged. The grade is capped at C because the bypass is externally triggerable
without any control over DNS or the network.
How to fix
Anchor the pattern: use host with "*.example.com" / host == "example.com", or a URL pattern with scheme and path boundaries ("http://www.example.com/*").
Examples
Bad
function FindProxyForURL(url, host) {
if (shExpMatch(url, "*example.com*")) {
return "DIRECT";
}
return "PROXY proxy.corp.example:8080";
}
Open bad example in checkerGood
function FindProxyForURL(url, host) {
if (host == "example.com" || shExpMatch(host, "*.example.com")) {
return "DIRECT";
}
return "PROXY proxy.corp.example:8080";
}
Open good example in checkerEngine behaviour
| Engine | Behaviour | Source |
|---|---|---|
| chromium | The query and path trick works for http (path and query reach the script); for https only https://host:port/ reaches it. The user-name trick does not work; user name and password are removed for http and https. | lab, verified 2026-10-12 |
| firefox | The user-name trick works for http and https (https://example.com:x@evil.test/ reaches the script unchanged). The query and path trick does not; path and query are removed for every scheme. | lab, verified 2026-10-12 |
| winhttp | The query and path trick works for http (path and query reach the script). The user-name trick does not work; https URLs are cut to https://host:port/, and a user name and password are removed from http URLs too. | lab, verified 2026-10-12 |
The PAC functions this rule is about
shExpMatch(): Shell-glob match of str against pattern; * matches any sequence, ? one character. The whole string must match.
Related rules
- Hostname pattern applied to url instead of host PAC-C001
- Trailing * in a host pattern matches attacker-controlled suffixes PAC-X002
- Port matched as a substring of the URL PAC-X008