Summary
Budibase Cloud's view filtering implementation contained an unsafe eval() call that allowed any authenticated user to run arbitrary JavaScript on the server.
When a user supplied a custom view map function, the server evaluated it directly, enabling access to sensitive environment variables and backend services within the app-service pod.
Affected context
This vulnerability occurs in Budibase Cloud (SaaS) deployments that use the in-memory view implementation in packages/server/src/db/inMemoryView.ts.
It is triggered when user-defined view map functions are passed to the server for filtering and are executed via eval() in the Node.js runtime.
Self-hosted Budibase instances relying on native CouchDB views do not share this execution path and are not affected under the described conditions.
Exploit preconditions
- Attack surface: Budibase Cloud API/interface that accepts view filtering or custom view map functions.
- Required access: Any authenticated Budibase Cloud user account, including free-tier tenants.
- Trigger point: Submission or modification of a view filter/map function that the server processes and evaluates for in-memory views.
- Why exploitation is possible: The server passes user-controlled JavaScript directly into
eval()without adequate validation, sandboxing, or restriction, effectively granting the user the ability to run arbitrary code in theapp-serviceprocess context.
Why this happens
The bug stems from executing user-supplied JavaScript in a highly privileged server process using eval() without robust validation or isolation.
This maps primarily to CWE-94: Improper Control of Generation of Code ('Code Injection'), where attackers can inject and execute code by influencing dynamically constructed scripts.
It is also related to CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code, as the dynamic evaluation mechanism treats user input as code, and CWE-20: Improper Input Validation, because the system assumes benign input and does not constrain what the map function is allowed to do.
In abstract, the insecure pattern is: treat user-specified "logic" as trusted and execute it via eval() in the same environment that holds secrets and privileged capabilities.
Potential impact
- Execution of arbitrary JavaScript code on the server in the
app-servicepod context. - Extraction of sensitive environment variables such as
INTERNAL_API_KEY,JWT_SECRET, CouchDB admin credentials, and cloud provider keys. - Direct access to the backing CouchDB instance, including enumeration of tenant databases.
- Reading user records, including email addresses and potentially other application data.
- Use of internal API keys and secrets to pivot to other internal services or infrastructure.
- Impersonation of users or forging of tokens if JWT or auth-related secrets are exposed.
- Potential large-scale data exfiltration or multi-tenant data exposure within the affected environment.
General mitigation guidance
Effective mitigation focuses on removing dynamic code execution of user-controlled input and tightening trust boundaries around server-side logic:
- Replace
eval()-based execution of user-defined functions with declarative, data-driven filters (e.g., query builders, whitelisted operators, or expression interpreters that treat input as data, not code). - Where custom logic is necessary, use constrained execution environments or sandboxed interpreters with strict capability limits, rather than running code in the main server process.
- Enforce strong input validation and structural schemas for any "view" or "map" definitions; allow only a limited, well-defined subset of operations.
- Segregate sensitive secrets from application processes that must process user-supplied "logic," using separate services, minimal-privilege credentials, and secret-scoping.
- Apply least-privilege principles for pods and services: ensure that the process handling user-defined filters has only the minimal environment variables and permissions it truly needs.
- Regularly review use of dynamic evaluation mechanisms (
eval,Function,vmin Node.js, or similar constructs in other languages) and remove or isolate them as part of secure coding standards.
How teams detect issues like this
Detection and prevention can be supported through a combination of code-level analysis and runtime monitoring:
- Static analysis: Configure SAST tools or custom linters to flag any use of unsafe dynamic evaluation functions (
eval,new Function,vm.runInThisContext, etc.) in server-side code, especially where arguments are derived from request data. - Code review practices: Establish code review checklists that explicitly question any dynamic code execution, custom scripting features, or user-configurable logic, requiring justification and sandboxing.
- Configuration and policy enforcement: Use organizational coding standards and pre-commit hooks to prevent introduction of
eval()and similar APIs in backend code paths. - Runtime monitoring: Instrument logging around view execution and server-side dynamic behavior to detect anomalous, complex, or suspicious view definitions and unexpected errors indicative of code injection attempts.
- Secret access monitoring: Track access to environment variables and backend databases to identify unusual patterns that could indicate exploitation or reconnaissance.

