NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Open WebUI

CVE-2026-45675: Open WebUI: LDAP and OAuth First-User Race Condition Allows Multiple Admin Accounts

highCVSS 3.1 8.1GHSA-h3ww-q6xx-w7x3

On a fresh Open WebUI instance with LDAP or OAuth login, several users who sign in at the same moment can all be made administrators. The role is chosen before the user is inserted, which leaves a race window. Versions up to 0.8.12 are affected. Upgrade to 0.9.0.

Published May 14, 2026 · Updated Jul 15, 2026 · Analysis Oct 27, 2026

What an attacker can do

The regular signup handler was already fixed: it inserts the user with DEFAULT_USER_ROLE, then promotes to admin only if Users.get_num_users() == 1. The LDAP path in routers/auths.py and the OAuth path in utils/oauth.py still decide first. LDAP runs Users.has_users() and sets role = 'admin' when the table is empty. OAuth's get_user_role returns 'admin' when user_count == 0. Both then call insert_new_auth with that role.

Concurrent first logins can all see an empty user table and all receive admin. The advisory notes DATABASE_ENABLE_SESSION_SHARING defaults to False, so each call has its own database session, which widens the window (CWE-362).

This only matters at bootstrap. The attacker must be able to authenticate through the configured LDAP or OAuth provider and time their first login against the legitimate first admin, so the complexity is high. With the admin role they reach all user data, system configuration, API keys and connected LLM backends. The risk is real for new deployments that expose a corporate SSO to many users before the owner has signed in.

Who is affected

open-webui up to and including 0.8.12 is affected. Only instances with LDAP or OAuth enabled and an empty user table are exposed. An instance that already has its first admin is no longer in the window.

Check the version:

pip show open-webui

For Docker, check the image tag. Also check the admin list in the settings for admins you did not create.

open-webui

Ecosystem
PyPI
Affected
<= 0.8.12
Fixed in
0.9.0
Check
pip show open-webui

How to fix it

Upgrade to open-webui 0.9.0 or later:

pip install --upgrade open-webui

Pull request 23626 makes both paths insert first with DEFAULT_USER_ROLE, then check get_num_users() == 1. Only the sole user is promoted. OAuthManager.get_user_role now returns DEFAULT_USER_ROLE for first-user bootstrap. Two racing first logins can both insert, but only one sees a count of 1.

The advisory names no workaround. For a new instance on an older version, sign in once as the intended admin on a private network before opening it to others.

How to tell if you were hit

Open the admin user list and look for more than one admin on an instance that should have one. Compare user creation times: admins created within the same second or two at first start are suspicious.

Check authentication logs for several first-time LDAP or OAuth logins in a burst during initial deployment. Review settings changes, API keys and connection edits made by unexpected admins.

Original advisory

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

  1. Deploy Open WebUI with LDAP or OAuth enabled on a fresh instance (no existing users)
  2. Send multiple concurrent authentication requests from different users
  3. Multiple requests pass the has_users() / get_num_users() == 0 check simultaneously
  4. 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:

  1. Insert the new user with DEFAULT_USER_ROLE unconditionally — no pre-insert role decision based on user count.
  2. After the insert commits, atomically call Users.get_num_users() == 1 to check whether this is the sole user.
  3. Only the sole user gets promoted to admin via Users.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.

Questions

Does this affect an Open WebUI instance that already has an admin?

Not in the described path. The race only occurs while the user table is empty, so it matters on fresh deployments using LDAP or OAuth sign-in.

Why was password signup not affected?

signup_handler was already patched to insert with the default role first and promote only when the user count is 1. The LDAP and OAuth paths missed that fix until 0.9.0.

Which Open WebUI version fixes the first-user race?

0.9.0. Versions up to and including 0.8.12 are listed as vulnerable.

References

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. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Open WebUI vulnerabilities

All Open WebUI entries