Skip to content

Tinyauth has OAuth account confusion via shared mutable state on singleton service instances

High severity GitHub Reviewed Published Apr 1, 2026 in steveiliop56/tinyauth • Updated Apr 6, 2026

Package

gomod github.com/steveiliop56/tinyauth (Go)

Affected versions

< 1.0.1-0.20260401140714-fc1d4f2082a5

Patched versions

1.0.1-0.20260401140714-fc1d4f2082a5

Description

Summary

All three OAuth service implementations (GenericOAuthService, GithubOAuthService, GoogleOAuthService) store PKCE verifiers and access tokens as mutable struct fields on singleton instances shared across all concurrent requests. When two users initiate OAuth login for the same provider concurrently, a race condition between VerifyCode() and Userinfo() causes one user to receive a session with the other user's identity.

Details

The OAuthBrokerService.GetService() returns a single shared instance per provider for every request. The OAuth flow stores intermediate state as struct fields on this singleton:

Token storagegeneric_oauth_service.go line 96:

generic.token = token  // Shared mutable field on singleton

Verifier storagegeneric_oauth_service.go line 81:

generic.verifier = verifier  // Shared mutable field on singleton

In the callback handler oauth_controller.go lines 136–143, the code calls:

err = service.VerifyCode(code)                       // line 136 — stores token on singleton
// ... race window ...
user, err := controller.broker.GetUser(req.Provider)  // line 143 — reads token from singleton

Between these two calls, a concurrent request's VerifyCode() can overwrite the token field, causing GetUser()Userinfo() to fetch the wrong user's identity claims.

The same pattern exists in all three implementations:

PoC

Race scenario (two concurrent OAuth callbacks):

  1. User A and User B both click "Login with GitHub" on the same tinyauth instance
  2. Both are redirected to GitHub, authorize, and GitHub redirects both back with authorization codes
  3. Both callbacks arrive at tinyauth nearly simultaneously:
Timeline:
  t0: Request A → service.VerifyCode(codeA) → singleton.token = tokenA
  t1: Request B → service.VerifyCode(codeB) → singleton.token = tokenB  (overwrites tokenA)
  t2: Request A → broker.GetUser("github")  → Userinfo() reads singleton.token = tokenB
  t3: Request A receives User B's identity (email, name, groups)

User A now has a tinyauth session with User B's email, gaining access to all resources User B is authorized for via tinyauth's ACL.

PKCE verifier DoS variant: Even with PKCE, concurrent oauthURLHandler calls overwrite the verifier field, causing VerifyCode() to send the wrong verifier to the OAuth provider, which rejects the exchange.

Static verification: Run Go's race detector on a test that calls VerifyCode and Userinfo concurrently on the same service instance — the -race flag will flag data races on the token and verifier fields.

Go race detector confirmation: Running a concurrent test with go test -race on the singleton service detects 4 data races on the token and verifier fields. Without the race detector, measured token overwrite rate is 99.9% (9,985/10,000 iterations).

Test environment: tinyauth v5.0.4, commit 592b7ded, Go race detector + source code analysis

Impact

An attacker who times their OAuth callback to race with a victim's callback can obtain a tinyauth session with the victim's identity. This grants unauthorized access to all resources the victim is permitted to access through tinyauth's ACL system. The probability of collision increases with concurrent OAuth traffic.

The PKCE verifier overwrite additionally causes a denial-of-service: concurrent OAuth logins for the same provider reliably fail.

Suggested Fix

Pass verifier and token through method parameters or return values instead of storing them on the singleton:

func (generic *GenericOAuthService) VerifyCode(code string, verifier string) (*oauth2.Token, error) {
    return generic.config.Exchange(generic.context, code, oauth2.VerifierOption(verifier))
}

func (generic *GenericOAuthService) Userinfo(token *oauth2.Token) (config.Claims, error) {
    client := generic.config.Client(generic.context, token)
    // ...
}

Store the PKCE verifier in the session/cookie associated with the OAuth state parameter, not on the service struct.

References

@steveiliop56 steveiliop56 published to steveiliop56/tinyauth Apr 1, 2026
Published to the GitHub Advisory Database Apr 1, 2026
Reviewed Apr 1, 2026
Published by the National Vulnerability Database Apr 2, 2026
Last updated Apr 6, 2026

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
High
Privileges required
Low
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(14th percentile)

Weaknesses

Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')

The product contains a concurrent code sequence that requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence operating concurrently. Learn more on MITRE.

CVE ID

CVE-2026-33544

GHSA ID

GHSA-9q5m-jfc4-wc92

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.