fix(platform-server): harden platform location origin validation during SSR#69184
Closed
alan-agius4 wants to merge 3 commits into
Closed
fix(platform-server): harden platform location origin validation during SSR#69184alan-agius4 wants to merge 3 commits into
alan-agius4 wants to merge 3 commits into
Conversation
Update platform-server to use Angular 's native `RuntimeError` class. This aligns error throwing patterns in platform-server with other packages of the framework such as core, common, and platform-browser. For URL and host errors, the error messages are configured to return only the raw dynamic URL when `ngDevMode` is false (in production) to aid in troubleshooting without bloating production bundles.
…ng SSR Add allowOriginChange option to ResolveUrlOptions in resolveUrl to enforce same-origin validation on resolved URLs. When set to false, it prevents any cross-origin changes (including HTTP/HTTPS URLs), aligning the emulated server-side platform location environment with browser security behavior. Refactor ServerPlatformLocation.replaceState to use allowOriginChange: false instead of manual comparison, hardening state change validation against cross-origin URLs. Add unit tests in url_spec.ts and platform_location_spec.ts for the origin validation changes.
3874990 to
35f2784
Compare
JeanMeche
reviewed
Jun 5, 2026
JeanMeche
approved these changes
Jun 5, 2026
7f36122 to
39d0e1b
Compare
Contributor
|
This PR was merged into the repository. The changes were merged into the following branches:
|
atscott
pushed a commit
that referenced
this pull request
Jun 5, 2026
…ng SSR (#69184) Add allowOriginChange option to ResolveUrlOptions in resolveUrl to enforce same-origin validation on resolved URLs. When set to false, it prevents any cross-origin changes (including HTTP/HTTPS URLs), aligning the emulated server-side platform location environment with browser security behavior. Refactor ServerPlatformLocation.replaceState to use allowOriginChange: false instead of manual comparison, hardening state change validation against cross-origin URLs. Add unit tests in url_spec.ts and platform_location_spec.ts for the origin validation changes. PR Close #69184
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Align ServerPlatformLocation state modification behavior (replaceState and pushState) with the browser's HTML5 History API by enforcing same-origin validation.
In a browser environment, calling replaceState/pushState with a cross-origin URL throws a SecurityError. Previously, the emulated ServerPlatformLocation in platform-server silently allowed cross-origin state changes. If application code passed untrusted input to replaceState/pushState during SSR, this could cause the base URL to be changed, resulting in potential SSRF and credential leaks for relative HTTP requests.
To mitigate this:
allowOriginChangeoption toResolveUrlOptions. If false,resolveUrlvalidates that the resolved URL's origin matches the base URL's origin.ServerPlatformLocation.replaceStateto callresolveUrlwithallowOriginChange: false.