GHSA-c54j-xp92-wh28: Budibase: Builder-to-Admin Privilege Escalation via onboardUsers Endpoint Without SMTP Configuration
SummaryThe `POST /api/global/users/onboard` endpoint is protected by `workspaceBuilderOrAdmin` middleware, allowing any user with builder permissions to access it. When SMTP email is not configured (the default for self-hosted Budibase instances), this endpoint bypasses the admin-restricted invite flow and directly creates users via `bulkCreate`, accepting arbitrary `admin` and `builder` role assignments from the request body. A builder-level user can create a new global admin account and receive the generated password in the response, achieving full privilege escalation.DetailsThe vulnerability stems from a mismatch between the authorization level of the `onboardUsers` endpoint and the user-creation capabilities it exposes when SMTP is not configured.**Route definition** (`packages/worker/src/api/routes/global/users.ts:93-109`):Compare with the `invite` and `inviteMultiple` endpoints which are correctly admin-only:**Controller** (`packages/worker/src/api/controllers/global/users.ts:601-630`):**Middleware pass-through** (`packages/backend-core/src/middleware/workspaceBuilderOrAdmin.ts:10-26`):In the worker context (`env.isWorker()` is `true`), when there is no `workspaceId` parameter in the request (which there isn't for the onboard endpoint), the middleware at line 19 checks `!workspaceId && env.isWorker()` — this is `true`, so it falls through to line 21 which only checks `hasBuilderPermissions`. Any global builder passes.**Validation gap** (`buildInviteMultipleValidation` at line 37-45): The Joi schema validates `userInfo` as `Joi.object().optional()` with no constraints on its contents, so `admin` and `builder` fields pass through.**No downstream check**: `bulkCreate` and `buildUser` do not strip or validate admin/builder fields — they are written directly to the user document in CouchDB.PoC**Prerequisites:** A self-hosted Budibase instance (default: no SMTP configured) and a user account with builder-level access.**Step 1:** Authenticate as a builder user and obtain the session cookie:**Step 2:** Create a new global admin user via the onboard endpoint:**Expected response** (includes the generated password):**Step 3:** Login as the new admin:The attacker now has full global admin access.Impact**Privilege escalation:** Any builder-level user can escalate to global admin on self-hosted Budibase instances without SMTP configured (the default deployment).**Full platform compromise:** Global admin can access all apps, all data sources, manage all users, delete apps, and modify platform configuration.**Credential exposure:** The generated password is returned in the HTTP response, giving the attacker immediate access to the new admin account.**Stealth:** The created user appears as a legitimately onboarded user, making detection difficult without audit log review.**Wide applicability:** Self-hosted Budibase instances commonly run without SMTP configuration, making this the default-exploitable path.Recommended FixMove the `onboardUsers` route from `builderOrAdminRoutes` to `adminRoutes` to match the authorization level of `invite` and `inviteMultiple`:Additionally, the `onboardUsers` controller should validate that the caller has sufficient permissions to assign the requested role level. Even admin users should not be able to create users with roles exceeding their own. Consider adding explicit validation in the controller:
CVSS v3.1: 8.8