René's URL Explorer Experiment


Title: @angular/ssr: the route matcher and @angular/router disagree, so per-route headers, status and renderMode come from a different route than the one rendered · Issue #34090 · angular/angular-cli · GitHub

Open Graph Title: @angular/ssr: the route matcher and @angular/router disagree, so per-route headers, status and renderMode come from a different route than the one rendered · Issue #34090 · angular/angular-cli

X Title: @angular/ssr: the route matcher and @angular/router disagree, so per-route headers, status and renderMode come from a different route than the one rendered · Issue #34090 · angular/angular-cli

Description: Command build Is this a regression? No Description @angular/ssr matches every incoming request twice, with two different tokenisers, and lets the two answers disagree. ServerRouter.match() picks the response's headers, status, renderMode...

Open Graph Description: Command build Is this a regression? No Description @angular/ssr matches every incoming request twice, with two different tokenisers, and lets the two answers disagree. ServerRouter.match() picks th...

X Description: Command build Is this a regression? No Description @angular/ssr matches every incoming request twice, with two different tokenisers, and lets the two answers disagree. ServerRouter.match() picks th...

Opengraph URL: https://github.com/angular/angular-cli/issues/34090

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@angular/ssr: the route matcher and @angular/router disagree, so per-route headers, status and renderMode come from a different route than the one rendered","articleBody":"### Command\n\nbuild\n\n### Is this a regression?\n\nNo\n\n### Description\n\n`@angular/ssr` matches every incoming request **twice, with two different tokenisers**, and lets the two answers disagree.\n\n`ServerRouter.match()` picks the response's `headers`, `status`, `renderMode` and `preload` using `RouteTree.getPathSegments()` (`packages/angular/ssr/src/routes/route-tree.ts`):\n\n```ts\nprivate getPathSegments(route: string): string[] {\n  return route.split('/').filter(Boolean).map(decodeURIComponent);\n}\n```\n\n`@angular/router` picks the component that renders into the response **body** using `DefaultUrlSerializer`, a grammar in which `(`, `)`, `;` and `//` are metacharacters and unparseable input is silently discarded.\n\nAppending a single character to a path therefore produces a response whose **body is route A** and whose **cache policy, security headers, status and render mode come from route B**.\n\nThe `@angular/router` side is intentional and is not the bug. `(name:seg)` is the documented secondary-outlet syntax, `;k=v` the documented matrix-parameter syntax, and d4d6c280 (`fix(router): handle parenthesized outlets without a name in DefaultUrlSerializer`, #64507) deliberately made an unnamed `(...)` group mean the primary outlet. `@angular/ssr` implements none of that grammar.\n\nVerified against the published `@angular/router` 22.1.6, `serialize(parse(x))`:\n\n| input | router resolves to |\n|---|---|\n| `/priv)` | `/priv` |\n| `/priv(` | `/priv` |\n| `/priv;` | `/priv` |\n| `/(priv)` | `/priv` |\n| `/priv/1//y` | `/priv/1` |\n| `/a/b)c/d` | `/a/b` |\n\n**This project has already patched one case of this class.** 85c18b4e (`fix(@angular/ssr): correctly handle routes with matrix parameters`, closes #31457) added `stripMatrixParams` because URLs with matrix parameters failed to match their route. That is the same divergence surfacing as a functional bug. Parentheses and interior `//` are the remaining cases, and the general fix is smaller than the third special case would be.\n\n**What is affected:** the per-route `headers`, `status` and `renderMode` declared in `app.routes.server.ts` are taken from a different route than the one that renders. `headers` is also spread last in `handleRendering`, after `Content-Type`, so those are attacker-selected too.\n\n**What is NOT affected, stated plainly:** `canActivate` and the other router guards still run, because `@angular/router` sees an ordinary path. This is not an authorization bypass and I am not claiming one. What is bypassed is the response policy and the render-mode directive.\n\n### Minimal Reproduction\n\n```\nng new ssrlab --ssr --defaults && cd ssrlab\n```\n\n`src/app/app.routes.ts`: client routes `pub`, `priv`, `priv/:id`, `privc`, `priv/:id/share`, each pointing at a component that renders a marker naming its own `routeConfig.path`, plus `{ path: '**', component: NotFound }`.\n\n`src/app/app.routes.server.ts`:\n\n```ts\nconst PRIVATE_HEADERS = {\n  'Cache-Control': 'no-store, private',\n  'X-Frame-Options': 'DENY',\n  'Content-Security-Policy': \"frame-ancestors 'none'\",\n};\n\nexport const serverRoutes: ServerRoute[] = [\n  { path: 'pub',   renderMode: RenderMode.Server, headers: { 'Cache-Control': 'public, max-age=600' } },\n  { path: 'priv',  renderMode: RenderMode.Server, headers: PRIVATE_HEADERS },\n  { path: 'priv/:id', renderMode: RenderMode.Server, headers: PRIVATE_HEADERS },\n  { path: 'privc', renderMode: RenderMode.Client, headers: PRIVATE_HEADERS },\n  { path: 'priv/:id/share', renderMode: RenderMode.Server, headers: { 'Cache-Control': 'public, max-age=31536000, immutable' } },\n  { path: '**',    renderMode: RenderMode.Server, headers: { 'Cache-Control': 'public, max-age=600' } },\n];\n```\n\n```\nng build && PORT=4111 node dist/ssrlab/server/server.mjs\ncurl -sD - --path-as-is 'http://127.0.0.1:4111/priv'\ncurl -sD - --path-as-is 'http://127.0.0.1:4111/priv)'\n```\n\n`policy_from` below is read off the response headers, `rendered` off the response body.\n\n```\n--- canonical spelling of each route ---\n/pub      200 policy_from=public    Cache-Control=public, max-age=600  X-Frame-Options=-     rendered=pub\n/priv     200 policy_from=private   Cache-Control=no-store, private    X-Frame-Options=DENY  rendered=priv\n/priv/1   200 policy_from=private   Cache-Control=no-store, private    X-Frame-Options=DENY  rendered=priv/:id\n/privc    200 policy_from=private   Cache-Control=no-store, private    X-Frame-Options=DENY  rendered=\u003cnot server-rendered>\n/nope     200 policy_from=wildcard  Cache-Control=public, max-age=600  X-Frame-Options=-     rendered=\u003cnot server-rendered>\n\n--- same routes, spelled so the two matchers disagree ---\n/priv)     200 policy_from=wildcard Cache-Control=public, max-age=600  X-Frame-Options=-     rendered=priv\n/priv(     200 policy_from=wildcard Cache-Control=public, max-age=600  X-Frame-Options=-     rendered=priv\n/priv;     200 policy_from=wildcard Cache-Control=public, max-age=600  X-Frame-Options=-     rendered=priv\n/(priv)    200 policy_from=wildcard Cache-Control=public, max-age=600  X-Frame-Options=-     rendered=priv\n/priv/1//y 200 policy_from=wildcard Cache-Control=public, max-age=600  X-Frame-Options=-     rendered=priv/:id\n/privc)    200 policy_from=wildcard Cache-Control=public, max-age=600  X-Frame-Options=-     rendered=privc\n```\n\n`GET /priv)` is one appended character. It replaces `no-store, private` with `public, max-age=600`, drops `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'none'`, and on `/privc)` server-renders a route whose configuration says `RenderMode.Client`.\n\nThe mangled path is not restricted to falling through to the catch-all. The mangled segment list is matched normally, so any route pattern that fits it is selectable:\n\n```\n/priv/1         policy_from=private  Cache-Control=no-store, private                    rendered=priv/:id\n/priv/1/share   policy_from=share    Cache-Control=public, max-age=31536000, immutable  rendered=priv/:id/share\n/priv/1//share  policy_from=share    Cache-Control=public, max-age=31536000, immutable  rendered=priv/:id\n```\n\nLine three renders the account page under the public sub-route's cache policy.\n\n### Exception or Error\n\nNone. Nothing throws and nothing is logged; both matchers succeed and return different answers. That is what makes it hard to notice in an application's own tests.\n\n### Your Environment\n\n```\n@angular/ssr 22.1.8 (latest on npm at time of testing)\n@angular/router 22.1.6 (latest)\nfiles: packages/angular/ssr/src/routes/route-tree.ts, packages/angular/ssr/src/routes/router.ts\n```\n\n### Anything else relevant?\n\n**Scope.** A differential sweep of 1575 paths against the running server produced 80 divergent paths in two root shapes: parenthesis/semicolon, and interior `//`. Enumerated over printable ASCII, the single-character triggers are `(`, `)` and `;`. All three are legal path characters that proxies and CDNs forward unchanged.\n\n**Suggested fix.** `@angular/ssr` already peer-depends on `@angular/router`, so normalising the pathname through the router's own grammar before tokenising makes the two matchers agree, in `ServerRouter.match`:\n\n```ts\nimport { DefaultUrlSerializer } from '@angular/router';\n\nprivate static readonly serializer = new DefaultUrlSerializer();\n\nprivate static normalize(pathname: string): string {\n  try {\n    const s = ServerRouter.serializer.serialize(ServerRouter.serializer.parse(pathname));\n    const cut = s.search(/[?#]/);\n\n    return cut === -1 ? s : s.slice(0, cut);\n  } catch {\n    return pathname; // malformed percent-encoding keeps today's behaviour\n  }\n}\n\nmatch(url: URL): RouteTreeNodeMetadata | undefined {\n  let { pathname } = stripIndexHtmlFromURL(url);\n  pathname = stripMatrixParams(ServerRouter.normalize(pathname));\n\n  return this.routeTree.match(pathname);\n}\n```\n\nChecked against the payload set and a calibration set: the divergent paths collapse onto the canonical route, and `/priv`, `/pub`, `/pub/1`, `/nope`, `/a%2Fb`, `/%zz` and `/priv/./x` tokenise exactly as they do today.\n\n**Known residual of that fix:** an application supplying a custom `UrlSerializer` still diverges, because the normalisation uses `DefaultUrlSerializer`. The durable fix is to build and query the route tree through the serializer the application injects. I am happy to open a PR with either shape.\n\n**Prior art checked.** All six `angular/angular-cli` security advisories; the five SSR ones concern `X-Forwarded-Prefix`, `createRequestUrl` and `CommonEngine` path traversal, none concerns route matching. Open PR #33248 centralises URL normalisation for prerender redirects, `Location` headers and the server manifest, but does not touch `routes/router.ts` or `routes/route-tree.ts`.\n\n**Reporting history.** Submitted to the Google OSS VRP as issue 559764571 on 2026-09-10. It was triaged and assigned, and the Bug Hunter Team invited public disclosure here on 2026-09-14. Filing it publicly at their request.\n\n**Disclosure.** This report and its testing were produced with AI assistance. Every claim in it was executed against a real production build of `@angular/ssr` 22.1.8 and `@angular/router` 22.1.6 rather than reasoned about, and the differential sweep carried a calibration set that showed no divergence.\n","author":{"url":"https://github.com/glivter","@type":"Person","name":"glivter"},"datePublished":"2026-09-14T20:37:26Z","url":"https://github.com/angular/angular-cli/issues/34090"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f6afa12b-2e17-2e3b-0190-f1cd01b71bfc
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCCF4:20A6C3:808DB:B7F3D:6AFDC69B
html-safe-nonce87d477d53500913a25a7e8acb7b990320f9eae259d1fa85f28ded2df24ee63c7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0Y0OjIwQTZDMzo4MDhEQjpCN0YzRDo2QUZEQzY5QiIsInZpc2l0b3JfaWQiOiI0Njc3MTc1NDc1MzkzMzgyMDQzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac8e415bd9367b313f47167948a954c605ae34f7b0dcda9c0fb791b02551e203ed
hovercard-subject-tagissue:5454355591
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/34090/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f14413e9c9b67e67c9c65f85ce9220bb572e098b446475aff5086e0dba026ef6/angular/angular-cli/issues/34090
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f14413e9c9b67e67c9c65f85ce9220bb572e098b446475aff5086e0dba026ef6/angular/angular-cli/issues/34090
og:image:altCommand build Is this a regression? No Description @angular/ssr matches every incoming request twice, with two different tokenisers, and lets the two answers disagree. ServerRouter.match() picks th...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameglivter
hostnamegithub.com
expected-hostnamegithub.com
None9ab00cc3b4fa90bbd3da70765dd38efc23cfa9d9b0930e41feea2bf67f60ecaf
turbo-cache-controlno-preview
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1b795ba060b92691fc16c5a12cf2bf95e83432b4
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/34090#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F34090
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F34090
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/34090
Reloadhttps://github.com/angular/angular-cli/issues/34090
Reloadhttps://github.com/angular/angular-cli/issues/34090
angularhttps://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Codehttps://github.com/angular/angular-cli
Issues196 (196)https://github.com/angular/angular-cli/issues
Pull requests20 (20)https://github.com/angular/angular-cli/pulls
Actionshttps://github.com/angular/angular-cli/actions
Security and quality8 (8)https://github.com/angular/angular-cli/security
Insightshttps://github.com/angular/angular-cli/insights
https://github.com/angular/angular-cli
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/34090
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/34090
@angular/ssr: the route matcher and @angular/router disagree, so per-route headers, status and renderMode come from a different route than the one renderedhttps://github.com/angular/angular-cli/issues/34090#top
area: @angular/ssrhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fssr%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
needsTriagehttps://github.com/angular/angular-cli/milestone/11
https://github.com/glivter
glivterhttps://github.com/glivter
on Sep 14, 2026https://github.com/angular/angular-cli/issues/34090#issue-5454355591
d4d6c28https://github.com/angular/angular-cli/commit/d4d6c2802351948ba1262df87eae144f4483ea06
85c18b4https://github.com/angular/angular-cli/commit/85c18b4ead77c6c090b9f5c63e9e034e58369152
#31457https://github.com/angular/angular-cli/issues/31457
#33248https://github.com/angular/angular-cli/pull/33248
angular-robothttps://github.com/apps/angular-robot
area: @angular/ssrhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fssr%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
on Sep 14, 2026https://github.com/angular/angular-cli/issues/34090#event-31129138233
angular-robothttps://github.com/apps/angular-robot
needsTriagehttps://github.com/angular/angular-cli/milestone/11
on Sep 14, 2026https://github.com/angular/angular-cli/issues/34090#event-31129140480
glivterhttps://github.com/glivter
on Sep 14, 2026https://github.com/angular/angular-cli/issues/34090#event-31130175990
fix(@angular/ssr): resolve the request path through the router's URL …https://github.com/glivter/angular-cli/commit/018fcbe7c6ba40407a6aebf775a236686290b787
https://docs.github.com/articles/closing-issues-via-commit-messages
018fcbehttps://github.com/glivter/angular-cli/commit/018fcbe7c6ba40407a6aebf775a236686290b787
https://github.com/SkyZeroZx
SkyZeroZxhttps://github.com/SkyZeroZx
on Sep 14, 2026https://github.com/angular/angular-cli/issues/34090#issuecomment-5671214161
#33555https://github.com/angular/angular-cli/issues/33555
https://github.com/glivter
glivterhttps://github.com/glivter
on Sep 14, 2026https://github.com/angular/angular-cli/issues/34090#issuecomment-5671267380
@SkyZeroZxhttps://github.com/SkyZeroZx
#33555https://github.com/angular/angular-cli/issues/33555
#33555https://github.com/angular/angular-cli/issues/33555
#33555https://github.com/angular/angular-cli/issues/33555
#34091https://github.com/angular/angular-cli/pull/34091
#33555https://github.com/angular/angular-cli/issues/33555
glivterhttps://github.com/glivter
not plannedhttps://github.com/angular/angular-cli/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Anot-planned
on Sep 14, 2026https://github.com/angular/angular-cli/issues/34090#event-31132648099
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Oct 22, 2026https://github.com/angular/angular-cli/issues/34090#issuecomment-6329552793
automatic conversation locking policyhttps://github.com/angular/angular/blob/f0fbced1c55bc8b8ed9df01cea99df42f3e7eae3/contributing-docs/auto-issue-locking.md
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Oct 22, 2026https://github.com/angular/angular-cli/issues/34090#event-33901029868
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular-cli/issues/34090
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/34090
area: @angular/ssrhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fssr%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
needsTriageNo due datehttps://github.com/angular/angular-cli/milestone/11
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.