Skip to content

Security: same-origin redirect validation#481

Open
nicdavidson wants to merge 3 commits intodevelopfrom
2026-04-security-scan
Open

Security: same-origin redirect validation#481
nicdavidson wants to merge 3 commits intodevelopfrom
2026-04-security-scan

Conversation

@nicdavidson
Copy link
Copy Markdown
Contributor

Summary

  • Adds same-origin check to handleRedirectIfPresent to prevent open redirect attacks

Test plan

  • Verify redirect still works for same-origin URLs
  • Confirm cross-origin redirect URLs are blocked

oleksandrkits and others added 3 commits March 27, 2026 12:15
The function was reading a URL from sessionStorage (originally captured
from the ?redirect= query param) and navigating to it without any origin
validation, allowing an attacker to craft a login link that sends the
victim — along with their live session token — to an arbitrary external
host after authentication.

Changes:
- Add isSameOriginUrl() that composes isValidHttpUrl() with an explicit
  window.location.origin comparison, rejecting external, protocol-relative,
  javascript:, and data: URLs.
- Patch handleRedirectIfPresent() to call isSameOriginUrl() before
  navigating; invalid URLs fall back to '/' instead of following the
  attacker-controlled destination.
- Expand url.spec.ts with 17 new tests covering isSameOriginUrl and the
  updated handleRedirectIfPresent (same-origin pass, token append,
  external URL rejection, protocol-relative/javascript:/data: rejection,
  fallback-to-root behaviour, sessionStorage cleanup on failure).
- Update swagger-ui 4.15.5 → 5.32.2 (fixes DOMPurify XSS/prototype
  pollution CVEs and Handlebars JS injection CVEs)
- Run npm audit fix for semver-compatible security patches

Result: 0 critical vulnerabilities (was 3), 58 total (was 77).
Remaining 58 are all in Angular 16 toolchain (requires major version
upgrade) and transitive dev dependencies.
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.

2 participants