Summary
Open WebUI's LDAP and OAuth authentication flows contain a Time-of-Check-Time-of-Use (TOCTOU) race condition in the logic that assigns the first-user admin role.
Under concurrent signups, this race can allow an unintended user to gain administrative privileges when they should have received only a default role.
Affected context
This vulnerability appears in Open WebUI deployments that:
- Use LDAP or OAuth as authentication providers
- Rely on "first user becomes admin" semantics or similar automatic role-bootstrapping logic
- Allow concurrent or closely timed signup/login attempts
- Do not enforce a transactional, single-path role assignment for initial admin creation
The regular username/password signup handler was explicitly hardened against TOCTOU, but the LDAP and OAuth code paths still follow the older, race-prone pattern.
Exploit preconditions
- Attack surface: Application authentication endpoints (LDAP and OAuth flows).
- Required access: Ability to initiate new user signups/logins through LDAP or OAuth; no prior administrative access is required.
- Trigger point: The moment the system checks for "first user/admin existence" and then separately assigns roles based on that check.
- Why exploitation is possible: The check for whether an admin exists and the subsequent role assignment are not performed atomically. Concurrent authentication requests can interleave between these two steps, allowing a non-intended user to receive the admin role because multiple code paths believe they are handling the "first" user.
Why this happens
The underlying issue is a combination of CWE-269: Improper Privilege Management and CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization (Race Condition).
The system performs a check (e.g., "does an admin already exist?") and then, in a separate step, uses that result to decide which role to assign. In the LDAP and OAuth flows, this occurs without proper locking or transactional safeguards, enabling a TOCTOU race. Multiple concurrent requests may see the same "no admin yet" state and then assign elevated privileges based on stale information. The regular signup handler was refactored to insert users with a default role first, but the same pattern was not applied to the LDAP and OAuth paths, leaving them vulnerable.
Potential impact
- An unintended user may become an administrator during initial system setup.
- Multiple users could simultaneously obtain administrative privileges when only one was intended.
- Administrative capabilities (user management, configuration changes, model and data access) can be misused to alter system behavior or exfiltrate sensitive information.
- An attacker controlling an LDAP or OAuth account could leverage the race to gain full control of the Open WebUI instance.
General mitigation guidance
Effective mitigation typically focuses on atomic privilege decisions and strong synchronization around bootstrap logic:
- Design role assignment for the first admin as a single, atomic operation that cannot be interleaved with other signups.
- Insert new users with a non-privileged, default role first, and only then elevate a single, well-defined user after re-checking the current state.
- Centralize and reuse the hardened signup logic across all authentication providers (local, LDAP, OAuth) to avoid divergent security behavior.
- Ensure that privilege changes (especially admin grants) are idempotent and guarded by clear invariants, such as "at most one bootstrap admin."
- Apply least-privilege defaults for new identities, requiring explicit, deliberate elevation paths rather than automatic admin assignment wherever possible.
How teams detect issues like this
Identifying this kind of issue generally involves code-centric and workflow-aware review:
- During static analysis or manual review, look for patterns where:
- The system queries "is there an admin / is this the first user?" and then, in a separate call, assigns roles.
- Different authentication flows implement this logic separately, leading to inconsistent safeguards.
- Flag logic that depends on the "first user" pattern without transactional safeguards, especially under concurrent request handling.
- Use automated tests or fuzzing that simulate concurrent signups through different auth providers to reveal unexpected multiple-admin outcomes.
- Incorporate policy checks (in CI/CD or code review templates) that require any role-assignment logic to be shared, centralized, and concurrency-safe.

