Summary
Grist prior to version 1.7.15 improperly embedded user-controlled values into server-rendered pages and inline scripts without adequate escaping, enabling both stored and reflected cross-site scripting (XSS).
When a victim opens a manipulated document or OAuth2 flow page, injected JavaScript can run in their authenticated Grist session, allowing an attacker to read or modify data and change sharing settings.
Affected context
The vulnerability arises in Grist's web interface wherever user-controlled content is rendered into HTML or inline JavaScript without strict output encoding.
This includes:
- Document names and descriptions displayed on the main application page for other users
- The OAuth2 end-of-flow page reflecting the
openerOriginrequest parameter
The issue appears when Grist is served over the web and users with document edit rights or the ability to influence request parameters can supply crafted values that end up unescaped in the page.
Exploit preconditions
- Attack surface: Grist web UI pages, specifically:
- Main application pages showing document metadata
- OAuth2 flow completion pages using
openerOrigin - Required access:
- For stored XSS: ability to edit a document's name or description
- For reflected XSS: ability to send crafted links or requests containing a malicious
openerOriginparameter - Trigger point: A victim user loads the affected Grist page in a browser while authenticated.
- Why exploitation is possible: User-controlled values are inserted directly into HTML or inline scripts without sufficient output encoding or context-aware escaping, allowing them to be interpreted as executable JavaScript.
Why this happens
The underlying issue is context-insensitive output of untrusted data into HTML and inline JavaScript, corresponding to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting) and related to CWE-116: Improper Encoding or Escaping of Output.
Grist's server-side templates rendered document metadata and request parameters into the DOM and script blocks without consistently escaping characters that have special meaning in HTML and JavaScript contexts.
This insecure pattern allows elements like <script>, event handlers, or injected JavaScript fragments to be treated as code rather than data when the page is rendered in the browser.
Potential impact
- Injected scripts can read sensitive data visible in the victim's Grist workspace.
- An attacker may modify or delete documents and spreadsheet contents through the victim's session.
- Sharing settings and access rules can be altered, potentially escalating a document editor to owner-level privileges.
- Additional users could be targeted by propagating malicious content or links, amplifying compromise across the organization.
- Browser-side actions such as redirecting users, phishing overlays, or silent data exfiltration can occur in the Grist origin.
General mitigation guidance
Effective mitigation centers on strict, context-aware output encoding and minimizing inline scripting risk.
Useful patterns include:
- Applying robust output encoding routines for all user-controlled data before rendering into HTML, JavaScript, or attribute contexts, ensuring special characters cannot break out into executable code.
- Avoiding inline scripts and event handlers, instead using external scripts that operate on data attributes or safely encoded content.
- Separating data from code by using structured APIs (e.g., JSON responses and DOM templating) that treat user input purely as data.
- Establishing a default-deny templating strategy where any variable interpolated into views passes through a standard escaping layer.
- Limiting the ability to store script-like content in fields that are widely displayed, combined with role-based controls to restrict who can edit high-impact metadata.
How teams detect issues like this
Detection typically involves a combination of code-level and behavioral analysis:
- Static analysis rules that flag direct insertion of request parameters or user-controlled fields into templates, inline scripts, or
innerHTMLwithout encoding. - Code review practices focusing on server-rendered views for improper use of templating engines, missing escaping filters, and unsafe concatenation of HTML/JavaScript.
- Security policies requiring that all new UI components use standardized escaping helpers or safe templating frameworks, enforced via CI checks.
- Automated application security testing (DAST) configured to probe pages with common XSS payload patterns and verify that user input is neutralized in responses.

