Skip to content

artifact-canvas: relax HTML policy to html:true + DOMPurify (render safe static HTML) #1042

Closed

Description

@amrmelsayed

Problem

The artifact-canvas renderer uses markdown-it html: false (spir-945 spec D7) as XSS
defense-layer-1, with DOMPurify as layer-2. Side effect: all raw HTML in a document is escaped to
visible text
, so specs/plans/reviews can't use raw HTML tags — <img>, <details>/<summary>,
<kbd>, <sub>/<sup>, HTML tables, alignment wrappers, etc. all render as literal angle-bracket
text. (Standard markdown ![alt](url) images still work; this is specifically about raw HTML tags.)

Proposal

Relax the renderer to html: true + DOMPurify as the sole raw-HTML guard. DOMPurify already
strips the dangerous surface — <script>, event-handler attributes (onerror=, onclick=…),
javascript: / data: URLs — while keeping safe static HTML. Net: richer rendering, same XSS
protection (DOMPurify, plus the webview's nonce-based script-src CSP, which blocks inline script
regardless of the markdown-it setting).

Explicitly still blocked (by design)

JavaScript and interactive elements supplied by document content. Executing a document's embedded
JS in a review surface is the exact XSS vector; DOMPurify + CSP strip it. This issue is about safe
static HTML only — not running document-supplied scripts.

Spec impact

Amends spir-945 D7 (html: false + DOMPurify → html: true + DOMPurify as the guard). This is
a cross-host change: every surface that mounts the canvas inherits it.

Related

Per architect direction, this is being implemented in the current #859 batch rather than deferred.

Activity

  1. added
    area/cross-cutting
    on Jun 13, 2026
  2. self-assigned this
    on Jun 13, 2026
  3. added 2 commits that reference this issue on Jun 13, 2026
  4. amrmelsayed commented on Jun 14, 2026

    @amrmelsayed
    CollaboratorAuthor

    Shipped as part of PR #1045 / pir-859 (commit 689abd2). The artifact-canvas renderer now uses html: true + DOMPurify with the policy locked in packages/artifact-canvas/src/renderer/sanitization.ts. Recorded as a D7 amendment in the #859 plan addendum and in spir-945's review. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/cross-cutting

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions