Skip to content

fix(platform-server): backport url validation origin hardening to v20#69188

Merged
atscott merged 2 commits into
angular:20.3.xfrom
alan-agius4:backport-69184-v20
Jun 5, 2026
Merged

fix(platform-server): backport url validation origin hardening to v20#69188
atscott merged 2 commits into
angular:20.3.xfrom
alan-agius4:backport-69184-v20

Conversation

@alan-agius4
Copy link
Copy Markdown
Contributor

Backports the fix and test hardening for platform location origin validation to v20.

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.
@pullapprove pullapprove Bot requested a review from devversion June 5, 2026 11:11
@angular-robot angular-robot Bot added the area: server Issues related to server-side rendering label Jun 5, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jun 5, 2026
@alan-agius4 alan-agius4 requested review from JeanMeche and removed request for devversion June 5, 2026 11:13
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: lts This PR is targeting a version currently in long-term support labels Jun 5, 2026
@alan-agius4
Copy link
Copy Markdown
Contributor Author

Disabling pullapprove as this is a backport.

@alan-agius4 alan-agius4 force-pushed the backport-69184-v20 branch from 26b7ed5 to 2f7da54 Compare June 5, 2026 11:15
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 5, 2026
@alan-agius4 alan-agius4 force-pushed the backport-69184-v20 branch from 2f7da54 to a18c255 Compare June 5, 2026 11:32
…ng SSR

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:
1. Add an `allowOriginChange` option to `ParseUrlOptions`. If false, `parseUrl` validates that the resolved URL's origin matches the base URL's origin.
2. Update `ServerPlatformLocation.replaceState` to call `parseUrl` with `allowOriginChange: false`.
@alan-agius4 alan-agius4 force-pushed the backport-69184-v20 branch from a18c255 to 675eab0 Compare June 5, 2026 11:43
@atscott atscott merged commit 49368c1 into angular:20.3.x Jun 5, 2026
17 checks passed
@atscott
Copy link
Copy Markdown
Contributor

atscott commented Jun 5, 2026

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: server Issues related to server-side rendering PullApprove: disable target: lts This PR is targeting a version currently in long-term support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants