Skip to content

fix(authentication-oauth): prevent open redirect via domain suffix attack#3669

Open
ByamB4 wants to merge 1 commit intofeathersjs:dovefrom
ByamB4:fix/oauth-redirect-domain-suffix-bypass
Open

fix(authentication-oauth): prevent open redirect via domain suffix attack#3669
ByamB4 wants to merge 1 commit intofeathersjs:dovefrom
ByamB4:fix/oauth-redirect-domain-suffix-bypass

Conversation

@ByamB4
Copy link

@ByamB4 ByamB4 commented Mar 11, 2026

Summary

  • Fixes incomplete validation of the redirect query parameter in OAuth strategy
  • The existing regex blocks @, \, and // but allows domain suffix attacks via . and - characters
  • Example: ?redirect=.attacker.com produces https://target.com.attacker.com, leaking the OAuth access token to an attacker-controlled domain

Changes

  • strategy.ts: Require queryRedirect to start with / (relative path only), preventing all URL authority manipulation attacks
  • strategy.test.ts: Add 5 test cases covering domain suffix attacks (.attacker.com, -attacker.com, bare domain) and valid relative path redirects

Attack Vector

  1. Attacker crafts: GET /oauth/google?redirect=.attacker.com
  2. After OAuth callback, redirect becomes: https://target.com.attacker.com#access_token=JWT_TOKEN
  3. If attacker registers target.com.attacker.com, they receive the victim's access token
  4. Result: Full account takeover

Test plan

  • Existing @, \\, // rejection tests still pass
  • New .attacker.com domain suffix attack is rejected
  • New -attacker.com domain suffix attack is rejected
  • New bare attacker.com redirect is rejected
  • Valid relative paths (/dashboard, /callback?state=abc) still work

Related to the fix in #3663 (CVE-2026-27191).

…tack

The regex validation for the redirect query parameter blocked @, \, and //
characters but did not prevent domain suffix attacks via . or - characters.
For example, ?redirect=.attacker.com would produce https://target.com.attacker.com
allowing an attacker to steal OAuth access tokens.

Fix: require redirect parameter to be a relative path starting with /,
which prevents all URL authority manipulation attacks.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

1 participant