Skip to content

fix(oauth): Match device login_hint with ASCII-only case folding - #129114

Merged
BYK merged 1 commit into
masterfrom
fix/oauth-device-login-hint-ascii-email
Oct 28, 2026
Merged

BYK merged 1 commit into
masterfrom
fix/oauth-device-login-hint-ascii-email

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #128458, from this review thread.

The device-flow login_hint check compared the hint to the signed-in user's primary email with str.casefold(). Unicode case folding maps some non-ASCII characters onto ASCII. For example, U+212A KELVIN SIGN folds to k. So a hint for one address could be approved by an account whose email only looks like it.

This switches the check to sentry.auth.email.emails_match. That helper folds ASCII A–Z only, and it's what the other auth email comparisons moved to in #127401 and #128720.

  • ensure_expected_account in oauth_device.py now calls emails_match directly. It was the only caller of ApiDeviceCode.accepts_user_email, so I removed that method. The model module can't import sentry.auth.email without a cycle, because that module imports User, Organization and org services.
  • test_login_hint_rejects_unicode_lookalike covers the case. It fails on the old code, which returns 200, and passes with this change, which returns 403. The existing ASCII case-insensitivity test still passes.

Verification: test_oauth_device.py and test_oauth_device_authorization.py pass (40 tests). prek and mypy pass on the changed files.

via BYK.

--

View Junior Session in Sentry

The login_hint check compared emails with str.casefold(), which maps some
non-ASCII characters onto ASCII (U+212A KELVIN SIGN folds to "k"). A hint for
one address could then be approved by a look-alike account. Use emails_match,
the ASCII-only helper the other auth email comparisons switched to in #127401
and #128720.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner October 28, 2026 22:39
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 28, 2026
@BYK
BYK requested a review from evanpurkhiser October 28, 2026 23:16
@BYK
BYK merged commit cdbc7de into master Oct 28, 2026
74 checks passed
@BYK
BYK deleted the fix/oauth-device-login-hint-ascii-email branch October 28, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant