Summary
Budibase's authenticated middleware used unanchored regular expressions against the full request URL, including query strings, to decide whether an endpoint required authentication.
By appending a public (no-auth) path as a query parameter, an attacker could trick the middleware into treating protected endpoints as public, gaining access to sensitive API functionality without valid credentials.
Affected context
This vulnerability appears in Budibase deployments where the Koa-based authenticated middleware evaluates public endpoint patterns using regular expressions against ctx.request.url.
Because ctx.request.url includes the query string and the regex patterns are not anchored to the start of the path, any route that merely contains a public path fragment in the query portion can be misclassified as public.
Environments exposing Budibase's API endpoints over the network, especially those holding sensitive data or administrative operations, are particularly affected.
Exploit preconditions
- Attack surface: HTTP(S) API endpoints exposed by Budibase (e.g.,
/api/global,/api/system, or other protected routes). - Required access: Network access to the Budibase instance; no valid authentication credentials are required if the attacker can craft URLs.
- Trigger point: The authenticated middleware inspects
ctx.request.urland applies unanchored regex checks to determine whether an endpoint should be exempt from authentication. - Why exploitation is possible: Public (no-auth) endpoint patterns are matched against the entire URL, including the query string, using unanchored regular expressions. Attacks are possible because the presence of a public endpoint path anywhere in the URL is enough to bypass authentication, even when the actual request path targets a protected resource.
Why this happens
The core issue is an improper authentication check stemming from unsafe pattern matching logic in the middleware.
Instead of performing strict, path-only comparisons with clear anchoring (e.g., matching from the beginning of the path and excluding query parameters), the middleware uses unanchored regular expressions against the full ctx.request.url.
In Koa, ctx.request.url combines the path and query string, so a crafted URL like POST /api/global/users/search?x=/api/system/status causes the regex for /api/system/status/ to match inside the query component.
This behavior aligns with CWE-287: Improper Authentication, where authentication decisions are made with flawed checks that can be bypassed by manipulating request formats and inputs.
Potential impact
- Attackers may access protected API endpoints without providing valid credentials.
- Sensitive user or system information could be retrieved via administrative or internal APIs.
- Unauthorized changes to application configuration, users, or data records can be made.
- Privilege escalation may occur if administrative-only endpoints are exposed in this way.
- Logging and monitoring systems may misinterpret attacker actions as legitimate public traffic, complicating incident response.
General mitigation guidance
Effective mitigation focuses on tightening how authentication decisions are made and reducing ambiguity in URL handling:
- Restrict authentication checks to the normalized request path, explicitly excluding query strings and fragments when determining protection level.
- Use anchored pattern matching (e.g.,
^/api/system/status(/|$)), or exact path lists, for endpoints that are intended to be public. - Centralize route protection logic and avoid relying on partial string matches or broad regexes for security-critical decisions.
- Implement a deny-by-default policy for endpoints: consider new or unclassified routes protected unless explicitly marked as public.
- Apply defense-in-depth by layering authorization checks at the handler or controller level, not solely in middleware pattern matching.
How teams detect issues like this
To detect similar vulnerabilities, organizations can combine code-level review with automated analysis:
- Static analysis: Search for authentication-related middleware that uses regexes or substring checks against full URLs (
ctx.request.url,req.url, etc.) instead of normalized paths, especially when deciding whether to enforce authentication. - Code review: Flag logic where public vs. protected routes are distinguished by pattern matching on URLs rather than explicit route registration or configuration.
- Security tests: Add automated tests that probe protected endpoints with appended query parameters containing known public paths, verifying that access is still denied.
- Policy enforcement: Introduce coding standards requiring that authentication and authorization be based on explicit route metadata or configuration, and integrate linters or custom rules into CI to enforce this.

