Open WebUI: LDAP and OAuth First-User Race Condition Allows Multiple Admin Accounts
8.1
High
CVSS 3.1 base
What to do
If you run open-webui 0.8.12 and earlier, upgrade to 0.9.0 or later.
Anyone who can reach it over the network, with no account and no user interaction, given conditions outside the attacker's control, can read and change sensitive data and make it unavailable.Read from the CVSS 3.1 vector
To exploit it
What it gets
My analysis of this finding: root cause, the vulnerable code, the impact and the fix, in the site’s format. The official advisory of record is linked above.
| Package | Ecosystem | Vulnerable | Fixed in |
|---|---|---|---|
open-webui | pip | <= 0.8.12 | 0.9.0 |
Open WebUI assigns the very first account to register on a fresh instance the admin role. Two of the three registration paths, LDAP and OAuth, decide that role with a check-then-create pattern that is not atomic. On a brand new deployment, several users who log in at the same moment can each observe an empty user table and each be created as an administrator. The regular signup endpoint was explicitly hardened against this, but the LDAP and OAuth paths were left on the old racy logic.
The race is a textbook TOCTOU. The role is decided from a count of existing users, and only later is the user inserted, with nothing holding the two steps together.
LDAP path, backend/open_webui/routers/auths.py:
# CHECK: is the user table empty?role = 'admin' if not Users.has_users(db=db) else request.app.state.config.DEFAULT_USER_ROLE # USE: create the user with the role decided aboveuser = Auths.insert_new_auth( email=email, password=str(uuid.uuid4()), name=cn, role=role, # role was determined BEFORE the insert db=db,)The bugrole is decided from a user count before the insert
OAuth path, backend/open_webui/utils/oauth.py, where get_user_role() reads the count up front:
def get_user_role(self, user, user_data): user_count = Users.get_num_users() # CHECK if not user and user_count == 0: return 'admin' # decided before any insertThe bugreads the user count before any row existsThe buggrants admin to every request that saw an empty table
The returned role is then handed straight to Auths.insert_new_auth(... role=self.get_user_role(None, user_data) ...). The same file’s regular signup_handler already carries the fix and even documents it: “Insert with default role first to avoid TOCTOU race.” That lesson was never carried over to these two flows. Because DATABASE_ENABLE_SESSION_SHARING defaults to False, each request runs on its own database session, which widens the window rather than narrowing it.
On a fresh instance with LDAP or OAuth enabled, any user who times a login to land concurrently with the legitimate first administrator can win admin for themselves. The exploit is simply firing several authentication requests at once before the first real admin finishes bootstrapping. Every winner lands in the database as a full administrator.
Admin in Open WebUI is total control: all users’ chats and files, system configuration, stored API keys, and every connected LLM backend. What should be a single trusted owner becomes several, one or more of them an attacker, with no way for the legitimate owner to tell which admins were meant to exist.
Make role assignment atomic by inverting the order, exactly as signup_handler already does: insert every new user with DEFAULT_USER_ROLE first, then check whether this account is the only one (get_num_users() == 1) and promote to admin only when that is true. The count is read after the row exists, so two concurrent registrations can never both see themselves as the sole user. For OAuth, that means dropping the count check out of get_user_role() entirely and doing the promotion post-insert in the callback.
Sanaan Fayaz Wani (GitHub sfwani) reported this vulnerability to the open-webui maintainers under coordinated disclosure and is credited as a reporter in GHSA-h3ww-q6xx-w7x3, published 2026-05-11.
All published findings: advisory index.