The gate the whole API depends on
Every authenticated endpoint in Budibase's server runs behind packages/server/src/middleware/authorized.ts. The first executable line of that middleware, on line 94 of the file as shipped in 3.31.4, is:
if (isWebhookEndpoint(ctx) || ctx.internal) {
return next()
}
return next() in koa is "advance to the next middleware in the chain." Nothing else inside authorized() runs: not the user lookup, not the resource-permission resolver, not the role-hierarchy traversal, not the base-permission check, not the CSRF gate. The request arrives at its handler as if authorized() were not installed. The decision rests on a single boolean.
The decision has to exist. Budibase webhook endpoints have their own auth model: the webhook URL embeds an app id and a webhook id, and the handler validates both against the stored record. A site-wide authentication check ahead of those handlers would block the legitimate caller. The structural question is real: is this request actually for a webhook endpoint?
isWebhookEndpoint(ctx) is what answered it.
isWebhookEndpoint asked a different question
In packages/server/src/middleware/utils.ts, in the version 3.31.4 shipped, isWebhookEndpoint read:
const WEBHOOK_ENDPOINTS = new RegExp(
[
"webhooks/trigger",
"webhooks/schema",
"webhooks/discord",
"webhooks/ms-teams",
"webhooks/slack",
].join("|")
)
export function isWebhookEndpoint(ctx: UserCtx) {
return WEBHOOK_ENDPOINTS.test(ctx.request.url)
}
The regex compiles to the alternation webhooks/trigger|webhooks/schema|webhooks/discord|webhooks/ms-teams|webhooks/slack. No ^. No $. No word boundary. RegExp.test() returns true on any substring match.
The target is ctx.request.url. In koa, ctx.request.url is the request line's URL: path and query string concatenated, exactly as the client sent them. The same Koa request object exposes ctx.request.path, the path component segment-parsed. The middleware reached for the unparsed form.
Either decision in isolation would have produced a working gate. An anchored regex applied to the full URL still tests the path, because the URL begins with /api/ and the alternation can only land on a position that begins with webhooks/. A substring regex applied to ctx.request.path still tests only path bytes. The combination is the bypass: an unanchored regex that takes substring matches, run against a string that includes the query, where the query is the caller's.
The function was named isWebhookEndpoint. A webhook endpoint is a structural property of the request: the path component begins with one of five strings. The implementation does not test that property. It tests whether a substring matches anywhere in the URL the client sent. Anywhere includes the query string.
The curl
The nuclei template at projectdiscovery/nuclei-templates/http/cves/2026/CVE-2026-31816.yaml encodes the chain in one request:
POST /api/ta_users/search?/webhooks/trigger HTTP/1.1
Host: <target>
Content-Type: application/json
x-budibase-app-id: <app_id>
{"query":{},"limit":1000}
The HTTP path is /api/ta_users/search. The query string is /webhooks/trigger. Koa's router dispatches by path: it parses the URL, takes the path component, walks the route trie. The route trie matches POST /api/:tableId/search, the row-search endpoint for an in-app table. Path-side, the request is going to row-search, not to a webhook.
authorized() runs first. isWebhookEndpoint(ctx) evaluates the unanchored alternation against ctx.request.url, which is the full string /api/ta_users/search?/webhooks/trigger. The substring webhooks/trigger appears at position 22. The regex matches. The function returns true. The middleware returns next(). The request reaches the row-search handler with no caller identity attached.
ta_users is Budibase's table-id convention for the default Users table that every Budibase app ships pre-populated. The ta_ prefix marks a table document in CouchDB. The handler reads the request body's empty filter ({"query":{},"limit":1000}) as "return up to 1000 rows," queries the table, returns the rows as JSON. The nuclei template's matcher confirms the bypass by checking the response body for email, roleId, and status, the three columns Budibase's default Users table ships with.
The GHSA advisory's own PoC list goes further than the nuclei template. POST /api/tables?/webhooks/trigger creates tables. DELETE /api/tables/<id>/<rev>?/webhooks/trigger deletes them. Datasources, automations, roles, integrations, and views are all reachable the same way. The CVSS vector reads A:N. The advisory's PoC list includes "delete tables." Both statements are about the same bug.
The only precondition is a valid x-budibase-app-id. App IDs are not secrets; the published URL of any Budibase app contains its app id in plain text.
Two errors, two fixes
The fix landed on the branch named bypass-via-webhook-query-param, merged as commit d657d82b on March 5, 2026. The diff against utils.ts is:
const WEBHOOK_ENDPOINTS = new RegExp(
- [
- "webhooks/trigger",
- "webhooks/schema",
- "webhooks/discord",
- "webhooks/ms-teams",
- "webhooks/slack",
- ].join("|")
+ "^/api/webhooks/(trigger|schema|discord|ms-teams|slack)(/|$)"
)
export function isWebhookEndpoint(ctx: UserCtx) {
- return WEBHOOK_ENDPOINTS.test(ctx.request.url)
+ const path = ctx.path || ctx.request.url.split("?")[0]
+ return WEBHOOK_ENDPOINTS.test(path)
}
The regex is anchored at ^/api/webhooks/ and bounded at the trailing (/|$). Even if the haystack were the full URL, the alternation can no longer land on a substring buried in a query string; the only position that satisfies the new pattern is the start of the request path. Separately, the haystack is no longer the full URL: the function takes ctx.path when koa has populated it, falling back to the path-only prefix of ctx.request.url. Even if the regex were still unanchored, the bypass would have nowhere to write.
Either change closes CVE-2026-31816. The developer shipped both. That is the developer's admission that either alone was not trusted.
The test the same PR added reads:
it("does not bypass auth when webhook path appears in query string", async () => {
config.setRequestUrl("/api/tables?/webhooks/trigger")
await config.executeMiddleware()
expect(config.throw).toHaveBeenCalledWith(401, "No user info found")
expect(config.next).not.toHaveBeenCalled()
})
The branch is bypass-via-webhook-query-param. The PR title is Bypass via webhook query param. The test method is does not bypass auth when webhook path appears in query string. Every artifact the vendor's own developer touched while landing the fix names the bug class.
Predicate stringifies the object, again
This is the predicate-stringifies-the-object shape. A security predicate intends to test one field of a structured value. The implementation tests a substring or equality match against the value's stringified form. The string representation includes other attacker-controlled fields the predicate did not mean to read. The bypass writes the gate's allow-string into one of those fields.
Budibase is the fourth exhibit of the pattern in the catalog. ChurchCRM's AuthMiddleware ran str_contains($request->getUri(), 'api/public') against PSR-7's __toString() and accepted the allow-string from a query parameter. PaperCut's SecurityRequestFilter ran an allowlist match against HttpServletRequest::getRequestURI() and accepted the allow-string from a Servlet path parameter. HPE Aruba's AOS-CX nginx gate ran the regex ^/rest/(|v.*/)login against the URI as a flat string and accepted login because PCRE's . ignored segment boundaries.
Each is the same shape in a different framework's clothes. ChurchCRM was PHP / PSR-7 and the stringification was __toString(). PaperCut was Java / Servlets and the stringification was getRequestURI(). AOS-CX was nginx / PCRE and the stringification was a hand-written regex whose dot consumed /. Budibase is JavaScript / Koa and the stringification is ctx.request.url. The structural fact reads the same in all four: any security predicate that uses a string operator against an object with more than one property worth reading admits the gate's allow-string from any of those properties.
Koa exposed the structurally correct accessor the entire time. It is called ctx.path. The patched code reaches for it.
PoC: projectdiscovery/nuclei-templates