Skip to content

fix: constrain hydrated action redirects#127

Merged
smiggleworth merged 2 commits into
mainfrom
fix/security-action-redirects
Jul 26, 2026
Merged

fix: constrain hydrated action redirects#127
smiggleworth merged 2 commits into
mainfrom
fix/security-action-redirects

Conversation

@smiggleworth

Copy link
Copy Markdown
Contributor

Closes #126.

Normalizes response redirects against the current page and permits only http(s) destinations on the current origin. Navigation receives pathname/search/hash rather than an untrusted absolute string.

Regression proof rejects cross-origin absolute and protocol-relative URLs plus javascript: and data: schemes while preserving the existing safe relative redirect contract. Focused action tests and the full local npm run check pass.

Copilot AI review requested due to automatic review settings July 26, 2026 17:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a security hardening for hydrated action redirects by normalizing redirect strings against the current page, restricting redirects to same-origin http(s), and only navigating using the computed pathname/search/hash portion.

Changes:

  • Add normalizeActionRedirect() to validate redirect destinations (http/https + same origin) and strip to pathname/search/hash.
  • Route enhanced action navigation through the normalized redirect value rather than the raw envelope string.
  • Add jsdom regression tests to ensure unsafe redirect schemes/hosts are rejected and do not trigger navigation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/jsdom/actions/actions.test.tsx Adds regression coverage rejecting cross-origin, protocol-relative, javascript:, and data: redirects for enhanced actions.
src/actions/index.tsx Normalizes and constrains action redirects to same-origin http(s), and passes only pathname/search/hash to location.assign().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/actions/index.tsx
@smiggleworth
smiggleworth merged commit dc33b67 into main Jul 26, 2026
3 checks passed
@smiggleworth
smiggleworth deleted the fix/security-action-redirects branch July 26, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: constrain hydrated action redirects

2 participants