FULL AI ANALYSIS

Android WebView OAuth redirect loses session cookies when using Custom Tabs and 302 cross-subdomain redirect

Generated Oct 17, 2026, 9:26:12 AM

Analysis summary

Custom Tabs are implemented by a separate browser process that may not expose the same cookie jar semantics as an in-app WebView and depends on the system browser to manage cookies. Cross-subdomain 302 sequences can interact with SameSite and browser optimizations (dedicated cookie stores for separate renderer processes, process swapping, or privacy heuristics) and cause cookies not to be sent on the subsequent redirected request. The fact that removing a redirect eliminates the issue strongly suggests the redirect sequence and process-host switching in Chrome/Custom Tabs are the triggers. Setting SameSite=None reduces trigger conditions but may have security implications.

Possible causes

Custom Tab/browser process swap across redirect leads to cookie jar not being propagated immediately between renderer processes, so the redirected request misses cookie header

70%

Browser privacy heuristics or SameSite handling treat the redirect as cross-site navigation and suppress cookies intermittently (especially with Lax), causing losses in some flows

50%

Inconsistent domain scoping for cookies (e.g., missing leading dot for .example.com) leading some clients to not attach cookies on subdomain-to-subdomain redirects

30%

Third-party password manager/autofill invoking a new tab/process interfering with the cookie-containing request timing (race), leading to missing cookies

20%

Suggested fixes

1

Diagnostic step 1

Remove intermediate redirects in the OAuth flow so the browser stays on the same origin chain for the minimal number of hops — redirect elimination is reversible and the most reliable fix observed in testing.

2

Diagnostic step 2

If redirects are unavoidable, consider using stateful server-side session tokens passed via the query string for intermediate hops (short-lived one-time tokens) instead of relying solely on cookies, and ensure these tokens are single-use and expire quickly to avoid security issues.

3

Diagnostic step 3

As a diagnostic, set SameSite=None on the cookie (Secure required) and test widely; if this resolves the issue fully, weigh the security trade-offs and consider tightening other controls (CSRF tokens, origin checks) before rolling out. Document this change and revert if unacceptable.

4

Diagnostic step 4

Log user-agent and flow timing for failed attempts (do not log cookie values) to correlate failures with specific browser versions or OEMs; escalate to Chromium bug tracker with a minimal repro if you can craft a small demo that shows cookie loss across cross-subdomain 302 in Custom Tabs.

5

Diagnostic step 5

As a fallback, implement the authorization flow using the AppAuth library with browser-based external auth that returns authorization code via a registered app scheme or claimed HTTPS redirect URI; AppAuth handles many of the edge cases and is reversible if you retain previous flow.