-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The validator was sixty-eight lines and a filter_var call\n\nPR #14101, \"[5.x] External Glide URL validation,\" landed February 27, 2026. It introduced `RemoteUrlValidator` to gate the only external-input surface the Glide image proxy exposes: the watermark parameter on an image-generation request, and any Glide call that fetches an image by URL. A request like `/img/asset/...?mark=https://example.com/wm.png` reaches `Statamic\\Imaging\\ImageGenerator::setUpWatermark`, which routes the watermark URL through `getWatermarkFilesystemAndParam → parseUrl → app(RemoteUrlValidator::class)->parse($url)`. The validator's job, end to end, is to refuse anything that resolves to an internal address before Guzzle dials it. CVE-2026-45660 is the case it does not refuse.\n\n```php\n// src/Imaging/RemoteUrlValidator.php (pre-patch, v5.73.21)\n\nprotected function ensureHostResolvesToPublicIps($host)\n{\n if (filter_var($host, FILTER_VALIDATE_IP)) {\n $this->assertPublicIp($host);\n return;\n }\n\n $records = call_user_func($this->resolver, $host);\n $ips = collect($records)->flatMap(function ($record) {\n return [$record['ip'] ?? null, $record['ipv6'] ?? null];\n })->filter()->values()->all();\n\n if (empty($ips)) {\n throw new InvalidRemoteUrlException('Unable to resolve URL host.');\n }\n\n foreach ($ips as $ip) {\n $this->assertPublicIp($ip);\n }\n}\n\nprotected function assertPublicIp($ip)\n{\n $result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);\n\n if (! $result) {\n throw new InvalidRemoteUrlException('Destination IP is not publicly routable.');\n }\n}\n```\n\nTwo `filter_var` calls. The first proves the resolved value is a syntactically valid IP. The second proves the IP is not in `FILTER_FLAG_NO_PRIV_RANGE` (RFC 1918, RFC 4193) and not in `FILTER_FLAG_NO_RES_RANGE` (loopback, link-local, IETF-reserved blocks). The flag set is what PHP's filter extension publishes as \"not private, not reserved.\" Statamic took PHP at its word.\n\nThe default resolver, declared on the constructor as `fn ($host) => dns_get_record($host, DNS_A + DNS_AAAA) ?: []`, walks both A and AAAA records and hands each back as either the `ip` or `ipv6` key of the resolver's array. `assertPublicIp` then runs the same predicate against either form. The flag-name pair is one constant; the address space the constant covers depends on which family the string parses as. That is where the gap lives.\n\n## `::ffff:169.254.169.254` passes the gate\n\nPHP's `filter_var` with the two range flags, on every PHP release before 8.3, runs the predicate against the address as named. An IPv6 string is matched against IPv6 range tables. Those tables enumerate the IPv6 spaces RFC 4291 and RFC 6890 list as reserved: `::1/128` for loopback, `fe80::/10` for link-local, `fc00::/7` for unique-local, and the documented IETF allocations. They do not enumerate the `::ffff:0:0/96` prefix that RFC 4291 sets aside for IPv4-mapped IPv6, which is the representation a dual-stack system uses to carry an IPv4 address inside an IPv6 socket.\n\n`::ffff:169.254.169.254` is one such address. It is the IPv6 representation of `169.254.169.254`. On every cloud provider that follows the EC2 convention, including AWS, Alibaba, Hetzner, Scaleway, and DigitalOcean, that IPv4 is the instance metadata service. The validator runs:\n\n```\nfilter_var('::ffff:169.254.169.254', FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)\n=> '::ffff:169.254.169.254' // returned as a valid public IP\n```\n\nNo exception. `parseUrl` returns. `ImageGenerator` constructs `GuzzleAdapter` against `https://attacker.example`. Guzzle's underlying curl handle resolves `attacker.example` through the OS resolver, receives the same IPv4-mapped IPv6 sockaddr from `getaddrinfo`, and `connect()`s. Linux's dual-stack socket (`IPV6_V6ONLY=0`, the default) recognises the `::ffff:` prefix and dispatches the connection over IPv4 to `169.254.169.254`. The kernel does the unwrap the validator did not.\n\nThe attacker's choice of address is not constrained to the metadata endpoint. The same path reaches every host the dual-stack kernel will route to over the unwrapped IPv4, which is every IPv4 host the validator was written to refuse: `127.0.0.1`, `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, and every host on a private VLAN bound to the Statamic server's network interfaces. The regression test that ships with the fix names what the author was thinking about when they wrote it:\n\n```php\n// tests/Imaging/ImageGeneratorTest.php (added in v5.73.22)\npublic static function ipv4MappedIpv6Provider()\n{\n return [\n 'mapped loopback' => ['::ffff:127.0.0.1'],\n 'mapped loopback (hex form)' => ['::ffff:7f00:1'],\n 'mapped RFC1918' => ['::ffff:10.0.0.1'],\n 'mapped link-local metadata' => ['::ffff:169.254.169.254'],\n ];\n}\n```\n\nFour entries. Loopback, loopback in compressed hex, an RFC 1918 private range, and the address the test names \"link-local metadata.\" The data provider's key strings are the test author saying out loud which address the fix is for.\n\n## The redirect path runs the same predicate\n\n`GuzzleAdapter::requestOptions` returns a Guzzle option array that registers a callback on every 30x:\n\n```php\nreturn [\n 'allow_redirects' => [\n 'on_redirect' => function ($request, $response, $uri) {\n app(RemoteUrlValidator::class)->validate((string) $uri);\n },\n ],\n];\n```\n\nThe author considered the redirect-to-internal class. The callback re-validates the redirect target. The callback uses the same `RemoteUrlValidator`. A target server can serve a 302 to `http://[::ffff:169.254.169.254]/`, and the redirect validator returns clean against the IPv6 form the same way the initial validator did. The defense against redirect-based SSRF is in the file; the bug class is in the file's only validator.\n\nThe bytes Guzzle reads after the connect are handed to Glide as a watermark source. Glide attempts to decode them as an image and fails when the response is JSON or plaintext, which is what every IMDS endpoint returns. The 500 the operator sees is not a successful watermark render. The GET that produced it is what the attacker came for: blind SSRF against the IMDS endpoint is sufficient to trigger any side effect on an internal HTTP API that responds to unauthenticated GET, and on IMDSv1 it is sufficient to retrieve IAM Role credentials through a follow-on connection from the same attacker-controlled domain whose DNS the validator obeys.\n\n## The seven-line patch is the canonicalization PHP 8.3 already did\n\nThe 5.73.22 diff to `assertPublicIp`:\n\n```diff\n protected function assertPublicIp($ip)\n {\n+ if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {\n+ $packed = inet_pton($ip);\n+ if ($packed !== false && substr($packed, 0, 12) === \"\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\xff\\xff\") {\n+ $ip = inet_ntop(substr($packed, 12));\n+ }\n+ }\n+\n $result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);\n\n if (! $result) {\n throw new InvalidRemoteUrlException('Destination IP is not publicly routable.');\n }\n }\n```\n\nSeven added lines. The algorithm: if the address parses as IPv6, pack it into its sixteen-byte representation, inspect the first twelve bytes, and if they match the IPv4-mapped prefix `\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\xff\\xff`, slice the trailing four bytes into the IPv4 dotted form via `inet_ntop` and reassign `$ip`. The existing `filter_var` call below then runs against the unwrapped IPv4 address. `169.254.169.254` lands in `FILTER_FLAG_NO_RES_RANGE`. The exception fires. The validator now matches what curl was always going to do.\n\nThe byte pattern `\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\xff\\xff` is the in-memory shape of the `::ffff:0:0/96` prefix. The patch is `inet_pton`, a substring compare, and `inet_ntop`. Each call is a primitive PHP exposes for exactly this purpose. The reason the patch can be seven lines is that the canonicalization is already in PHP; the validator just never reached for it.\n\nThe advisory's own remark on the version split:\n\n> Sites running PHP 8.3 or newer are not affected.\n\nThis is the vendor saying out loud where the gap is. The Statamic validator's two-line check trusted PHP to discriminate between \"valid IPv6 in a documented public block\" and \"valid IPv6 carrying an embedded IPv4 in a documented private block.\" Before PHP 8.3, the filter extension did not make that distinction; the IPv4-mapped form was not classified as the reserved block its embedded IPv4 belonged to. From PHP 8.3 onward, the filter extension treats the mapped form as the IPv4 address it carries. The Statamic patch is the same canonicalization, written one layer up.\n\n## PHP 8.3 was the patch. PHP 8.2 is the CVE.\n\nPHP 8.3 was released November 23, 2023. PHP 8.2 reached end of active support December 8, 2024 and end of security support December 31, 2025. Statamic 5.x's `composer.json` requires `php ^8.2`. The vulnerable `RemoteUrlValidator` shipped February 27, 2026. The fix shipped May 11, 2026. The advisory shipped May 18, 2026.\n\nThe deployment slice CVE-2026-45660 describes is every Statamic install whose hosting still serves PHP 8.2, every install on a long-term-support distribution that back-ports security fixes into the 8.2 branch, every install whose operator pinned the runtime older than the one PHP would have done the work in. The `not affected` line in the advisory is honest about what the upstream had already done; it also names the deployment population that needs the polyfill.\n\nThe validator was new. The validator's flags were correct. The bug is older than the validator, and it lives one layer below it.\n\n## Gate-before-canonicalize, on filter_var's range flags\n\nThe class signature is in the catalog. The check runs against the wrapped representation; the action runs against the unwrapped one. The fix is to canonicalize before checking, never after. The Statamic exhibit puts the disagreement inside PHP's filter extension, where IPv6-form range checks and IPv4-form range checks split across a runtime-version boundary.\n\nThe same shape lives across the catalog's prior exhibits with different parser pairs. Open-WebSearch ([CVE-2026-42260](/posts/open-websearch-cve-2026-42260-block-list-never-reached)) wrote the `::ffff:*` enumeration into a dispatcher its control flow never reached. Gotenberg ([CVE-2026-42596](/posts/gotenberg-cve-2026-42596-patch-removed-the-default-protection)) wrote a deny-list regex against the bracketed-host form and let `net/netip.ParseAddr` unmap it to loopback IPv4 inside the dial. EspoCRM ([CVE-2026-33534](/posts/espocrm-cve-2026-33534-host-check-had-no-ipv4-parser)) wrote a `filter_var(..., FILTER_VALIDATE_IP)` host check and let libcurl's `inet_aton` accept `0177.0.0.1` as the same address with different bytes. Each is the same shape on a different parser pair.\n\nThis exhibit moves the disagreement inside a single function, across runtime versions of it. The validator and the kernel use two views of `::ffff:169.254.169.254`; the validator runs against the address as a string, the kernel routes against the address as bytes. PHP 8.3's filter extension closes the gap by unwrapping the mapped form before classifying it. Statamic's patch closes the gap by unwrapping the mapped form before passing it to filter_var. Both implement the same canonicalization. The runtime is the layer; the user code is the polyfill.\n\nPoC: [GHSA-pf9c-ch8r-2958](https://github.com/advisories/GHSA-pf9c-ch8r-2958). Patch commit: [3a0b3a05a in statamic/cms](https://github.com/statamic/cms/commit/3a0b3a05ab5f788fad4fa0af710d52510c56218e).","closing_line":"The patch is in `RemoteUrlValidator`. The bug is in `filter_var` on every PHP below 8.3.","hook_md":"Statamic 5.73.21's Glide image proxy gates external URLs through a new file, `src/Imaging/RemoteUrlValidator.php`, added eleven weeks before the CVE was assigned. The validator parses the URL, resolves the host through `dns_get_record`, and asks each returned address one question: `filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)`. The flag names describe the validator's intent. The function call is the validator's enforcement.\n\nCVE-2026-45660 is the gap between what `filter_var` answered and what `curl` was about to do.","post_id":576,"slug":"statamic-cve-2026-45660-ssrf-guard-was-filter-var","title":"CVE-2026-45660: Statamic's SSRF Guard Was filter_var. PHP 8.3 Was The Fix.","type":"initial","unreadable_sentence":"Statamic 5.73.22's seven-line patch is the canonicalization PHP 8.3 added inside `filter_var`."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCarWNhwAKCRDeZjl4jgkQ JmV7AQC4TUzExap64VudmRVQiNSeQ64IhDejbzpHw5fgJxTEqQD/YiIo7wNuuu9N P8eApnLoWKDxXU7ELCmSqUJc7aBFAA4= =/u/X -----END PGP SIGNATURE-----