fix(server): sandbox user-provided SVGs - #5916
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
ApprovabilityVerdict: Approved 457efa6 This PR adds standard security hardening by sandboxing user-provided SVG files with restrictive CSP headers to prevent XSS attacks. The change is small, well-tested, and follows established security best practices for handling untrusted SVG content. You can customize Macroscope's approvability policy. Learn more. |
## What's Changed * fix(web): thread title button no longer eats the drag area by @nathangerday in pingdotgg/t3code#5857 * fix(web): unify usage page chrome by @t3-code[bot] in pingdotgg/t3code#5823 * fix(shell): add ~/.local/bin to the Windows CLI resolver so native-installed providers are found by @arhxam in pingdotgg/t3code#5074 * fix(web): match settings search shortcut styling to command palette's by @UtkarshUsername in pingdotgg/t3code#5841 * fix(mobile): long-pressing a thread row no longer navigates into the thread by @juliusmarminge in pingdotgg/t3code#5901 * fix(server): usage no longer double-counts forked Codex sessions by @t3dotgg in pingdotgg/t3code#5887 * fix(server): sandbox user-provided SVGs by @t3dotgg in pingdotgg/t3code#5916 * fix(web): match usage titlebar text styling by @t3-code[bot] in pingdotgg/t3code#5897 ## New Contributors * @nathangerday made their first contribution in pingdotgg/t3code#5857 **Full Changelog**: pingdotgg/t3code@v0.0.33-nightly.20260809.1047...v0.0.33-nightly.20260810.1054 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.33-nightly.20260810.1054
User-provided SVGs are served from signed URLs on the app origin. Opening one directly could run active SVG content with access to that origin.
This adds a restrictive Content Security Policy to SVG asset responses. Inline SVG styles still render, while scripts, external loads, and same-origin access are blocked. Raster asset responses are unchanged.
Tests:
vp test run apps/server/src/http.test.tsMade with GPT-5.6 using the Codex harness in T3 Code.
Note
Medium Risk
Targets a real XSS/origin-abuse vector on user content, but the change is limited to response headers on the asset route and is covered by unit tests.
Overview
User-uploaded SVGs served from signed asset URLs now get a restrictive Content-Security-Policy so opening them directly cannot run scripts or access the app origin.
A shared
assetResponseHeadershelper centralizes asset response headers:.svgpaths (case-insensitive) adddefault-src 'none'; style-src 'unsafe-inline'; sandboxon top of existing private cache andnosniff. Raster and other assets keep the same headers as before, with no CSP.The signed asset
GETroute uses this helper instead of inline header objects. Tests cover SVG vs PNG behavior.Reviewed by Cursor Bugbot for commit 457efa6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add CSP sandbox header to SVG assets served by the asset route
Adds a
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandboxheader to responses for.svgfiles (case-insensitive) to prevent script execution in user-provided SVGs. Header logic is centralized in a new exportedassetResponseHeadersfunction in http.ts. Non-SVG assets continue to receive onlyCache-ControlandX-Content-Type-Optionsheaders.Macroscope summarized 457efa6.