# Leading * without a dot matches look-alike domains

Source: https://findproxyforurl.net/rules/shexpmatch-leading-asterisk-without-dot/ · last updated 2026-10-04

Rule PAC-X004 (`shexpmatch-leading-asterisk-without-dot`), severity high, category: Security and fail-safety, top 20 #5.

shExpMatch(host, "*corp.example") matches badcorp.example as well as www.corp.example. The safe form is "*.corp.example", where the dot forces a label boundary.

## Why it matters

Without the dot, the leading wildcard can absorb part of a label. `*corp.example` is true
for `www.corp.example`, but also for `badcorp.example` and `notcorp.example`, which anyone
could register. This is the glob twin of PAC-X003. `*.example.com` requires at least one full
label before the dot and only matches real subdomains; the apex itself then needs its own
clause.


## How to fix

Use "*.example.com" (with the dot) and add host == "example.com" for the apex.

## Bad

```js
function FindProxyForURL(url, host) {
  if (shExpMatch(host, "*example.com")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  if (host == "example.com" || shExpMatch(host, "*.example.com")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Engine behaviour

- pacparser: "*example.com" matches a look-alike domain ending in "example.com"; "*.example.com" does not. (source: lab, verified 2026-05-20)
