GHSA-25qc-m4pw-2w8r: Budibase: Unauthenticated global-admin & database creation via tenant-confusion bypass of the one-time init guard (`POST /api/global/users/init`)
- Source:
- OSV.dev
- Published:
- Fetched:
- Updated:
- Affects:
- @budibase/server
https://osv.dev/vulnerability/GHSA-25qc-m4pw-2w8r ↗
Budibase: Unauthenticated global-admin & database creation via tenant-confusion bypass of the one-time init guard (`POST /api/global/users/init`) ## Description ### Summary On a self-hosted, single-tenant Budibase instance (`multiTenancy:false`), the public bootstrap endpoint `POST /api/global/users/init` remains fully exploitable **after** the instance has been provisioned. Its "already initialised" guard (`checkAnyUserExists()`) is evaluated inside a **tenant-scoped** database context derived from an **attacker-controlled `tenantId`** in the request body. Because the tenancy layer never constrains that `tenantId` to the only legitimate tenant (`default`) on a single-tenant deployment, an unauthenticated attacker simply supplies any unused tenant name to make the guard see an empty user list, and the endpoint then creates a brand-new CouchDB database (` _global-db`) and a **global-admin** user document (`admin.global = true`, `builder.global = true`) inside it - with no authentication and no CSRF token. This is (a) a bypass of the security control meant to permanently close first-run setup, and (b) an unauthenticated, persistent write primitive that lets an anonymous attacker create an unbounded number of databases and admin-user documents - a resource-exhaustion / denial-of-service vector against the CouchDB datastore, plus creation of latent rogue admin accounts. ### Details Root cause chain (source, tag v3.44.0): 1. `packages/worker/src/api/index.ts:41` - `POST /api/global/users/init` is in `PUBLIC_ENDPOINTS`, so `auth.buildAuthMiddleware(PUBLIC_ENDPOINTS)` marks it `publicEndpoint` and the "no public access to worker" gate (`api/index.ts:159-165`) lets it through **without any session**. It is also in `NO_TENANCY_ENDPOINTS` (`api/index.ts:83`), so the tenancy middleware does **not** pin the request to `default` - the tenant is taken verbatim from the request body - and in `NO_CSRF_ENDPOINTS`. 2. `packages/worker/src/middleware/cloudRestricted.ts:10,25` - the `cloudRestricted` guard only enforces the internal API key when `!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL`. On a self-hosted instance (`SELF_HOSTED=true`) it is a **no-op** (`return next()`), so `cloudRestrictedRoutes` provides no protection here. 3. `packages/worker/src/api/routes/global/users.ts:69-79` - `cloudRestrictedRoutes.post("/api/global/users/init", … controller.adminUser)`. 4. `packages/worker/src/api/controllers/global/users.ts:232` - the handler runs `await tenancy.doInTenant(tenantId, …)` using the **attacker-supplied** `tenantId`. 5. `packages/worker/src/api/controllers/global/users.ts:238` - the only guard, `const userExists = await checkAnyUserExists()`, throws 403 only if a user exists **in the current tenant context**. 6. `packages/worker/src/utilities/users.ts:3-15` - `checkAnyUserExists()` calls `tenancy.getGlobalDB()`, which resolves to ` _global-db`. For any unused `tenantId` this DB is empty → the guard passes → `userSdk.db.createAdminUser(email, tenantId, …)` (`users.ts:247`) creates a full global admin. The defect is **incorrect authorization scoping**: the single-tenant de Affected: npm:@budibase/server No fixed version published yet References: https://github.com/Budibase/budibase/security/advisories/GHSA-25qc-m4pw-2w8r https://nvd.nist.gov/vuln/detail/CVE-2026-122247 https://github.com/Budibase/budibase/commit/362a7fe9aea594531ece1cf15be76cc00bfb88b9 https://github.com/Budibase/budibase https://github.com/Budibase/budibase/releases/tag/v3.50.0 https://github.com/Budibase/budibase/releases/tag/v4.0.0