Skip to content

Conversation

@analytically
Copy link
Contributor

@analytically analytically commented Dec 4, 2025

Two bugs caused intermittent "unexpected state token" errors:

  1. base64.StdEncoding uses +, /, = which get mangled in URLs
  2. Multiple browser tabs race to overwrite the single state cookie

Replace cookie-based state validation with self-validating HMAC-signed
tokens. State now includes timestamp, entropy, and signature - verified
entirely from the URL parameter without cookie comparison.

Signing key derived from OAuth client credentials (HMAC of clientID
with clientSecret as key), avoiding new configuration.

Potentially fixes #9036

@analytically analytically requested a review from a team as a code owner December 4, 2025 13:31
@analytically analytically changed the title fix(skymarshal): use URL-safe base64 encoding for OAuth state token fix(skymarshal): use HMAC-signed stateless OAuth state tokens Dec 4, 2025
@taylorsilva taylorsilva added the bug label Dec 4, 2025
Two bugs caused intermittent "unexpected state token" errors:

1. base64.StdEncoding uses +, /, = which get mangled in URLs
2. Multiple browser tabs race to overwrite the single state cookie

Replace cookie-based state validation with self-validating HMAC-signed
tokens. State now includes timestamp, entropy, and signature - verified
entirely from the URL parameter without cookie comparison.

Signing key derived from OAuth client and PG credentials
(HMAC of clientID, clientSecret, dbUser and dbPassword as key),
avoiding new configuration.

Signed-off-by: Mathias Bogaert <mathias.bogaert@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

unexpected state token on successful auth callback

2 participants