Repository navigation
fix(@angular/ssr): validate prerender parameter values - #34570
Conversation
Reject `getPrerenderParams` values that are not valid path segments, such as `a/b`, `..` or a value containing `\`, instead of prerendering a different route or redirect target. Fixes angular#34569
There was a problem hiding this comment.
Code Review
This pull request introduces validation for prerender parameter values in Angular SSR, ensuring they are valid, non-empty path segments and do not contain path traversal or invalid characters (even when percent-encoded). It also adds comprehensive unit tests to verify this behavior. One issue was identified where decodeURIComponent can throw a URIError on malformed percent-encoded sequences, bypassing the custom descriptive error. It is recommended to wrap this call in a try-catch block to handle malformed sequences gracefully.
There was a problem hiding this comment.
Thanks for the PR.
Validating getPrerenderParams values is a good bug fix and hardening, though we do not consider #34569 to be a security issue.
getPrerenderParams() only runs at build time (ng build) and is not reachable from untrusted runtime requests. Unlike output encoding bugs where valid route segments (like apostrophes) broke generated code or HTML attributes, the scenarios in #34569 rely on getPrerenderParams() returning unvalidated path separators (\ or /) or dot segments (..) for a single segment parameter, and having a root :param route with no static prefix. Validating that external data matches the expected slug or ID format before returning it from getPrerenderParams() is an application responsibility, and allowedHosts is only meant to validate incoming Host headers at runtime in AngularAppEngine, not outbound requests during ng build. At runtime, dynamic redirect routes also do not decode %5C or %2F or keep leading slashes in buildUrlWithParams.
That said, rejecting invalid path segments in getPrerenderParams makes sense as hardening, but the current implementation in this PR has several bugs. Please see the inline comments below.
This is my bad I misleading this part from #34569. Same for the runtime Where I'm stuck is "an application responsibility". The page paths in the repro do what both advisories you published on 2026-10-28 ask, and the build still takes the host from them. GHSA-jp2q-rh7r-4vjf asks that values be "strictly validated or URL-encoded (e.g., with const encodePath = (path) => path.split('/').map(encodeURIComponent).join('/');so The tenant and short-link slugs only go through the slug validator, which rejects separators, whitespace and dot segments but lets I tested this on a fresh clone of the branch tip, an
For me the theat model will be like the following : The actor is a CMS author who can write one row of application data, no repository or CI access. I think you already placed that actor in scope, the precondition of GHSA-w34w is "The parameter values returned during the build originate from an untrusted or externally modifiable source (such as a CMS, database, or external API)", and it was scored for a network attacker with low privileges, not for a build operator. That score also counts the conditions it needs and it still came out High, so I'm wondering if "needs a particular route shape and a later build" lowers the severity instead of ruling the report out? On "unvalidated path separators ( On "no static prefix", switching the render host does need the value in first position, that part holds. But @alan-agius4 So I still think it can be reclassified like a security issue, since I don't think that, based on the framework, this can happen only by using the API as documented, but by unexpected behavior which allows performing a request to another host |
alan-agius4
left a comment
There was a problem hiding this comment.
@SkyZeroZx Thanks for sharing the additional context and follow-up. However, our assessment remains unchanged, and we consider #34569 to be a regular bug/hardening improvement rather than a security vulnerability.
Per our Security Policy (SECURITY.md), build-time configuration and values returned by developer-authored build-time functions such as getPrerenderParams() are considered trusted inputs. Passing unvalidated data from an external source (such as a CMS or database) into build-time route generation, or encoding untrusted path separators/hosts with encodeURIComponent instead of validating that parameters match an expected format, is an application-level input validation concern, not a vulnerability in Angular.
The earlier advisories you referenced (GHSA-jp2q-rh7r-4vjf and GHSA-w34w-96hf-98hj) involved output-escaping defects in generated JS/HTML where valid route characters (such as ') broke syntax.
Reject
getPrerenderParamsvalues that are not valid path segments, such asa/b,..or a value containing\, instead of prerendering a different route or redirect target.Fixes #34569