fix(manage): add wasm-unsafe-eval to CSP for Monaco WebAssembly#2915
fix(manage): add wasm-unsafe-eval to CSP for Monaco WebAssembly#2915amikofalvy merged 2 commits intomainfrom
wasm-unsafe-eval to CSP for Monaco WebAssembly#2915Conversation
Monaco Editor (via @shikijs/monaco) uses WebAssembly for syntax highlighting, which is blocked in production by the current CSP. Adding the targeted `wasm-unsafe-eval` directive permits WASM compilation without opening the door to JavaScript eval(). Fixes PILOT-INKEEP-COM-21 Made-with: Cursor
🦋 Changeset detectedLatest commit: 87e5423 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
TL;DR — Adds Key changes
Summary | 2 files | 2 commits | base:
|
There was a problem hiding this comment.
Clean, minimal fix. 'wasm-unsafe-eval' is the correct directive — strictly narrower than 'unsafe-eval', only permits WebAssembly.compile()/instantiate(), and is required by @shikijs/monaco's Oniguruma WASM tokenizer. Placement before the dev-only 'unsafe-eval' conditional is correct. No security concerns.
Claude Opus | 𝕏
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This is a well-scoped, minimal fix for a real production issue (Sentry PILOT-INKEEP-COM-21).
✅ What's Good
-
Correct directive choice:
'wasm-unsafe-eval'is the right CSP directive for this use case — it allowsWebAssembly.compile()andWebAssembly.instantiate()without enabling JavaScripteval(). This is strictly narrower than'unsafe-eval'and follows CSP Level 3 best practices. -
Minimal change surface: Single line addition in the existing CSP builder function — no architectural changes or new patterns introduced.
-
Clear problem/solution mapping: Monaco Editor (via
@shikijs/monaco) requires WebAssembly for TextMate grammar parsing. The CSP was blocking this in production, causingCompileErrorfor 4 users across 19 occurrences. -
Proper placement: The directive is added to
scriptSrcDomainsarray alongside other CSP entries, maintaining consistency with the existing pattern.
📋 Test Plan Feedback
The test plan items are appropriate:
- ✅ Deploy to preview and verify Monaco loads
- ✅ Confirm no
CompileErrorin console - ✅ Verify CSP header includes
wasm-unsafe-eval
Consider adding: Verify the CSP header does not include 'unsafe-eval' in production (it should only appear in development mode per the existing conditional on line 38).
✅ APPROVE
Summary: This is a clean, surgical fix that uses the narrowest available CSP directive to enable WebAssembly while maintaining the security posture. The change is well-justified by the linked Sentry issue and follows CSP best practices.
Reviewers (1)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
orchestrator |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Note: This is a minimal 1-line CSP fix. No subagents were dispatched as the scope is trivially reviewable by the orchestrator directly.
dimaMachina
left a comment
There was a problem hiding this comment.
@claude add a changeset
|
Claude finished @dimaMachina's task in 30s —— View job Adding changeset
Added a patch changeset for |
Co-authored-by: Dimitri POSTOLOV <[email protected]>
Ito Test Report ✅12 test cases ran. 12 passed. All 12 test cases passed with no failures, confirming expected behavior across CSP policy enforcement, authentication/redirect protections, route handling, and Monaco-based editor/viewer functionality. Key findings were that ✅ Passed (12)Commit: Tell us how we did: Give Ito Feedback |
) * fix(manage): add `wasm-unsafe-eval` to CSP for Monaco WebAssembly Monaco Editor (via @shikijs/monaco) uses WebAssembly for syntax highlighting, which is blocked in production by the current CSP. Adding the targeted `wasm-unsafe-eval` directive permits WASM compilation without opening the door to JavaScript eval(). Fixes PILOT-INKEEP-COM-21 Made-with: Cursor * Add changeset for CSP wasm-unsafe-eval fix Co-authored-by: Dimitri POSTOLOV <[email protected]> --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Dimitri POSTOLOV <[email protected]>
Summary
'wasm-unsafe-eval'to thescript-srcCSP directive inproxy.ts@shikijs/monaco) uses WebAssembly for syntax highlighting, which is blocked in production by the current CSP — causingCompileErroron every page that loads the editor'wasm-unsafe-eval'is strictly narrower than'unsafe-eval'— it permits onlyWebAssembly.compile()/instantiate()without enabling JavaScripteval()Context
Sentry issue: PILOT-INKEEP-COM-21 — 19 occurrences, 4 users impacted, escalating. Affects the conversations trace page and any route that lazy-loads Monaco.
Test plan
CompileErrorin browser consolewasm-unsafe-evalinscript-srcMade with Cursor