Security
What the editor already blocks, and a Content-Security-Policy for an app that embeds it.
The editor treats document JSON, pasted HTML, and framed URLs as untrusted. This page is the policy for an app that mounts it. Link previews and comments are not in the editor yet, so there is no unfurl fetch and no comment HTML to sanitize.
What is already checked
- Links and media
src.javascript:,vbscript:, anddata:URLs other thandata:image/png,jpeg,gif, orwebpare removed from link marks and from media and link blocks, including JSON import and collaboration updates. New tab links userel="noopener noreferrer"andtarget="_blank". - Pasted HTML. The schema keeps headings, lists, tables, links, code, and images. Unknown tags, event handlers, and a Word
cid:image do not become asrc. See the paste fixtures undereditor/src/test/fixtures/paste/. - Embeds. An embed iframe is rendered only when the URL is on the add-on's allowlist. The frame is
sandbox="allow-scripts allow-presentation allow-popups"withreferrerpolicy="no-referrer".allow-same-originis omitted, so a page on your own host still cannot read the editor's origin. - PDF preview. The preview iframe has no
allow-scriptsand usesreferrerpolicy="no-referrer". The Open file link is the fallback when a browser will not paint a PDF in that frame. - YouTube and Vimeo. Those players are iframed with
referrerpolicy="strict-origin-when-cross-origin". They are not sandboxed: the player does not run insideallow-scriptswithoutallow-same-origin. - Whiteboard import. A saved Excalidraw scene keeps drawing elements, the view settings the editor persists, and image files whose
dataURLpasses the same check as other media. SVG andjavascript:file data are dropped. - Uploads. The example server refuses SVG and HTML types, stores a generated name, sends
X-Content-Type-Options: nosniff, and deletes a file whose first bytes are SVG, HTML, or XML even when the client sentimage/png. Other files are served withContent-Security-Policy: default-src 'none'; sandbox, except PDFs, which Chrome will not render under a CSP sandbox.
Content-Security-Policy
Put this on the page that mounts the editor. Tighten frame-src to the hosts you actually embed.
default-src 'self';
script-src 'self';
style-src 'self' 'unsafe-inline';
img-src 'self' data: blob: https:;
media-src 'self' blob: https:;
font-src 'self' data:;
connect-src 'self' https:;
frame-src https://www.youtube.com https://www.youtube-nocookie.com https://player.vimeo.com;
object-src 'none';
base-uri 'self';
form-action 'self'style-src includes 'unsafe-inline' because KaTeX and the whiteboard set styles on elements. img-src allows data: and blob: for pasted images and in-progress uploads. Add your upload host to img-src, media-src, and connect-src. If you allow other embed domains, add them to frame-src and to the embed allowlist together.
Still yours to configure
- The embed allowlist. An empty list renders the URL as text.
- Upload authentication.
POST /api/uploadis off untilENABLE_UPLOADS=true, and it requires a Bearer token unlessUPLOADS_ALLOW_ANONYMOUSis set for local development. - Serving user files from a different origin than the app, so a missed sniff cannot share the app's cookies.