fix(security): add worker-src to CSP so alphaTab-based plugins can render - #68
Conversation
…nder The baseline CSP headers added in 81837ec (#44, XSS fix) set script-src, style-src, img-src, font-src, media-src, and connect-src, but no worker-src. Per CSP fallback rules, workers then fall back to script-src, which allows 'self'/'unsafe-inline'/https: but not blob:. alphaTab (used by the tabview and staffview plugins) spawns its rendering worker from a blob: URL. Without worker-src, browsers silently blocked that worker, so both plugins rendered a blank canvas for every song and every arrangement — not specific to any one instrument. Reported as "Sax arrangement not visible in staffview or tabview" for the song Money; reproduced the same blank result on the Lead arrangement, confirming it was a general regression from the CSP change rather than anything arrangement-specific. Adds "worker-src 'self' blob:;", matching the existing blob: allowance already granted to img-src/media-src for the same reason (plugin CDN assets). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe baseline Content Security Policy now allows same-origin and ChangesWorker CSP policy
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to The PR adds the missing worker-src allowance needed for alphaTab-based tab and staff rendering, with focused coverage for the security header change. No actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 22✅ Passed checks (22 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
ℹ️ No critical issues — two small follow-ups inline.
Reviewed changes
- Adds
worker-src 'self' blob:to the site-wide CSP (server.py:129). The root-cause analysis holds up: whenworker-srcis absent, worker loads fall back tochild-src→script-src(MDN), and this policy'sscript-src('self' 'unsafe-inline' https:) doesn't allowblob:— so alphaTab's blob:-minted rendering worker was blocked, matching the blank canvases in tabview/staffview. - Security posture stays coherent.
blob:was already granted toimg-src/media-src, only same-origin scripts can mint blob: URLs, andscript-srcalready permits inline execution — the incremental exposure is minimal and consistent with the header's documented rationale (server.py:105-117). Placement and formatting match the surrounding directives.
ℹ️ Nitpicks
- Adding an explicit
worker-srcnarrows what previously fell back toscript-src: cross-origin module workers fromhttps:CDNs were technically permitted before and are blocked now. That looks like intentional, sensible tightening (classic workers can't be cross-origin anyway, and alphaTab loads its worker from ablob:), just noting it so it's a conscious choice. - Per CSP2 §source-list-guid-matching, allowing
blob:is spec-equivalent tounsafe-evalfor worker creation. Accepted here given the existing posture above — worth remembering ifscript-srcis ever tightened to nonce-based, at which pointworker-src blob:deserves a second look too.
Big Pickle (free) | 𝕏
- Add a regression test pinning the new worker-src directive ('self'
and blob: present, no bare http:/data:), mirroring the existing
script-src parsing test so a future CSP edit can't silently drop it.
- Add the CHANGELOG.md [Unreleased] > Security entry the PR's own
checklist asked for, alongside the #47 baseline-CSP entries this
builds on.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — incremental delta since the prior review (451b240..0475afd), which lands exactly the two follow-ups suggested there:
- Added a regression test pinning the new CSP directive (
tests/test_security_headers.py).test_csp_allows_self_and_blob_workersparsesworker-srcout of the header with the same style as the existing script-src test and asserts'self'+blob:are present while barehttp:/data:are not. Verified it can fail (dropping the directive raisesStopIteration) and that the full file suite passes. - Added the
[Unreleased] → SecurityCHANGELOG bullet documenting the blank-canvas root cause and the fix, placed right after the #47 baseline-CSP entries this builds on — matching the repo's Keep-a-Changelog convention.
Both prior threads are resolved by these changes; nothing outstanding on my side.
Big Pickle (free) | 𝕏
✅ Action performedReview finished.
|

Summary
worker-src 'self' blob:;directive to the site-wide Content-Security-Policy inserver.py.Root cause
The baseline CSP headers added in 81837ec (#44, stored-XSS fix) covered
script-src,style-src,img-src,font-src,media-src, andconnect-src, but never setworker-src. Per CSP fallback rules, workers without an explicitworker-srcfall back toscript-src, which allows'self'/'unsafe-inline'/https:but notblob:.alphaTab (used by the
tabviewandstaffviewplugins) spawns its rendering worker from ablob:URL. Withoutworker-src, browsers silently blocked that worker, so both plugins rendered a blank canvas — for every song and every arrangement, not anything instrument-specific.Reported as "can't see the Sax arrangement in staffview or tabview" for the song Money. Reproduced the identical blank render on the Lead arrangement of the same song, confirming this is a general regression from the CSP change introduced in #44, not anything about the Sax arrangement's data.
Fix
Add
worker-src 'self' blob:;, matching theblob:allowance already granted toimg-src/media-srcfor the same reason (plugin-loaded CDN assets).Test plan
🤖 Generated with Claude Code