CVE-2026-45719: Budibase CouchDB Reduce Injection Vulnerability
MODERATECVE-2026-45719 is a MODERATE (CVSS 6.5) couchdb reduce injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Budibase libraries in the npm ecosystem. The issue involves couchdb reduce injection via unsanitized calculation parameter in v1 views api. Remediation is available by upgrading affected packages to version 3.38.1.
CVE-2026-45719 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N).
How to Fix CVE-2026-45719
To remediate this vulnerability, upgrade all affected Budibase dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install @budibase/server@3.38.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @budibase/server
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-45719, inspect your project dependencies using npm:
npm ls @budibase/server
Analyze the terminal output to locate any version of Budibase in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.38.1), your application is affected.
Note: The npm ls @budibase/server command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Budibase, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-45719 Affected Budibase Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@budibase/server
|
npm |
< 3.38.1
|
3.38.1
|
References
Frequently Asked Questions
What is CVE-2026-45719?
Which Budibase versions are affected?
What version fixes CVE-2026-45719?
Is @budibase/server affected?
What is the CVSS score of CVE-2026-45719?
What CWE is associated with CVE-2026-45719?
How can I check npm dependencies for CVE-2026-45719?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-363w-hvwh-w7m6",
"modified" : "2026-06-08T23:51:48Z",
"published" : "2026-05-18T17:47:58Z",
"aliases" : [ "CVE-2026-45719" ],
"summary" : "Budibase: CouchDB Reduce Injection via Unsanitized Calculation Parameter in V1 Views API ",
"details" : "# Security Advisory: CouchDB Reduce Injection via Unsanitized Calculation Parameter in V1 Views API\n\n**Affected Software:** Budibase\n**Affected Component:** `packages/server/src/api/controllers/view/viewBuilder.ts`, `packages/server/src/api/routes/view.ts`\n**CWE:** CWE-94 (Improper Control of Generation of Code)\n**Discovery Date:** 2026-03-24\n\n---\n\n## Summary\n\nThe V1 Views API (`POST /api/views`) accepts a `calculation` parameter from the request body that is interpolated directly into a CouchDB reduce function definition without validation. Although an internal `SCHEMA_MAP` object defines the valid calculation types (`sum`, `count`, `stats`), no actual validation is performed against this map before the value is used in string interpolation.\n\nA user with Builder permissions can inject arbitrary JavaScript code that will be executed within the CouchDB JavaScript engine when the view is queried.\n\n---\n\n## Affected Component\n\n**Route:** `POST /api/views` (V1 legacy views endpoint)\n**File:** `packages/server/src/api/routes/view.ts`, line 45\n\n```js\n.post(\"/api/views\", viewController.v1.save)\n```\n\nNote: This route has no Joi request body validator, unlike the V2 views endpoint which uses `viewValidator()`.\n\n**Vulnerable code:** `packages/server/src/api/controllers/view/viewBuilder.ts`, line 213\n\n```js\nconst reduction = field && calculation ? { reduce: `_${calculation}` } : {}\n\nreturn {\n meta: { field, tableId, groupBy, filters, schema, calculation, ... },\n map: `function (doc) { ... }`,\n ...reduction, // <-- unvalidated calculation string becomes CouchDB reduce\n}\n```\n\n---\n\n## Vulnerability Detail\n\nThe `viewBuilder` function constructs a CouchDB design document view definition. It correctly sanitizes all inputs that flow into the `map` function string (using `JSON.stringify` for field names and a strict `TOKEN_MAP` allowlist for filter operators).\n\nHowever, the `calculation` parameter follows a different path:\n\n1. User submits `calculation` via `POST /api/views` request body\n2. No Joi validator is present on this V1 route\n3. `viewBuilder` receives `calculation` as a raw string\n4. It is interpolated as: `` reduce: `_${calculation}` ``\n5. This reduce definition is saved to a CouchDB design document\n6. When the view is queried, CouchDB evaluates the reduce value\n\nCouchDB's behavior for reduce functions:\n- Values starting with `_` followed by a known built-in (`_sum`, `_count`, `_stats`) are executed as native reducers\n- Any other value is treated as a **JavaScript function string** and executed in CouchDB's SpiderMonkey JS engine\n\nThe `SCHEMA_MAP` object in the same file defines `sum`, `count`, and `stats` as valid keys, but this map is only used for schema construction — it is never used as an input validator for the `calculation` parameter.\n\n---\n\n## Steps to Reproduce\n\n**Prerequisites:** Authenticated session with Builder role permissions.\n\n**1. Send a crafted view creation request:**\n\n```bash\ncurl -X POST https://<budibase-instance>/api/views \\\n -H \"Content-Type: application/json\" \\\n -H \"Cookie: <builder-session-cookie>\" \\\n -d '{\n \"name\": \"test_view\",\n \"tableId\": \"<valid-table-id>\",\n \"field\": \"amount\",\n \"calculation\": \"stats\\\"); } function(keys,values,rereduce){ var data = \\\"\\\"; for(var i in this) { data += i + \\\"=\\\" + this[i] + \\\",\\\"; } return data; } //\"\n }'\n```\n\n**2. Query the created view:**\n\n```bash\ncurl https://<budibase-instance>/api/views/test_view?group=true \\\n -H \"Cookie: <builder-session-cookie>\"\n```\n\n**3. Expected result:** The injected JavaScript function executes in CouchDB's JS context during reduce evaluation. The function can:\n- Enumerate objects available in the CouchDB sandbox\n- Access document data from the reduce `values` parameter\n- Return arbitrary data in the view response\n\n**Simplified test:** To verify the injection point without complex payloads:\n\n```json\n{\n \"name\": \"calc_test\",\n \"tableId\": \"<valid-table-id>\",\n \"field\": \"amount\",\n \"calculation\": \"INVALID_NOT_A_BUILTIN\"\n}\n```\n\nThis produces `reduce: \"_INVALID_NOT_A_BUILTIN\"`. CouchDB will reject this as neither a valid built-in nor a valid function, confirming that arbitrary strings reach the reduce evaluator.\n\n---\n\n## Impact\n\n- **Code execution:** Arbitrary JavaScript runs in CouchDB's SpiderMonkey sandbox\n- **Data access:** The reduce function receives all matching document values, allowing data exfiltration across the database\n- **Scope limitation:** CouchDB's JS sandbox prevents filesystem or network access — this is not OS-level RCE\n- **Authentication required:** Attacker must have Builder role, which already grants significant application access\n- **Persistence:** The injected reduce function persists in the design document and executes on every view query\n\n---\n\n## Recommended Fix\n\nAdd an allowlist validation in `viewBuilder` before the reduce interpolation:\n\n```typescript\nconst VALID_CALCULATIONS = [\"sum\", \"count\", \"stats\"];\n\nif (calculation && !VALID_CALCULATIONS.includes(calculation)) {\n throw new Error(`Invalid calculation type: ${calculation}`);\n}\n\nconst reduction = field && calculation ? { reduce: `_${calculation}` } : {};\n```\n\nAdditionally, add a Joi validator to the V1 views route to match the V2 endpoint:\n\n```typescript\n// In packages/server/src/api/routes/view.ts\n.post(\"/api/views\", v1ViewValidator(), viewController.v1.save)\n```\n\n---\n\n## Additional Context\n\nThe V2 views API (`POST /api/v2/views`) uses `viewValidator()` with Joi schema validation and a separate calculation handling path. This finding is specific to the V1 legacy endpoint which lacks equivalent input validation.\n\nThe `map` function string in the same code is properly protected — all user inputs reaching it are escaped via `JSON.stringify()` or validated against a strict `TOKEN_MAP` allowlist. Only the `reduce` path is affected.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@budibase/server"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.38.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/Budibase/budibase/security/advisories/GHSA-363w-hvwh-w7m6"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-45719"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/Budibase/budibase"
}, {
"type" : "WEB",
"url" : "https://github.com/Budibase/budibase/releases/tag/3.38.1"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-05-18T17:47:58Z",
"nvd_published_at" : "2026-05-27T18:16:26Z"
}
}