Budibase Privilege Escalation via Role Assignment API
An app-scoped builder in Budibase can exploit a missing authorization flaw in the public role assignment API (`POST /api/public/v1/roles/assign`) to escalate privileges, granting themselves builder access to any other application within the tenant, read/modify data, exfiltrate datasource credentials, and execute arbitrary code via automation steps, compromising the entire tenant's app and data plane in Budibase versions up to and including 3.39.19 and npm/@budibase/server up to 3.38.1.
Budibase versions up to 3.39.19 are vulnerable to a high-severity privilege escalation flaw (GHSA-j9fc-w3mr-x6mv) allowing an app-scoped builder to gain unauthorized builder access to any other application within the tenant. This vulnerability, an an incomplete fix of a previous hardening attempt, stems from a missing authorization check in the POST /api/public/v1/roles/assign API endpoint. Attackers can leverage their existing app-scoped builder privileges to self-assign elevated roles or cross-app builder access, leading to a tenant-wide compromise of app data and the potential for remote code execution via automation steps, as well as exfiltration of stored datasource credentials. The flaw impacts licensed Budibase deployments (Business/Enterprise) where isExpandedPublicApiEnabled is active.
Attack Chain
- An attacker, possessing an app-scoped builder role for
appAbut no global administrative privileges, initiates the attack. - The attacker authenticates and sends a
POSTrequest to the/api/global/self/api_keyendpoint on the Budibase worker, successfully obtaining a public API key, as app-scoped builders havehasBuilderPermissionswhich passes thebuilderOnlymiddleware check. - Using the newly acquired API key and their session cookie, the attacker sends a
POSTrequest to/api/public/v1/roles/assign, setting thex-budibase-app-idheader toappA(their controlled app ID) and including a JSON body specifying{"userIds":["<self>"],"appBuilder":{"appId":"<appB>"}}whereappBis the target application. - The API endpoint's
builderOrAdminmiddleware passes due toisBuilder(user, appA), and thevalidateGlobalRoleUpdatefunction (designed for global roles) ignores theappBuilderattribute, which was not referenced for validation. - The
sdk.publicApi.roles.assignfunction processes the request, addingappBto the attacker'suser.builder.appswithout performing any authorization checks that the caller controlsappB. - The attacker successfully escalates privileges, becoming a builder for
appBand potentially any other app within the tenant. - With builder access to
appB, the attacker can now read/modify all data rows, access and exfiltrate stored datasource credentials, and modify automations to achieve remote code execution viabash,executeScript, orexecuteQuerysteps, leading to tenant-wide app/data-plane compromise.
Impact
A successful exploitation of this vulnerability allows an app-scoped builder to bypass cross-app isolation, gaining builder access to all other applications within the licensed Budibase tenant. This enables the attacker to read and modify sensitive data, exfiltrate stored datasource credentials (e.g., database connection strings, API keys), and create or modify automation rules to execute arbitrary code on the server. The attacker can also assign any data-plane role, including ADMIN, to themselves or any other user within any application. While it doesn't directly grant global admin or builder flags, it effectively leads to a tenant-wide compromise of all app data and functionality.
Recommendation
- Upgrade Budibase deployments to a patched version to remediate the missing authorization checks in the
POST /api/public/v1/roles/assignendpoint. - Implement API gateway or WAF rules to inspect and validate requests to the
/api/public/v1/roles/assignendpoint, specifically checking if theappIdin the request body matches thex-budibase-app-idheader for non-global administrators. - Monitor
webserverlogs for unusual or excessivePOSTrequests to/api/global/self/api_keyand/api/public/v1/roles/assignendpoints from non-global administrator accounts, which could indicate attempts to exploit this vulnerability.