fix(gateway): sandbox workspace assistant-media SVG documents - #1
Open
SebTardif wants to merge 1 commit into
Open
fix(gateway): sandbox workspace assistant-media SVG documents#1SebTardif wants to merge 1 commit into
SebTardif wants to merge 1 commit into
Conversation
Apply the existing image-document sandbox to every assistant-media image, not only files outside allowed roots. Workspace SVG opened as a document otherwise keeps Control UI script-src 'self'. Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
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.
What Problem This Solves
GET /__openclaw__/assistant-mediaapplies the image-document sandbox CSP only when the file is outside allowed roots. A workspace SVG is still served asimage/svg+xmlwithContent-Disposition: inlineand the Control UI CSP (script-src 'self'). Opening that URL as a top-level document is same-origin with Control UI, so a same-origin script in the SVG can run. Outside SVG already getsdefault-src 'none'; sandbox, which blocks that.This change was first reported privately as GHSA-j833-88j9-76q7. The same one-line sandbox fix was prepared on the temporary private fork
openclaw/openclaw-ghsa-j833-88j9-76q7. The advisory was later closed unpublished. The remediating public PR againstopenclaw/openclawis already #144333. This PR is the public record on the SebTardif fork. Do not merge this into forkmainas a substitute for that upstream PR.Why This Change Was Made
A live browser load of the two header policies shows the script-execution gap. Workspace CSP fetched
/probe.jsand/hit. Sandbox CSP did not fetch/probe.js. Apply the existing image sandbox to every assistant-media image, including workspace SVG.User Impact
Workspace diagrams that rely on inline CSS or external SVG resources may render more strictly when opened as a top-level document.
<img>embedding is unchanged. Outside-root images already used this sandbox.Evidence
Live browser (Edge CDP) against a local server that reused the Control UI CSP vs the image sandbox CSP. Same SVG, same script href.
After the header change, workspace SVG byte responses also set
content-security-policycontainingsandbox.Real behavior proof
Behavior or issue addressed: Workspace assistant-media SVG was a same-origin document without the image sandbox, so a same-origin script in that SVG could run. Sandboxed outside SVG could not.
Real environment tested: Windows 11, Edge via CDP on 127.0.0.1:9222, worktree
C:/tmp/oc-f074-publicat the patched tip.Exact steps or command run after this patch:
Evidence after fix: terminal output from the header replay:
Observed result after fix: Control UI CSP lets the SVG load
/probe.jsand post/hit. Image sandbox does not load/probe.js. Workspace SVG now gets that sandbox header.What was not tested: A full Gateway plus Control UI lightbox click with a live operator session.
Summary
Same one-line change as openclaw#144333 (
if (mediaKind === "image")). First filed as GHSA-j833-88j9-76q7 with the fix on the private advisory fork. Public fork record only.