Skip to content

fix(auth): avoid mutating OAuth query params - #1660

Merged
o-santi merged 1 commit into
supabase:mainfrom
hsusul:fix/auth-oauth-query-params-mutation
Oct 9, 2026
Merged

o-santi merged 1 commit into
supabase:mainfrom
hsusul:fix/auth-oauth-query-params-mutation

Conversation

@hsusul

@hsusul hsusul commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • copy caller-provided OAuth query parameters before adding derived fields
  • cover the behavior for both async and generated sync clients

Problem

sign_in_with_oauth() used the caller's nested query_params dictionary as its working dictionary. Adding redirect_to or scopes to the authorization URL therefore also changed the caller's credentials, allowing stale OAuth parameters to leak into a later reuse of that object.

Solution

Create a shallow copy of query_params before enriching it for URL generation. The generated URL, public API, and accepted option shapes remain unchanged.

Tests

  • Regression on clean upstream: failed because the original dictionary gained redirect_to
  • uv run --package supabase_auth pytest src/auth/tests/_async/test_gotrue.py::test_sign_in_with_oauth_does_not_mutate_query_params src/auth/tests/_async/test_gotrue.py::test_exchange_code_for_session src/auth/tests/_sync/test_gotrue.py::test_sign_in_with_oauth_does_not_mutate_query_params src/auth/tests/_sync/test_gotrue.py::test_exchange_code_for_session -q — 4 passed
  • make auth.tests — mypy passed; 166 Docker-backed tests passed
  • uv run ruff check src/auth — passed
  • uv run ruff format --check src/auth — passed
  • uv build --package supabase_auth — passed
  • git diff --check — passed

Closes #1659

@olirice @silentworks

@hsusul
hsusul requested review from a team and o-santi as code owners September 22, 2026 15:51
@o-santi
o-santi merged commit 553cb47 into supabase:main Oct 9, 2026
37 of 43 checks passed
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.

sign_in_with_oauth mutates the caller's query_params dictionary

2 participants