Repository navigation
fix(auth): refuse sign-in destinations with control characters - #197
Merged
Merged
Conversation
Browsers drop tabs and line breaks from a URL, so a callbackUrl or next of "/\t/evil.example" passed the same-site check and then opened //evil.example after signing in. The web app and the API now refuse control characters and backslashes anywhere in it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W42z4FbekWr33b6791svQQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Description
Before: the post-sign-in destination checks (
safeCallbackUrlfor/login?callbackUrl=,safeNexton the external-login return, and the API's_safe_next) accepted/\t/evil.example. Browsers drop tabs, CR and LF from URLs, so after a passkey or external sign-in,location.assignwent tohttps://evil.example/. That is an open redirect from a link on the real site.After: all three refuse control characters and backslashes anywhere in the path, and
safeNextnow reusessafeCallbackUrl. Ordinary paths with query strings behave as before. Password sign-in was not affected, because Auth.js already prefixes its own base URL.Motivation and Context
This answers threat-model question Q40: a post-sign-in
nexttarget is limited to same-origin paths (claimed, correctness-only).Steps to reproduce (if appropriate):
The new tab, CR and LF cases fail on main and pass here:
__tests__/navigation.test.ts,__tests__/externalSignIn.test.tsx, and the new line intests/api/test_external_login.py.Types of changes
!in the title)Checklist:
make hookschecks it on commit).docs/accordingly.## UnreleasedinCHANGELOG.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01W42z4FbekWr33b6791svQQ
Generated by Claude Code