CVE-2026-122244: 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
High CVSS 7.7
- OSV id
- GHSA-r2q3-7m4h-63qg
- Also known as
- CVE-2026-122244
- Published
- Last modified
Affected packages
| Package | Affected versions | Fixed in |
|---|---|---|
| @budibase/server npm |
<= 3.38.1 | after 3.38.1 |
How to fix it
No fix yet. No fixed version of @budibase/server has been released yet.
- Check the advisory and its references below for a workaround or a configuration change that turns off the affected feature.
- Limit exposure: don't pass untrusted input to the affected code path, and keep it off public endpoints if you can.
- Pin away from the affected versions if an older release is not affected, or consider replacing the package.
- Watch for the fix: a free AIssue account checks your lockfiles every day and emails you when a fixed version is released.
Not sure whether your project uses an affected version? Check your lockfile below for free.
Details
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()):
jsonString = jsonString
.replace(/&/g, "&") // no-op: replaces "&" with "&" (should be "&")
.replace(/</g, "<") // no-op (should be "<")
.replace(/>/g, ">") // no-op (should be ">")
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:
- 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.
- 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,
References
- GHSA-r2q3-7m4h-63qg on OSV.dev
- Web: https://github.com/Budibase/budibase/security/advisories/GHSA-r2q3-7m4h-63qg
- Advisory: https://nvd.nist.gov/vuln/detail/CVE-2026-122244
- Web: https://github.com/Budibase/budibase/commit/5f37fb43728639c540cc7233283f1100e9315424
- Package: https://github.com/Budibase/budibase
- Web: https://github.com/Budibase/budibase/releases/tag/v3.50.0
- Web: https://github.com/Budibase/budibase/releases/tag/v4.0.0
Am I affected?
Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.
About this data
Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.