Skip to content

Restore CLR RAR metadata validation for malformed hash blobs - #15217

Merged
JanProvaznik merged 2 commits into
mainfrom
janprovaznik-mscorlib-mismatch-evidence
Oct 8, 2026
Merged

JanProvaznik merged 2 commits into
mainfrom
janprovaznik-mscorlib-mismatch-evidence

Conversation

@JanProvaznik

@JanProvaznik JanProvaznik commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

VS customer reports: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/3049117/

Regression introduced by #13853.

Context

The CLR metadata interop migration changed unused GetAssemblyRefProps hash outputs from real output locations to null. On assemblies with an invalid AssemblyRef hash-blob index, this bypasses the metadata-read failure that RAR previously handled nonfatally. RAR then traverses newly exposed dependencies, potentially excluding a previously resolved primary reference with MSB3258 or emitting MSB3277 that breaks warning-as-error builds.

image

Changes Made

  • Request both hash outputs in the size-query and property-read calls, preserving the legacy HRESULT/exception path without reverting the CsWin32 migration.
  • Add generated, customer-free regression fixtures: an invalid hash must retain the metadata-read failure, while a valid hash must preserve a maximum-version reference for normal resolution checks.

Compatibility

Limited to the Windows/.NET Framework CLR metadata reader. The .NET PEReader path is unchanged. No new diagnostics, defaults, APIs or protocols are introduced.

This deliberately restores the existing all-or-nothing dependency-read fallback: a malformed hash can abandon dependency traversal while retaining the primary reference. It does not blanket-ignore version 65535, continue with a partial dependency array, or undo the later COM activation/lifetime fixes.

Testing

The new malformed-hash regression failed against unpatched local source and passed after restoring the hash outputs. A separate valid-hash control retained the preexisting maximum-version rejection behavior.

.\build.cmd -msbuildEngine dotnet -v quiet -bl -binaryLogName RARHashBlobCompatibilityPRRetry.binlog /p:CreateTlb=false

Passed: full repository build, 0 warnings and 0 errors. An initial run encountered CS0009 in a malformed generated ExampleTaskX86 reference assembly; rebuilding that fixture repaired the generated output, and the full retry passed without product changes.

.\artifacts\bin\Microsoft.Build.Tasks.UnitTests\Debug\net472\Microsoft.Build.Tasks.UnitTests.exe --filter-class '*AssemblyInformation_Tests' --no-progress

Passed: 10 tests, 0 failures, 0 skipped (net472/x86).

.\artifacts\bin\Microsoft.Build.Tasks.UnitTests\Debug\net472\Microsoft.Build.Tasks.UnitTests.exe --filter-class '*VerifyIgnoreVersionForFrameworkReference' --no-progress

Passed: 4 tests, 0 failures, 0 skipped (net472/x86).

Coverage gaps: the complete Tasks test suite and required CI matrix have not been run locally. Type-library generation was disabled for the dotnet-engine build.

Dependencies and Follow-up

No companion-PR dependency. This is a candidate for backporting to affected servicing branches. A deliberate malformed-metadata recovery policy, including any partial dependency traversal or cross-runtime behavior change, should be evaluated separately with compatibility/ChangeWave discipline.

Preserve the legacy metadata-read failure by requesting both unused hash outputs in GetAssemblyRefProps. Add synthetic regressions for malformed hash blobs and maximum-version references with valid hashes.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 16:57

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.

Copilot review overview

🟢 Approval recommended

The narrow compatibility fix preserves existing failure handling and includes focused regression coverage, with no blocking issues identified.

Review effort: Balanced
Findings: None

What changed in this PR

Restores legacy malformed-hash validation in RAR’s Windows/.NET Framework metadata reader without changing the PEReader path.

Changes:

  • Requests hash outputs in both GetAssemblyRefProps calls to preserve existing metadata-read failures.
  • Adds generated fixtures covering malformed hashes and maximum-version references with valid hashes.
File Description
src/​Tasks/​AssemblyDependency/​AssemblyInformation.cs Restores hash output arguments for CLR metadata validation.
src/​Tasks.UnitTests/​AssemblyDependency/​AssemblyInformation_Tests.cs Adds malformed-hash regression coverage and a valid-hash control.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot 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.

# Dimension Verdict
4 Test Coverage & Completeness 🟡 1 MODERATE

✅ 23/24 dimensions clean.

  • Test Coverage — make the positive control use a real, non-empty valid hash blob.

The product change is narrowly scoped and consistent with the legacy CLR metadata-reader behavior restored from before #13853. No merge-blocking correctness, compatibility, concurrency, performance, API, diagnostic, or cross-platform issue was found.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • github.com
  • raw.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"
    - "raw.githubusercontent.com"

See Network Configuration for more information.

Generated by Expert Code Review (on open) for #15217 · copilot · gpt56 · 866.4 AIC · ⌖ 4.56 AIC · ⊞ 24.9K

@JanProvaznik JanProvaznik self-assigned this Oct 7, 2026
@JanProvaznik JanProvaznik added the Priority:1 Work that is critical for the release, but we could probably ship without label Oct 7, 2026
@JanProvaznik
JanProvaznik enabled auto-merge (squash) October 8, 2026 10:29
@JanProvaznik
JanProvaznik merged commit 74878b5 into main Oct 8, 2026
14 checks passed
@JanProvaznik
JanProvaznik deleted the janprovaznik-mscorlib-mismatch-evidence branch October 8, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority:1 Work that is critical for the release, but we could probably ship without

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants