Summary
Budibase's Text component, when used in Markdown mode, renders user-controlled content directly into innerHTML without sanitization, creating a stored cross-site scripting (XSS) condition.
Any database column bound to this component becomes a persistent XSS sink for users with write access, potentially allowing arbitrary script execution in other users' browsers.
Affected context
This vulnerability arises in Budibase applications that:
- Use the Text component in Markdown mode
- Bind the component to database columns that BASIC app users with WRITE permission can modify
- Render this content for other users (including higher-privileged builders or admins) in a browser
The issue is located in packages/bbui/src/Markdown/MarkdownViewer.svelte, where marked.parse(markdown) output is assigned directly to innerHTML without sanitization or HTML filtering.
Exploit preconditions
- Attack surface: Web UI of Budibase applications using the Markdown Text component
- Required access: BASIC app user account with WRITE permission on a table column bound to a Markdown Text component
- Trigger point: Viewing of the affected page or component by any user whose browser renders the stored Markdown content
- Why exploitation is possible: The Markdown rendering pipeline (
marked.parse) returns HTML that is written directly toinnerHTMLwithout sanitation or context-aware encoding, allowing embedded scripts or event handlers to execute in the viewer's browser.
Why this happens
The underlying issue is an improper neutralization of input before using it in a web page, mapped to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
The Markdown viewer treats user-supplied content as trusted and:
- Converts it to HTML with
marked.parse(markdown) - Assigns the resulting HTML directly to
innerHTMLin Svelte
Without a sanitization step or context-aware escaping, hostile payloads embedded in Markdown are preserved and executed by the browser.
Architecturally, the bug stems from coupling rich-text/Markdown rendering with raw HTML injection, without enforcing an invariant that all HTML sinks are protected by an HTML sanitizer or strict allowlist.
Potential impact
- Execution of arbitrary JavaScript in the context of the affected Budibase app
- Session hijacking or theft of authentication tokens stored in accessible cookies or web storage
- Unauthorized actions performed on behalf of a victim user via their browser (e.g., modifying data, changing configurations)
- Defacement or manipulation of application UI to mislead users or facilitate phishing
- Lateral movement to other parts of the application through CSRF-like interactions initiated from the victim's browser
General mitigation guidance
Effective mitigation focuses on treating Markdown and HTML output as untrusted and enforcing consistent output encoding policies:
- Introduce a robust HTML sanitization step between Markdown parsing and
innerHTML, using a well-maintained sanitizer with a strict, minimal allowlist of tags and attributes. - Avoid writing arbitrary HTML to
innerHTMLwherever possible; prefer framework-level rendering APIs that escape content by default. - Distinguish between trusted and untrusted rich text data, and only allow raw HTML output for content produced by highly trusted sources under explicit review.
- Apply content security policies (CSP) that reduce XSS impact, for example by disallowing inline scripts and restricting script sources, recognizing that CSP is a defense-in-depth control.
- Enforce the principle of least privilege for app users and roles so that only necessary users can write to fields that are displayed as rich content.
How teams detect issues like this
Teams can detect similar vulnerabilities by examining both code and behavior:
- Static analysis patterns: Search for assignments to
innerHTML,outerHTML, or similar sinks, especially where data originates from user inputs or database fields, and check for absent or weak sanitization. - Markdown/HTML pipeline review: Inspect Markdown rendering components to ensure they include a sanitizer or safe rendering mode before output reaches the DOM.
- Code review checklists: Add explicit review questions around any feature that uses rich text, WYSIWYG editors, or Markdown parsing to verify output encoding and sanitization.
- Automated security testing: Use dynamic scanners or security testing tools configured to inject XSS payloads into rich-text fields and observe whether the payload is stored and executed.
- Policy enforcement in CI/CD: Integrate lint rules or SAST tools that flag direct DOM injection patterns and require justification or compensating controls.

