Skip to content

[WebAssembly] Uno.UI requires 'unsafe-eval' in the page's Content Security Policy #24429

Open

Description

@mikernet

Describe the bug

Uno.UI on WebAssembly evaluates JavaScript source strings for part of its interop (WebAssemblyRuntime.InvokeJS and the native dispatcher). Under a Content Security Policy that does not allow 'unsafe-eval' for scripts, the first dispatcher call fails:

fail: Uno.UI.Dispatching.NativeDispatcher[0]
      NativeDispatcher unhandled exception
EvalError: Evaluating a string as JavaScript violates the following Content Security Policy directive because 'unsafe-eval' is not an allowed source of script: script-src 'nonce-...' 'self' https://*.vscode-cdn.net 'wasm-unsafe-eval'

and the app then dies with a NullReferenceException in the renderer before drawing anything. 'wasm-unsafe-eval' (required for the .NET runtime) is not sufficient.

Hosts with strict CSPs are increasingly common (VS Code webviews, browser extensions, corporate portals), and the [JSImport]/[JSExport] interop the runtime provides does not need eval. Migrating the remaining string-evaluated interop to generated bindings would let Uno apps run under script-src 'self' 'wasm-unsafe-eval'.

To Reproduce

  1. Publish any Uno WebAssembly app (Skia renderer, Uno.Sdk 6.5.36).
  2. Serve it with Content-Security-Policy: script-src 'self' 'wasm-unsafe-eval' (no 'unsafe-eval').
  3. Open the page: the EvalError above is logged and the app does not render.

The bootstrapper itself boots fine under script-src 'self' 'wasm-unsafe-eval' (as its documentation states); the failure comes from Uno.UI's native dispatcher / WebAssemblyRuntime.InvokeJS path evaluating script strings.

Expected behavior

The app runs without 'unsafe-eval'. If that is not feasible, the requirement should be documented in the WebAssembly hosting docs together with the exact CSP the runtime needs.

Environment

  • Uno.WinUI 6.5.237 (Uno.Sdk 6.5.36), Uno.WinUI 6.7.103 (Uno.Sdk 6.7.22), .NET 10 SDK 10.0.400
  • Chromium (VS Code 1.136 webview), Windows 11

Workaround

Add 'unsafe-eval' to script-src.

Activity

  1. jminnihan commented on Sep 8, 2026

    @jminnihan

    Same issue for me....had to downgrade to 6.6.42 from 6.7.22. This must be fixed as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions