Do not sign ASP.NET Core static web assets in containers - #1055
Open
ChatchawanIllyes wants to merge 2 commits into
Open
Do not sign ASP.NET Core static web assets in containers#1055ChatchawanIllyes wants to merge 2 commits into
ChatchawanIllyes wants to merge 2 commits into
Conversation
Author
|
@dotnet-policy-service agree |
Contributor
|
@ChatchawanIllyes please rebase since we migrated tests from Moq to NSubstitute. |
Packages produced by the ASP.NET Core SDK carry their browser assets in a staticwebassets directory and record each asset's integrity hash at pack time in build/Microsoft.AspNetCore.StaticWebAssets.props. Because .js is signable (Windows Script Host scripts are .js), recursing into such a package signs its .js assets, which changes them and invalidates the recorded hashes. Consuming applications then fail with an integrity conflict. When recursing into a container, skip the files in a package's staticwebassets directory and log a warning for each one. A package is recognized by a Microsoft.AspNetCore.StaticWebAsset*.props file in its build, buildTransitive, or buildMultiTargeting directory, and only that package's staticwebassets directory is skipped. Files elsewhere in the package, including .js files outside of staticwebassets, are unaffected. Filtering is skipped when the caller provides a file list, so static web assets can still be signed by listing them explicitly with --file-list. Fixes dotnet#1045 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
SignerTests builds its own service collection, so AggregatingSigner could not be activated there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ChatchawanIllyes
force-pushed
the
static-web-assets-1045
branch
from
August 15, 2026 17:32
ed70356 to
485e0be
Compare
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.
Fixes #1045
Problem
Packages produced by the ASP.NET Core SDK (Blazor and Razor class libraries) carry their browser assets in a
staticwebassetsdirectory and record each asset's integrity hash at pack time inbuild/Microsoft.AspNetCore.StaticWebAssets.props..jsis in the signable extension list because Windows Script Host scripts are.js, so recursing into such a package signs its.jsassets. That changes the files, invalidates the recorded hashes, and consuming applications fail with an integrity conflict. The workaround reported in #1045 was--recurse-containers false, which gives up signing the package contents entirely.Change
When recursing into a container,
AggregatingSignernow skips the files in a package'sstaticwebassetsdirectory and logs a warning naming each skipped file.Detection is convention-based and scoped to the package that declares the assets:
Microsoft.AspNetCore.StaticWebAsset*.propsfile in itsbuild,buildTransitive, orbuildMultiTargetingdirectory. The wildcard also coversMicrosoft.AspNetCore.StaticWebAssetEndpoints.props(.NET 9 and later).staticwebassetsdirectory is skipped --- astaticwebassetsdirectory elsewhere in the container is not..jsfiles outside ofstaticwebassets, so genuine Windows Script Host scripts are still signed.Filtering applies only when no file list was provided. A caller who explicitly listed files has already stated an intent, so static web assets can still be signed by listing them with
--file-list.The new
IStaticWebAssetFilterworks on the file paths already enumerated from the container, so it adds noIContainer.GetFiles(...)calls.Notes
.xlffiles updated by the build.Testing
StaticWebAssetFilterTestscovering the marker file locations and names, non-.jsassets (.wasm,.dll), a.jsfile outsidestaticwebassets, a similarly named directory, case insensitivity, and the warning.AggregatingSignerTestscases for a.nupkgcontainer with and without a file list.Sign.Core.Testcompiles but cannot run (the projects arewin-x64andSign.TestInfrastructureneedsmage.exe). I verified the new and existingAggregatingSignertests --- 55 in total --- by compiling the same sources into a scratchnet8.0project and running them locally; they all pass. CI is the first Windows run.🤖 Generated with Claude Code