# isInNet called with an invalid address, mask or argument count

Source: https://findproxyforurl.net/rules/isinnet-invalid-arguments/ · last updated 2026-10-11

Rule PAC-E010 (`isinnet-invalid-arguments`), severity high, category: Errors and robustness.

The network or mask literal is not a dotted-quad IPv4 address, the mask is not contiguous, or the call has fewer than three arguments. The comparison is then false for every host.

## Why it matters

`isInNet(host, pattern, mask)` only works with two syntactically valid IPv4 literals.
Typos such as `295.255.255.240`, `10.0.0` or `255:255.255.0` do not raise an error in
most engines; the function just returns false and the DIRECT branch for the internal
network silently stops matching. The engines disagree about such calls: Chrome, Edge and
Firefox check the pattern and mask first and return false, while pactester (pacparser) and
Windows (WinHTTP) do not check them. There, `isInNet(ip, "10.0.0.0/8", "255.0.0.0")`
(pactester only), a short mask such as `255.255.0` and a prefix length such as `8` can be
true, so a pactester test passes while the browsers return false (lab, 2026-10-11).
Non-contiguous masks (`255.0.255.0`) are accepted by every engine and compared bit by bit,
which produces surprising matches. With only two arguments the browsers return false, and
pactester and Windows throw an error that ends the evaluation. IPv6 literals are not valid
arguments for the v1 function (PAC-K014). Leading zeros such as `010.0.0.0` pass the browsers'
check but are read differently on Windows; PAC-C031 reports them.


## How to fix

Use four decimal octets 0-255 for both address and mask; the mask must be a run of 1-bits followed by 0-bits (e.g. 255.240.0.0).

## Bad

```js
function FindProxyForURL(url, host) {
  if (isInNet(host, "10.20.30.40", "295.255.255.240")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  if (isInNet(host, "10.20.30.32", "255.255.255.240")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Engine behaviour

- chromium: isInNet returns false when the network or mask literal is not a valid dotted quad (isValidIpAddress check), also with only two arguments; non-contiguous masks are accepted and applied bitwise. (source: lab, verified 2026-10-11)
- firefox: Same check as Chromium; invalid pattern or mask and a missing mask give false. (source: lab, verified 2026-10-11)
- pacparser: No check of pattern or mask, so a CIDR network or a short mask can still match; a missing mask throws. (source: lab, verified 2026-10-11)
- winhttp: Own implementation without a check of the mask; answers short masks, leading zeros and a missing mask differently from the browsers. (source: lab, verified 2026-10-11)
