CVE-2026-45675: Open WebUI: LDAP and OAuth First-User Race Condition Allows Multiple Admin Accounts
Summary The LDAP and OAuth authentication flows use a TOCTOU (Time-of-Check-Time-of-Use) pattern for first-user admin role assignment. The regular signup handler (signuphandler in auths.py, line 663) was explicitly patched to prevent this race with the comment "Insert with default role first to avoid TOCTOU race", but the LDAP and OAuth code paths were never updated with the same fix.
Published May 14, 2026 · Updated Jul 15, 2026
Affected packages
open-webui
- Ecosystem
- PyPI
- Affected
- <= 0.8.12
- Fixed in
- 0.9.0
- Check
pip show open-webui
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
The LDAP and OAuth authentication flows use a TOCTOU (Time-of-Check-Time-of-Use) pattern for first-user admin role assignment. The regular signup handler (signup_handler in auths.py, line 663) was explicitly patched to prevent this race with the comment *"Insert with default role first to avoid TOCTOU race"*, but the LDAP and OAuth code paths were never updated with the same fix.
Vulnerable Code
LDAP (auths.py, lines 479-490)
# Line 482 - CHECK: is the user table empty?
role = 'admin' if not Users.has_users(db=db) else request.app.state.config.DEFAULT_USER_ROLE
# Lines 484-490 - USE: create user with the role determined above
user = Auths.insert_new_auth(
email=email,
password=str(uuid.uuid4()),
name=cn,
role=role, # <-- role was determined BEFORE insert, race window exists
db=db,
)OAuth (oauth.py, lines 1103-1112, 1566-1574)
# Line 1104 - CHECK: count users
def get_user_role(self, user, user_data):
user_count = Users.get_num_users()
if not user and user_count == 0:
return 'admin' # Line 1112
# Lines 1566-1574 - USE: create user with pre-determined role
user = Auths.insert_new_auth(
...
role=self.get_user_role(None, user_data), # Line 1571
...
)Both paths determine the role BEFORE inserting the user, creating a race window where multiple concurrent requests on a fresh instance can all observe an empty database and all receive the admin role.
Comparison with Patched Signup
The signup_handler (auths.py, line 663) was explicitly fixed:
# Insert with default role first to avoid TOCTOU race
user = Auths.insert_new_auth(..., role=DEFAULT_USER_ROLE, ...)
# Then check if this is the only user and upgrade
if Users.get_num_users() == 1:
Users.update_user_role_by_id(user.id, 'admin')The LDAP and OAuth paths did NOT receive this fix.
Exploitation
- Deploy Open WebUI with LDAP or OAuth enabled on a fresh instance (no existing users)
- Send multiple concurrent authentication requests from different users
- Multiple requests pass the
has_users()/get_num_users() == 0check simultaneously - All concurrent users become administrators
DATABASE_ENABLE_SESSION_SHARING defaults to False (env.py:387), so each call uses its own database session, widening the race window.
Impact
Any LDAP/OAuth user who times their first login concurrently with the legitimate first admin can escalate to full admin privileges, gaining access to all user data, system configuration, API keys, and connected LLM backends.
Suggested Fix
Apply the same insert-then-check pattern used in signup_handler: insert the user with DEFAULT_USER_ROLE first, then atomically check if this is the only user and upgrade to admin only if so.
Resolution
Fixed in PR #23626 (commit 96a0b3239), first released in v0.9.0 (Apr 2026). Both LDAP (routers/auths.py) and OAuth (utils/oauth.py) registration paths now use the same insert-first-check-after pattern that signup_handler already had:
- Insert the new user with
DEFAULT_USER_ROLEunconditionally — no pre-insert role decision based on user count. - After the insert commits, atomically call
Users.get_num_users() == 1to check whether this is the sole user. - Only the sole user gets promoted to
adminviaUsers.update_user_role_by_id.
OAuthManager.get_user_role was also updated to return DEFAULT_USER_ROLE (not admin) for first-user bootstrap; admin promotion is deferred to the post-insert check above. With this ordering, two concurrent first-user registrations that both observe an empty table can both insert, but only one will see get_num_users() == 1 afterward — the other will see == 2 and not be promoted.
Users on >= 0.9.0 are not affected.
Credited to sfwani, Classic298.
References
- https://github.com/open-webui/open-webui/security/advisories/GHSA-h3ww-q6xx-w7x3
- https://github.com/open-webui/open-webui/pull/23626
- https://github.com/open-webui/open-webui/commit/96a0b3239b1aadb23fc359bf10849c9ba12fd6ec
- https://github.com/open-webui/open-webui/releases/tag/v0.9.0
- https://nvd.nist.gov/vuln/detail/CVE-2026-45675
- https://github.com/pypa/advisory-database/tree/main/vulns/open-webui/PYSEC-2026-2730.yaml
- https://github.com/advisories/GHSA-h3ww-q6xx-w7x3
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Open WebUI vulnerabilities
All Open WebUI entriesCVE-2026-87011
Open WebUI: Unauthenticated requests can stall the server via uncached OIDC fetches in back-channel logout
high7.5Sep 10, 2026CVE-2026-87012
Open WebUI: Any authenticated user can suppress calendar alerts instance-wide via a non-numeric alert value
medium4.3Sep 10, 2026CVE-2026-87013
Open WebUI: Any authenticated user can start a non-terminating request via a folder parent cycle
medium4.3Sep 10, 2026CVE-2026-87014
Open WebUI: Admin demoted through SSO role sync keeps read and write access to all users' notes
medium6.5Sep 10, 2026CVE-2026-87015
Open WebUI: A user's session cookies are sent to tool servers configured for bearer authentication
medium6.8Sep 10, 2026CVE-2026-87016
Open WebUI: Sign-in as another user via wildcard characters in the OAuth subject claim on SQLite
high8.1Sep 10, 2026
