Skip to content

Security: Prevent OAuth CSRF, open redirect, and account takeover - #2

Open
mertcano wants to merge 1 commit into
sapiom:mainfrom
mertcano:mertcano-patch-1
Open

Security: Prevent OAuth CSRF, open redirect, and account takeover#2
mertcano wants to merge 1 commit into
sapiom:mainfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

Copy link
Copy Markdown

This PR addresses a HIGH-severity vulnerability in the Spotify OAuth connector where the state parameter was unsigned and reusable, and the callback trusted client-supplied user IDs and redirect paths. The flow has been secured with session-bound nonces and strict path validation to prevent account-linking confusion and arbitrary external redirects.

CSRF Protection: Replaced the static, unsigned state payload with a short-lived, single-use nonce stored in a secure, HTTP-only cookie (spotify-oauth-nonce). The callback now strictly verifies this nonce to bind the OAuth flow to the active browser session.

Account Takeover Prevention: Removed reliance on the userId decoded from the OAuth state parameter. The callback now explicitly re-validates the current user's session (req.cookies.get('realism-session')) to ensure connector credentials are only bound to the genuinely authenticated user.

Open Redirect Prevention: Enforced strict relative-path validation for the returnTo parameter in both the initialization and callback routes. Absolute URLs and protocol-relative paths (e.g., //evil.com) are securely downgraded to the default /dashboard route.

This PR addresses a HIGH-severity vulnerability in the Spotify OAuth connector where the state parameter was unsigned and reusable, and the callback trusted client-supplied user IDs and redirect paths. The flow has been secured with session-bound nonces and strict path validation to prevent account-linking confusion and arbitrary external redirects.

CSRF Protection: Replaced the static, unsigned state payload with a short-lived, single-use nonce stored in a secure, HTTP-only cookie (spotify-oauth-nonce). The callback now strictly verifies this nonce to bind the OAuth flow to the active browser session.

Account Takeover Prevention: Removed reliance on the userId decoded from the OAuth state parameter. The callback now explicitly re-validates the current user's session (req.cookies.get('realism-session')) to ensure connector credentials are only bound to the genuinely authenticated user.

Open Redirect Prevention: Enforced strict relative-path validation for the returnTo parameter in both the initialization and callback routes. Absolute URLs and protocol-relative paths (e.g., //evil.com) are securely downgraded to the default /dashboard route.
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