fix(frontend): XSS hardening — SVG sanitization, iframe sandbox, workspace CSP (WS1)#1391
Open
jeremyeder wants to merge 12 commits intomainfrom
Open
fix(frontend): XSS hardening — SVG sanitization, iframe sandbox, workspace CSP (WS1)#1391jeremyeder wants to merge 12 commits intomainfrom
jeremyeder wants to merge 12 commits intomainfrom
Conversation
…space CSP (SEC-2sl.1) - SEC-2sl.1.1: Replace dangerouslySetInnerHTML SVG rendering with a blob URL <img> approach via a new SvgBlobImage component, blocking all script execution in SVG files - SEC-2sl.1.2: Remove allow-same-origin from iframe sandbox attribute, preventing sandboxed HTML content from escaping the sandbox and accessing the parent origin - SEC-2sl.1.3: Add Content-Security-Policy: sandbox; script-src 'none' response header for HTML and SVG workspace files served on the same origin, blocking stored XSS Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
✅ Deploy Preview for cheerful-kitten-f556a0 canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dangerouslySetInnerHTMLSVG rendering infile-content-viewer.tsxwith a newSvgBlobImagecomponent that creates a blob URL and renders via<img>. Blob URLs are opaque to the browser's script engine, so embedded<script>,onload, and<foreignObject>payloads cannot execute.allow-same-originfrom the iframesandboxattribute in the HTML viewer tab. Keeping onlyallow-scriptsprevents sandboxed content from escaping the sandbox and accessing parent-origin storage, cookies, or DOM.Content-Security-Policy: sandbox; script-src 'none'response header in the workspace file route for HTML, HTM, and SVG extensions. This neutralizes stored XSS from workspace files served on the same origin without changing Content-Type or inline display behaviour.Files changed
components/frontend/src/components/file-content-viewer.tsxcomponents/frontend/src/app/api/projects/[name]/agentic-sessions/[sessionName]/workspace/[...path]/route.tsTest plan
<script>alert(1)</script>to a workspace; confirm it renders as an image with no alert.allow-scriptsis present) but has no access towindow.parentordocument.cookieof the app..htmlor.svgworkspace file directly via the API route; confirm theContent-Security-Policyresponse header is present with valuesandbox; script-src 'none'..pngworkspace file; confirm no CSP header is added.anytypes were introduced (checked via convention grep).🤖 Generated with Claude Code