Skip to content

[wasm][coreclr] Default fetch integrity checks off in .NET 12 - #137531

Merged
pavelsavara merged 6 commits into
dotnet:mainfrom
davidwrighton:wasm-skip-integrity-fingerprinted
Nov 18, 2026
Merged

pavelsavara merged 6 commits into
dotnet:mainfrom
davidwrighton:wasm-skip-integrity-fingerprinted

Conversation

@davidwrighton

@davidwrighton davidwrighton commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Disable loader fetch integrity checks by default for CoreCLR browser apps targeting .NET 12 or later. Fetch SRI requires the complete response before it can be consumed, preventing streaming Wasm compilation.

Changes

  • Add WasmEnableIntegrityCheck and write its inverse as disableIntegrityCheck in the generated boot configuration for build and publish.
  • When unset, disable fetch integrity checks for CoreCLR apps targeting .NET 12 or later, regardless of fingerprinting. Preserve the existing default for Mono and earlier target frameworks.
  • Set <WasmEnableIntegrityCheck>true</WasmEnableIntegrityCheck> to opt in to fetch integrity checking. An explicit false disables it.
  • Preserve JavaScript overrides: disableIntegrityCheck: false enables checking, and true disables it.
  • Apply the setting to loader fetches during normal startup and dotnet.download(true) prefetching. Keep the existing fetch and retry implementations unchanged.
  • Retain resource and aggregate hashes, custom resource-loader callback hashes, endpoint integrity properties, fingerprints, ETags, HTML preload SRI, and import-map SRI.
  • Track the property in both incremental boot-config stamps and briefly document the opt-in.

This replaces the original fingerprint-dependent loader implementation with a boot-configuration default.

Validation

  • Clean Browser/CoreCLR Debug baseline: passed with .\build.cmd -bl -os browser -subset clr+libs+host+packs -c Debug /p:RuntimeFlavor=CoreCLR /p:EnableHotReloadInRuntimeConfigDevFile=false.
  • Changed WebAssembly SDK package: built successfully; packaged browser targets verified byte-for-byte against the source.
  • Focused Browser/CoreCLR Debug no-workload WBT run: 25 passed, 0 failed, 0 skipped. Covers manifest defaults and overrides, real Chrome fetch options during prefetch and creation, fingerprinted and non-fingerprinted apps, retained endpoint/HTML/import-map integrity, and incremental build/publish property toggles.
  • Regression assertions were verified failing against the preceding behavior before passing with the change.
  • git diff --check: passed.
  • Not run: full WBT, Mono browser execution, hosted workload Blazor.AssetCachingTests, or fresh startup benchmarks.

Compatibility

This is a behavioral change requiring breaking-change documentation. The build property controls fetch integrity only; it does not disable SRI in generated HTML or import maps.

Download retry behavior is unchanged. With fetch integrity disabled, a nonempty corrupted HTTP-200 cached response can fail later during compilation or initialization without a cache-reload retry. Applications requiring hash-based detection can opt in using WasmEnableIntegrityCheck=true.

Resolves #137529

Note

This description was generated with GitHub Copilot.

davidwrighton and others added 3 commits November 13, 2026 16:57
Fingerprinted assets (boot config cache "force-cache", or "reload" on retry)
have content-addressed URLs, so the stale-cache protection that integrity
provided is already guaranteed. Fetch SRI blocks streaming compilation and
hashes every byte on the main thread, costing ~25% of CoreCLR WebAssembly
cold startup on desktop.

When disableIntegrityCheck is unset, skip integrity for fingerprinted assets.
An explicit false keeps integrity for all hashed assets; true still disables
it everywhere. Applies to the CoreCLR loader (including prefetch) and Mono.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 3d3a8d4f-c935-49c3-987c-2998d7c8abf7
Limit the fingerprinted-asset integrity default to the CoreCLR loader and
expect the previous behavior from Mono in the new build test.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 3d3a8d4f-c935-49c3-987c-2998d7c8abf7
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 3d3a8d4f-c935-49c3-987c-2998d7c8abf7
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An invalid cached Wasm body can bypass integrity validation and fail outside the retry path, preventing cache-reload recovery and causing repeated startup failures.

2 open issues
What changed in this PR

This PR changes the CoreCLR WebAssembly loader to skip fetch integrity checks by default for fingerprinted assets, aiming to enable streaming compilation and reduce startup overhead. Mono behavior remains unchanged.

Changes:

  • Applies fingerprint-aware integrity checks to startup and prefetch requests while preserving explicit configuration overrides.
  • Documents the unset, false, and true configuration states.
  • Adds browser tests that inspect fetch integrity options across fingerprinting configurations.
File Description
src/​native/​libs/​Common/​JavaScript/​types/​public-api.ts Documents integrity-check configuration behavior.
src/​native/​libs/​Common/​JavaScript/​loader/​dotnet.d.ts Updates the corresponding declaration comments.
src/​native/​libs/​Common/​JavaScript/​loader/​assets.ts Shares integrity-selection logic and carries cache metadata through prefetch.
src/​mono/​wasm/​Wasm.Build.Tests/​ModuleConfigTests.cs Adds four integrity/fingerprinting test cases with Mono-specific expectations.
src/​mono/​wasm/​testassets/​WasmBasicTestApp/​App/​wwwroot/​main.js Adds a scenario that records integrity options on asset requests.

Review effort: Balanced

@pavelsavara

Copy link
Copy Markdown
Member

Interesting observation.

Maybe we can just make the disableIntegrityCheck default false when we construct the boot config. I will take over this PR next week.

@pavelsavara pavelsavara self-assigned this Nov 14, 2026
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Nov 14, 2026
@pavelsavara pavelsavara added this to the 12.0.0 milestone Nov 14, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

pavelsavara and others added 3 commits November 16, 2026 12:20
Revert the original PR implementation before replacing it with an
MSBuild-controlled boot configuration default.

Co-authored-by: Copilot <[email protected]>
Add WasmEnableIntegrityCheck to control the generated boot configuration.
Disable fetch integrity by default for CoreCLR apps targeting .NET 12 or
later, while preserving JavaScript overrides and earlier runtime defaults.

Retain endpoint hashes, preload and import-map integrity, and cache
validators. Cover configuration, browser fetch and prefetch behavior, and
incremental build and publish changes in Wasm.Build.Tests.

Co-authored-by: Copilot <[email protected]>
@pavelsavara pavelsavara changed the title [wasm][coreclr] Skip fetch integrity for fingerprinted assets by default [wasm][coreclr] Default fetch integrity checks off in .NET 12 Nov 16, 2026
@davidwrighton

Copy link
Copy Markdown
Member Author

@pavelsavara Thank you for taking over this PR. The changes that you've made LGTM, but since this is my PR I can't approve anything.

@pavelsavara
pavelsavara merged commit 1628791 into dotnet:main Nov 18, 2026
38 checks passed
@radekdoulik

Copy link
Copy Markdown
Member

LGTM. What about the case when user would disable fingerprinting (<WasmFingerprintAssets>false</WasmFingerprintAssets>) @maraf should we even allow that? Are there cases where we need to disable fingerprints?

@pavelsavara

Copy link
Copy Markdown
Member

I started tracking breaking changes #137891

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

Labels

arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm] Skip fetch integrity for fingerprinted assets by default (~25% of CoreCLR WebAssembly cold startup)

5 participants