fix: allow 'unsafe-eval' in web worker extension host CSP (1.2) - #302
Merged
Merged
Conversation
aderende
approved these changes
Sep 24, 2026
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.
Issue
#301
Description of Changes
Extensions that run in the web worker extension host and ship CommonJS code (e.g.
vscodevim.vim) fail to activate with:The web worker extension host loads CommonJS extension code via
new Function(), which CSP only permits under'unsafe-eval'.'wasm-unsafe-eval'covers WebAssembly only.This ports the fix from #141 (1.0) and #142 (1.1), which did not reach
main, so 1.2 was cut without it:common/preapplied/remove-unsafe-headers.diff: drop thewebWorkerExtensionHostIframe.htmlhunk so the worker iframe keeps upstream's'unsafe-eval'. The other CSP changes in this patch are unchanged.common/replace-inline-sha-with-placeholder.diff,web-embedded/remove-unsafe-eval-and-unsafe-inline-from-csp-direct.diff: update context lines accordingly. The resulting web-embedded CSP is unchanged.Testing
prepare-src.shapplies cleanly for all four targets; no new offsets/fuzz compared to current1.2.code-editor-sagemaker-server,code-editor-server:script-src 'self' 'unsafe-eval' 'sha256-…'(same inline script hash as before)code-editor-web-embedded,code-editor-web-embedded-with-terminal: unchangedcode-editor-sagemaker-serverrelease:vscodevim.vimfails to activate with the error above. With this change applied, Vim activates and enters NORMAL mode with no errors.Additional Notes
Matches upstream Code-OSS, which uses
'unsafe-eval'in this iframe. The worker extension host runs in a sandboxed iframe/web worker.Backporting
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.