Skip to content

Commit 084ce62

Browse files
Remove wasm-unsafe-eval from Webview CSP
sql.js runs in a dedicated worker thread, not in the webview directly. Therefore, the webview does not require 'wasm-unsafe-eval' to load or compile WebAssembly. This change hardens the CSP by removing this unnecessary directive. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
1 parent 2a3de52 commit 084ce62

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/editorController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,13 @@ export class DatabaseViewerProvider extends Disposable implements vsc.CustomRead
228228
[cspUtil.defaultSrc]: [webview.cspSource],
229229
// SECURITY NOTE: 'unsafe-inline' removed for scripts.
230230
// Inline event handlers have been refactored to use addEventListener.
231-
// wasm-unsafe-eval is still required for sql.js WASM compilation.
231+
// wasm-unsafe-eval is NOT required because sql.js runs in a worker thread, not the webview.
232232
//
233233
// NOTE: 'unsafe-inline' for styles has been removed.
234234
// The <style> tag in viewer.html uses a nonce for CSP compliance.
235235
// Dynamic inline styles for column widths and positioning are handled via
236236
// CSSOM (element.style.prop = ...) which is allowed by CSP.
237-
[cspUtil.scriptSrc]: [webview.cspSource, cspUtil.wasmUnsafeEval, `'nonce-${nonce}'`],
237+
[cspUtil.scriptSrc]: [webview.cspSource, `'nonce-${nonce}'`],
238238
[cspUtil.styleSrc]: [webview.cspSource, `'nonce-${nonce}'`],
239239
[cspUtil.imgSrc]: [webview.cspSource, cspUtil.data, cspUtil.blob],
240240
[cspUtil.fontSrc]: [webview.cspSource],

0 commit comments

Comments
 (0)