Summary
A JSON injection flaw in Budibase allows unauthenticated visitors of a published app to tamper with query bodies and filters sent to backing data sources.
When a builder exposes PUBLIC read or write queries, crafted parameter values can expand filters to match entire collections, enabling mass data disclosure and modification in a single request.
Affected context
This vulnerability affects Budibase deployments where builders have published queries with a PUBLIC role against data sources such as MongoDB, CouchDB, Elasticsearch, DynamoDB-PartiQL, or REST endpoints that accept JSON bodies.
The issue arises when query parameters are interpolated directly into JSON query templates and parsed without robust escaping of JSON metacharacters, while access control middleware short-circuits for PUBLIC queries and CSRF protections are not applied on this path.
Exploit preconditions
- Attack surface: The POST
/api/v2/queries/:queryIdendpoint exposed by any published Budibase app. - Required access: No authentication or valid session is needed; knowledge of the public app URL and its
x-budibase-app-idvalue suffices. - Trigger point: Submission of crafted query parameters that include closing quotes and additional JSON keys, causing the parsed filter object to be reshaped.
- Why exploitation is possible: Parameter values are substituted into raw JSON bodies and then parsed; the validator only blocks Handlebars markers and fails to escape JSON metacharacters, so attackers can inject extra fields that override builder-defined filters and broaden query scope.
Why this happens
The core bug stems from unsafe construction of JSON query bodies using direct string substitution of untrusted parameters followed by JSON.parse, without proper encoding or structural validation.
Because the validator focuses on rejecting template syntax ({{, }}) rather than enforcing strict JSON escaping, attacker input can break out of intended value positions and introduce new keys or operators.
This pattern maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, generalized here as injection into a query language, and CWE-943: Improper Neutralization of Special Elements in Data Query Logic, where user-controlled data is permitted to influence query structure and filter semantics.
Potential impact
- Unauthenticated visitors may read every document in affected collections.
- Attackers could modify every document in a collection via PUBLIC write queries.
- Data integrity can be compromised through bulk updates or overwrites.
- Confidential data stored behind the app may be exfiltrated at scale.
- Application behavior and analytics built on the data can be subtly or overtly poisoned.
General mitigation guidance
Effective mitigation centers on treating query parameters strictly as data, never as structural components of query logic.
Builders and platform developers can:
- Use structured parameter binding APIs that construct filter objects programmatically instead of interpolating raw JSON strings.
- Enforce rigorous escaping or encoding of JSON metacharacters and disallow any syntax that alters object structure or operators.
- Apply least-privilege principles to PUBLIC queries, avoiding broad read/write operations and limiting accessible fields and actions.
- Introduce server-side validation that checks filters against a schema or allowlist of permitted operators, rejecting unexpected keys.
- Ensure that public-facing query execution paths are protected by CSRF defenses where appropriate and do not bypass authorization middleware.
How teams detect issues like this
Detection typically involves combining code-level and configuration-level scrutiny:
- Static analysis or linters can flag patterns where
JSON.parseis used on strings built via concatenation or template substitution of request parameters. - Code review should highlight any query construction logic that accepts untrusted input and directly feeds it into data source drivers, such as Mongo
collection.find()orupdateMany()calls. - Configuration reviews of Budibase apps can identify PUBLIC queries with broad filters or write actions and prioritize them for hardening.
- Logging and security monitoring can watch for anomalous query traffic from unauthenticated sources, especially requests that return unusually large result sets or update many documents.

