Skip to content

fix: sanitize AI review HTML before rendering to prevent stored XSS#3673

Closed
Swately wants to merge 1 commit into
tscircuit:mainfrom
Swately:rep2/sanitize-ai-review-html
Closed

fix: sanitize AI review HTML before rendering to prevent stored XSS#3673
Swately wants to merge 1 commit into
tscircuit:mainfrom
Swately:rep2/sanitize-ai-review-html

Conversation

@Swately

@Swately Swately commented Jun 12, 2026

Copy link
Copy Markdown

ViewAiReviewView renders marked.parse(review.ai_review_text) straight into dangerouslySetInnerHTML. marked doesn't sanitize, so any HTML/script the registry returns in ai_review_text executes in the user's DOM (stored XSS).

Fix: wrap the parsed output in DOMPurify.sanitize(...). dompurify added as a runtime dependency (browser-native, light); regression test added (jsdom + the real DOMPurify pipeline) covering onerror, <script> and javascript: payloads, and confirming normal markdown survives. Full suite green.

Out of scope (separate concern noted in #3376): the postMessage handler in RunFrameWithIframe.tsx lacks an event.origin check — the right fix needs your input on which origins are legitimate, so I left it for a follow-up.

Fixes #3376


Authored with AI assistance, reviewed and submitted under my responsibility.

ViewAiReviewView renders marked.parse(review.ai_review_text) directly into
dangerouslySetInnerHTML. marked does not sanitize, so any HTML/script the
registry returns in ai_review_text executes in the user's DOM.

Wrap the parsed output in DOMPurify.sanitize. Adds dompurify as a runtime
dependency and a regression test (jsdom + the real DOMPurify pipeline)
covering onerror, <script> and javascript: payloads, and confirming normal
markdown survives. Full suite green.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
runframe Ready Ready Preview, Comment Jun 12, 2026 6:55pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been inactive for 1 day since being marked as stale.

@github-actions github-actions Bot closed this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: unsanitized HTML render and unverified postMessage in lib/components/

1 participant