{"id":"GHSA-456h-ww26-f758","summary":"Tinyauth: User enumeration attack by timing oracle","details":"### Summary\nIt's possible to enumerate users through a timing oracle. In other words: I can easily check if a username exists or not by observing the timing differences between logins.\n\n### PoC\nSetup a tinyauth server with a local user. It can be over the network.\n\nTry to log in with the local user, using an incorrect password: there is a noticeable delay. You know that the user exists.\n\nNow try to log in with a username that does not exist, using an incorrect password: it will complete almost immediately. You know that the user does not exist.\n\n### Expected vs actual behavior\n\nLogin attempts should take roughly the same amount of time when the user exists vs when the user does not exist.\nRight now, nonexistent user attempts are way faster, meaning if your login attempt is slow, then the username exists for sure.\n\n### Details\n\nExisting usernames will take an extra ~50 milliseconds to respond to login attempts, while non-existing usernames will take only ~50 microseconds (1000x less time) to return an incorrect password response.\n\nEven taking network traffic into consideration, it is trivial to check whether a local user exists or not.\n\n=== Existing user, wrong password ===\n  #1: 50.52ms\n  #2: 46.24ms\n  #3: 43.57ms\n\n=== Nonexistent user ===\n  #1: 43.03µs\n  #2: 48.45µs\n  #3: 59.33µs\n\n### Suggested fix\n\nThis can be solved by checking a dummy password hash when a user is not found before returning a query, this will mimic the exact same delay irrelevant of hardware capabilities.\n\nPotential patch:\n```\nFrom ca102773e0303f6025480efb26db379e3570a350 Mon Sep 17 00:00:00 2001\nFrom: Disyer \u003cdaniel@tohka.us\u003e\nDate: Tue, 14 Jul 2026 12:35:07 +0300\nSubject: [PATCH] fix: prevent user enumeration by means of timing attack\n\n---\n internal/controller/user_controller.go    |  1 +\n internal/middleware/context_middleware.go |  1 +\n internal/service/auth_service.go          | 10 ++++++++++\n 3 files changed, 12 insertions(+)\n\ndiff --git a/internal/controller/user_controller.go b/internal/controller/user_controller.go\nindex ae6c23b..2ecc996 100644\n--- a/internal/controller/user_controller.go\n+++ b/internal/controller/user_controller.go\n@@ -90,6 +90,7 @@ func (controller *UserController) loginHandler(c *gin.Context) {\n \n        if err != nil {\n                if errors.Is(err, service.ErrUserNotFound) {\n+                       controller.auth.DummyCheckPassword(req.Password)\n                        controller.log.App.Warn().Str(\"username\", req.Username).Msg(\"User not found during login attempt\")\n                        controller.auth.RecordLoginAttempt(req.Username, false)\n                        controller.log.AuditLoginFailure(req.Username, \"unknown\", c.ClientIP(), \"user not found\")\ndiff --git a/internal/middleware/context_middleware.go b/internal/middleware/context_middleware.go\nindex f49c85a..f70c9e7 100644\n--- a/internal/middleware/context_middleware.go\n+++ b/internal/middleware/context_middleware.go\n@@ -244,6 +244,7 @@ func (m *ContextMiddleware) basicAuth(username string, password string) (*model.\n        search, err := m.auth.SearchUser(username)\n \n        if err != nil {\n+               m.auth.DummyCheckPassword(password)\n                return nil, nil, fmt.Errorf(\"error searching for user: %w\", err)\n        }\n \ndiff --git a/internal/service/auth_service.go b/internal/service/auth_service.go\nindex eeb5c8e..9cbc105 100644\n--- a/internal/service/auth_service.go\n+++ b/internal/service/auth_service.go\n@@ -28,6 +28,10 @@ import (\n const MaxOAuthPendingSessions = 256\n const OAuthCleanupCount = 16\n \n+// a dummy hash to check when a user is not found, to prevent user enumeration\n+// hardcoded to prevent having to generate a hash on every startup\n+const dummyHash = \"$2a$10$iFQ6./j2a.UShYQOzWh4vOlnoze5DmHI3tRY3WU4YMj3zwp.t3TnO\"\n+\n var (\n        ErrUserNotFound = errors.New(\"user not found\")\n )\n@@ -204,6 +208,12 @@ func (auth *AuthService) CheckUserPassword(search model.UserSearch, password str\n        return errors.New(\"user authentication failed\")\n }\n \n+func (auth *AuthService) DummyCheckPassword(password string) {\n+       // When a user is not found, we still want to perform a password check to prevent\n+       // timing attacks that could reveal whether a user exists or not\n+       bcrypt.CompareHashAndPassword([]byte(dummyHash), []byte(password))\n+}\n+\n func (auth *AuthService) GetLocalUser(username string) *model.LocalUser {\n        if auth.runtime.LocalUsers == nil {\n                return nil\n-- \n2.55.0\n```\n\nAfter testing the proposed fix, there is no discernible timing difference:\n\n=== Existing user, wrong password ===\n  #1: 43.23ms\n  #2: 43.26ms\n  #3: 42.57ms\n\n=== Nonexistent user ===\n  #1: 42.45ms\n  #2: 42.11ms\n  #3: 47.71ms","aliases":["CVE-2026-77582","GO-2026-6555"],"modified":"2026-10-01T20:56:17.798738861Z","published":"2026-09-22T20:37:06Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2026-09-22T20:37:06Z","nvd_published_at":"2026-09-21T17:18:53Z","cwe_ids":["CWE-208"],"severity":"MODERATE"},"references":[{"type":"WEB","url":"https://github.com/tinyauthapp/tinyauth/security/advisories/GHSA-456h-ww26-f758"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-77582"},{"type":"WEB","url":"https://github.com/tinyauthapp/tinyauth/pull/1004"},{"type":"WEB","url":"https://github.com/tinyauthapp/tinyauth/commit/c22925c2fba981875d0a2b09dd3ee41c0ae4c310"},{"type":"PACKAGE","url":"https://github.com/tinyauthapp/tinyauth"},{"type":"WEB","url":"https://github.com/tinyauthapp/tinyauth/releases/tag/v5.1.0"}],"affected":[{"package":{"name":"github.com/tinyauthapp/tinyauth","ecosystem":"Go","purl":"pkg:golang/github.com/tinyauthapp/tinyauth"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.0.1-0.20260714134959-c22925c2fba9"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-456h-ww26-f758/GHSA-456h-ww26-f758.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N"}]}