Title: Angular Router zero-segment group replay can create duplicate outlet siblings and exhaust SSR workers · Issue #70997 · angular/angular · GitHub
Open Graph Title: Angular Router zero-segment group replay can create duplicate outlet siblings and exhaust SSR workers · Issue #70997 · angular/angular
X Title: Angular Router zero-segment group replay can create duplicate outlet siblings and exhaust SSR workers · Issue #70997 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description ImportantThis is a separate recognizer failure from #70932 and #70933. Those get their snapshot fan-out from empty-path routes matching th...
Open Graph Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description ImportantThis is a separate recognizer failure from #70932 and #70933. Those get their snapshot fa...
X Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description ImportantThis is a separate recognizer failure from #70932 and #70933. Those get their snapshot fa...
Opengraph URL: https://github.com/angular/angular/issues/70997
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Angular Router zero-segment group replay can create duplicate outlet siblings and exhaust SSR workers","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nrouter\n\n### Is this a regression?\n\nNo\n\n### Description\n\n> [!IMPORTANT]\n> This is a separate recognizer failure from #70932 and #70933. Those get their snapshot fan-out from empty-path routes matching the outlets a URL names, and become fatal when URL-sized state is copied into each snapshot. Here, the Router builds a tree that violates its own NG04006 invariant: two siblings targeting the same outlet under one parent. No query parameters or matrix parameters are required. The minimal reproducer is 28 bytes.\n\nA parenthesised group that consumes no segments is transparent to recognition. `processSegmentGroup()` hands it to `processChildren()` with the same `config` and the same `parentRoute`:\n\n```ts\nif (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {\n return this.processChildren(injector, config, segmentGroup, parentRoute);\n}\n```\n\nThe group costs no configured level and creates no node. Its contents are matched against the same route array again. Nest the groups and the array matches once per group, and every match lands in the snapshot tree as a sibling. Those siblings carry the same outlet name. NG04006 already says that is invalid.\n\nThe check that says so does not run on every list:\n\n```ts\nconst mergedChildren = mergeEmptyPathMatches(children);\nif (typeof ngDevMode === \"undefined\" || ngDevMode) {\n checkOutletNameUniqueness(mergedChildren);\n}\n```\n\nThat gate is gone in an optimized build, so production builds a tree development would have rejected. The OOM below uses that.\n\nThe second gap has nothing to do with production. `mergeEmptyPathMatches()` takes two nodes that matched the same empty-path route, concatenates their children and normalizes the result recursively. That list never reaches `checkOutletNameUniqueness()`. The call site only sees what `processChildren()` got back, not the children inside the nodes on it.\n\nThis route is enough:\n\n```ts\n{\n path: 'a',\n children: [{\n path: '', outlet: 'detail',\n children: [{ path: ':id', component: DetailPanel }],\n }],\n}\n```\n\n`/a/(detail:1//x:/(detail:2))`, 28 bytes, navigates. With `ngDevMode` **on**:\n\n```text\ndetail@''\n├── primary@:id url=1\n└── primary@:id url=2\n```\n\nTwo siblings on the primary outlet, under one parent, in a development build, no error. The tree is identical with `ngDevMode` off. The two gaps are independent: ungating the existing call site stops the replay below and leaves this untouched.\n\nThe route configuration is four lines. No empty-path level, no nesting, no guards, no resolvers:\n\n```ts\n{\n path: 'dashboard',\n component: Dashboard,\n children: [{ path: ':id', outlet: 'detail', component: DetailPanel }],\n}\n```\n\nThe URL is a balanced tree of these groups. Wrapper names are one character and can repeat between levels, since `UrlSegmentGroup.children` is keyed by outlet name:\n\n```text\n/dashboard/(detail:1//x:/(detail:1//x:/(...)//y:/(...))//y:/(...))\n```\n\nSnapshots counted with a build instrumented only at `createSnapshot()`. One request, 511 groups, 7,669 bytes:\n\n| Fan-out | Panel contains | Nodes | Tree steps |\n| ------: | -------------------------------- | -----: | ----------: |\n| 1 | nothing | 1,024 | 659,205 |\n| 2 | one aside | 2,046 | 2,624,000 |\n| 4 | aside with two widgets | 4,090 | 10,470,405 |\n| 13 | three panels, three widgets each | 13,288 | 110,406,675 |\n\nThe count is `2 * groups * matched_routes * fan_out + 2` in every row. `createSnapshot()` runs twice per match and the root snapshot is built directly,\nso the retained tree is half the count plus one.\n\nAn equal-byte control that reuses one wrapper name instead of distinct ones builds **236** nodes and walks **35,700** tree steps. Same-named siblings overwrite each other in `UrlSegmentGroup.children`, so the replay collapses. With no named outlet in the replayed set, recognition builds 8 nodes. **13,288 snapshots against 236, from one request of the same length.** That is the finding. The counts below are how far it goes.\n\nFan-out is application-controlled, not attacker-controlled. None of it appears in the URL. Every request count below is from the fan-out 13 shape. The four-line one is fatal too, but needs several times as many requests and I did not measure that\nprecisely.\n\nI tested Angular **22.2.0 on Node.js 24.16.0** with `outputMode: \"server\"`, against the three-panel configuration, at both request-line limits:\n\n| Path bytes | 128 MiB | 256 MiB | 512 MiB |\n| -----------: | ----------: | ----------: | ---------------: |\n| 7,669 B | 10 requests | 20 requests | over 40 requests |\n| 15,349 B | 6 requests | 10 requests | 20 requests |\n\nEvery failure was V8 hitting its own heap limit, not the container being reaped. The equal-byte control survived all of them. Six requests of 15 KB is not a burst any rate limit would notice, and the 8 KB payload reaches the same heap for less total traffic.\n\nA `development` build answers 404 and the worker is unaffected, so this shape does not show up locally. The merge case above does not show up locally either, and that one is not about the build at all.\n\nTo isolate where the memory goes I ran the same payload with the existing check ungated. Four concurrent requests at 256 MiB:\n\n| Build | Peak RSS | Status |\n| ------------- | ---------: | -----: |\n| stock | 296 MiB | 302 |\n| check ungated | **73 MiB** | 404 |\n\n73 MiB is the worker at rest. Recognition throws on the first duplicated sibling and the tree is never built, so the snapshot tree is where the memory goes. This is an ablation, not a proposal. It does not touch the merge case above.\n\n#### Secondary: the same gap under `withRouterResources()`\n\nThe replay is not the only thing that produces siblings sharing an outlet name. A flat URL of distinct names does it too, because `processSegmentAgainstRoute()` lets an empty-path route in the primary outlet match every named outlet the URL declares:\n\n```ts\n{ path: '', component: Shell, children: [\n { path: ':id', component: Report, resources: threeResources },\n { path: '', outlet: 'side', component: Panel },\n] }\n```\n\n```text\n/(a:1//b:1//c:1//...)\n```\n\nThat inflation is #70932's. What is new is that with `withRouterResources()` enabled, each duplicated instance costs a factory and its loaders. Three resources on 300 ms timers:\n\n| Path bytes | Outlets | Heap | Requests | stock | with #70933 |\n| ---: | ---: | ---: | ---: | --- | --- |\n| 7,995 B | 1,246 | 256 MiB | 5 | OOM | OOM |\n| 16,073 B | 2,400 | 256 MiB | 3 | OOM | OOM |\n| 7,995 B | 1,246 | 512 MiB | 12 | OOM | OOM |\n| 16,073 B | 2,400 | 512 MiB | 8 | OOM | OOM |\n\nLoaders that resolve immediately kill nothing. The wait is what costs.\n\n`withRouterResources()` is developer preview and opt-in, and the flat fan-out belongs to #70932, so this is secondary. It is here because it shows the same gap costing memory instead of only producing a wrong tree.\n\n#### Backend amplification\n\nIf the route carries a `resolve`, the resolver runs once per activated route, so once per replayed group. `resolveData()` uses `concatMap`, so they run one after another and the request holds its worker slot for the sum.\n\n```ts\n{\n path: 'dashboard',\n component: Dashboard,\n children: [{\n path: ':id', outlet: 'detail', component: DetailPanel,\n resolve: { item: itemResolver }, // fetch(API + '/item/' + id)\n }],\n}\n```\n\n```text\n/dashboard/(detail:1//x:/(detail:1//x:/(detail:1)//y:/(detail:1))//y:/(...))\n```\n\nA backend answering in 250 ms, one request, no concurrency:\n\n| Path bytes | Groups | Backend queries | Worker slot held | HTTP status |\n| ---------------: | -----: | --------------: | ---------------: | ----------: |\n| 230 B | 15 | 15 | 3,924 ms | 302 |\n| 950 B | 63 | 63 | 15,994 ms | 302 |\n| 1,910 B | 127 | 127 | 32,069 ms | 302 |\n| 1,910 B, control | 127 | 7 | 1,927 ms | 302 |\n\nQueries equal groups at every size. One 1,910-byte GET becomes **127** queries against whatever the resolver talks to, against 7 for the control. One is in flight at a time, so the 127 spread over 32 seconds. That is about 4 a second and buries nothing on its own. What one request costs reliably is a worker slot and a connection, held for those 32 seconds. The query load scales with concurrency.\n\nThe worker stays up the whole time, so what degrades is the service behind it. \nThat traffic comes from the SSR tier's own address, with its own credentials, and carries nothing the attacker controls. The client gets a 302 with a 20-byte `Location`. A 1,910-byte URI and a 32-second response both get logged, but nothing connects the queries back to the request.\n\nI measured `resolve` only.\n\n### Please provide a link to a minimal reproduction of the bug\n\nhttps://github.com/SkyZeroZx/angular-router-zero-segment-replay-lab\n\n```bash\n./scripts/validate.sh counts # snapshot counts\n./scripts/validate.sh devprod # development against production\n./scripts/validate.sh ablation # stock, #70933, the gate\n./scripts/validate.sh backend # the resolver table\n```\n","author":{"url":"https://github.com/SkyZeroZx","@type":"Person","name":"SkyZeroZx"},"datePublished":"2026-09-28T04:17:04Z","url":"https://github.com/angular/angular/issues/70997"}
| 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:15c2d705-02ca-93d6-6fc2-8b16f7a06195 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A31E:1F8B56:8BFE99:C61982:6AFDC9C1 |
| html-safe-nonce | 1b759261a8608d82ec9f73636a7cca86bf5597493bc741f250eac4263cda939c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzFFOjFGOEI1Njo4QkZFOTk6QzYxOTgyOjZBRkRDOUMxIiwidmlzaXRvcl9pZCI6IjQzODE4MDk0OTY0MTA2NzE1NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 27fcfd0258a2863f53b6a6ab1119634af21fdc86ee69c296c2bb88533742f300 |
| hovercard-subject-tag | issue:5609233277 |
| 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/70997/issue_layout |
| twitter:image | https://opengraph.githubassets.com/528c0ccdee089521dc607a6a33ea1c9cd5e273691116ab523d5639866982d7a9/angular/angular/issues/70997 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/528c0ccdee089521dc607a6a33ea1c9cd5e273691116ab523d5639866982d7a9/angular/angular/issues/70997 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description ImportantThis is a separate recognizer failure from #70932 and #70933. Those get their snapshot fa... |
| 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 | 9ab00cc3b4fa90bbd3da70765dd38efc23cfa9d9b0930e41feea2bf67f60ecaf |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| 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 | 1b795ba060b92691fc16c5a12cf2bf95e83432b4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width