GHSA-HP3V-MFQW-H74C
Vulnerability from github – Published: 2026-07-20 23:24 – Updated: 2026-07-20 23:24Summary
The @astrojs/netlify adapter converts each image.remotePatterns entry into a regular expression that is written to .netlify/v1/config.json under images.remote_images. Netlify's Image CDN uses these regexes as the allowlist that decides which remote image URLs it will optimize. remotePatternToRegex() escapes . in the hostname but interpolates the literal pathname into the regex without escaping regex metacharacters. As a result, the generated allowlist is broader than the pattern the developer declared, and broader than Astro's canonical matchPattern() helper (which compares non-wildcard pathnames by exact string equality).
This is a residual of the same bug class addressed in CVE-2026-54300 (PR #17018, commit 1310277d). That fix corrected wildcard semantics and added a $ anchor but did not add metacharacter escaping for literal pathnames.
Details
In packages/integrations/netlify/src/index.ts, remotePatternToRegex() escapes dots in the hostname:
regexStr += hostname.replace(/\./g, '\\.');
but interpolates the pathname unescaped in all three branches, e.g. the exact-match branch:
regexStr += `(\\${pathname})`;
Any regex metacharacter in the literal path (., +, ?, (, [, ...) is therefore passed through raw. Because . matches any character (including /), a restrictive pattern is silently widened.
The security boundary on Netlify is the generated regex itself — Netlify's Image CDN enforces it directly and Astro's runtime matchPattern() is not in the loop for this path, so there is no compensating layer that re-validates the request.
Proof of Concept
Configure an SSR site with a literal pathname containing a .:
// astro.config.mjs
image: {
remotePatterns: [{
protocol: 'https',
hostname: 'cdn.example.com',
pathname: '/img/v1.0/file',
}],
}
Run astro build and inspect .netlify/v1/config.json images.remote_images[0]:
https://cdn\.example\.com(:[0-9]+)?(\/img/v1.0/file)([?][^#]*)?$
Testing the generated regex:
https://cdn.example.com/img/v1.0/file-> MATCH (intended)https://cdn.example.com/img/v1X0/file-> MATCH (bypass; the unescaped.matches any character)https://cdn.example.com/img/v1/0/file-> MATCH (bypass;.also matches/, crossing a path segment)
Astro's canonical matchPattern() (exact string equality on the pathname) rejects both bypass URLs.
Impact
Netlify's Image CDN accepts optimization requests for URLs on the allowed host that the developer's remotePatterns entry was intended to exclude. The hostname remains correctly anchored, so the broadening is confined to the pathname dimension on an already-allowed host. Realistic impact depends on whether other images the developer meant to keep out of their CDN exist at metacharacter-adjacent paths on that host. This affects reasonable, non-permissive configurations, since any pathname containing a . (file extensions, version segments) is affected.
Patches
A fix will escape all regex metacharacters in the literal portions of each remotePatterns component before interpolation, applying only Astro's documented wildcard semantics explicitly. A regression corpus validates the generated Netlify regexes against @astrojs/internal-helpers' matchPattern().
Workarounds
Avoid regex metacharacters (notably .) in image.remotePatterns[].pathname values, or scope the allowed host so that unintended paths are not reachable.
Credit
Reported by @sec-reex as part of an incomplete-patch measurement study (responsible disclosure).
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "@astrojs/netlify"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "8.1.2"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-185"
],
"github_reviewed": true,
"github_reviewed_at": "2026-07-20T23:24:34Z",
"nvd_published_at": null,
"severity": "LOW"
},
"details": "## Summary\n\nThe `@astrojs/netlify` adapter converts each `image.remotePatterns` entry into a regular expression that is written to `.netlify/v1/config.json` under `images.remote_images`. Netlify\u0027s Image CDN uses these regexes as the allowlist that decides which remote image URLs it will optimize. `remotePatternToRegex()` escapes `.` in the hostname but interpolates the literal `pathname` into the regex **without escaping regex metacharacters**. As a result, the generated allowlist is broader than the pattern the developer declared, and broader than Astro\u0027s canonical `matchPattern()` helper (which compares non-wildcard pathnames by exact string equality).\n\nThis is a residual of the same bug class addressed in CVE-2026-54300 (PR #17018, commit `1310277d`). That fix corrected wildcard semantics and added a `$` anchor but did not add metacharacter escaping for literal pathnames.\n\n## Details\n\nIn `packages/integrations/netlify/src/index.ts`, `remotePatternToRegex()` escapes dots in the hostname:\n\n```js\nregexStr += hostname.replace(/\\./g, \u0027\\\\.\u0027);\n```\n\nbut interpolates the pathname unescaped in all three branches, e.g. the exact-match branch:\n\n```js\nregexStr += `(\\\\${pathname})`;\n```\n\nAny regex metacharacter in the literal path (`.`, `+`, `?`, `(`, `[`, ...) is therefore passed through raw. Because `.` matches any character (including `/`), a restrictive pattern is silently widened.\n\nThe security boundary on Netlify is the generated regex itself \u2014 Netlify\u0027s Image CDN enforces it directly and Astro\u0027s runtime `matchPattern()` is not in the loop for this path, so there is no compensating layer that re-validates the request.\n\n## Proof of Concept\n\nConfigure an SSR site with a literal pathname containing a `.`:\n\n```js\n// astro.config.mjs\nimage: {\n remotePatterns: [{\n protocol: \u0027https\u0027,\n hostname: \u0027cdn.example.com\u0027,\n pathname: \u0027/img/v1.0/file\u0027,\n }],\n}\n```\n\nRun `astro build` and inspect `.netlify/v1/config.json` `images.remote_images[0]`:\n\n```\nhttps://cdn\\.example\\.com(:[0-9]+)?(\\/img/v1.0/file)([?][^#]*)?$\n```\n\nTesting the generated regex:\n\n- `https://cdn.example.com/img/v1.0/file` -\u003e MATCH (intended)\n- `https://cdn.example.com/img/v1X0/file` -\u003e MATCH (bypass; the unescaped `.` matches any character)\n- `https://cdn.example.com/img/v1/0/file` -\u003e MATCH (bypass; `.` also matches `/`, crossing a path segment)\n\nAstro\u0027s canonical `matchPattern()` (exact string equality on the pathname) rejects both bypass URLs.\n\n## Impact\n\nNetlify\u0027s Image CDN accepts optimization requests for URLs on the allowed host that the developer\u0027s `remotePatterns` entry was intended to exclude. The hostname remains correctly anchored, so the broadening is confined to the pathname dimension on an already-allowed host. Realistic impact depends on whether other images the developer meant to keep out of their CDN exist at metacharacter-adjacent paths on that host. This affects reasonable, non-permissive configurations, since any `pathname` containing a `.` (file extensions, version segments) is affected.\n\n## Patches\n\nA fix will escape all regex metacharacters in the literal portions of each `remotePatterns` component before interpolation, applying only Astro\u0027s documented wildcard semantics explicitly. A regression corpus validates the generated Netlify regexes against `@astrojs/internal-helpers`\u0027 `matchPattern()`.\n\n## Workarounds\n\nAvoid regex metacharacters (notably `.`) in `image.remotePatterns[].pathname` values, or scope the allowed host so that unintended paths are not reachable.\n\n## Credit\n\nReported by @sec-reex as part of an incomplete-patch measurement study (responsible disclosure).",
"id": "GHSA-hp3v-mfqw-h74c",
"modified": "2026-07-20T23:24:34Z",
"published": "2026-07-20T23:24:34Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/withastro/astro/security/advisories/GHSA-hp3v-mfqw-h74c"
},
{
"type": "WEB",
"url": "https://github.com/withastro/astro/pull/17018"
},
{
"type": "ADVISORY",
"url": "https://github.com/advisories/GHSA-529g-xq4f-cw38"
},
{
"type": "PACKAGE",
"url": "https://github.com/withastro/astro"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "@astrojs/netlify generates an overly-broad Netlify Image CDN allowlist because remotePatterns.pathname metacharacters are not escaped"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.