Improve MotW handling and clarify the MSB3821#14015
Conversation
IsDangerous only flagged data/metadata nodes that had a mimetype attribute. A ResXFileRef entry uses a type attribute (no mimetype) and later triggers AddLinkedResource, which opens and reads the linked external file. A MotW-marked .resx could therefore bypass the MSB3821 trust check and cause GenerateResource to embed arbitrary build-user-readable file contents into output resources. Fix: also flag the file as dangerous when a data/metadata node has a type attribute referencing ResXFileRef. Additionally, behind ChangeWave 18.8, treat any typed entry on a MotW-marked .resx as untrusted (defense in depth).
There was a problem hiding this comment.
Pull request overview
This PR tightens GenerateResource’s handling of Mark-of-the-Web (Internet/Restricted zone) inputs to reduce risk from .resx files that can trigger type loading / linked-file processing, and updates MSB3821 text to include secure-usage guidance.
Changes:
- Expand “dangerous”
.resx/.reswdetection to treatResXFileRefentries as dangerous and (behind ChangeWave 18.8) treat any typed entry as dangerous for MotW-tagged files. - Clarify MSB3821 to instruct users to unblock only if they trust the files and link to MSBuild security best practices.
- Update localized XLF source strings and mark translations as needing review.
Show a summary per file
| File | Description |
|---|---|
| src/Tasks/Resources/xlf/Strings.zh-Hant.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.zh-Hans.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.tr.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.ru.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.pt-BR.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.pl.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.ko.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.ja.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.it.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.fr.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.es.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.de.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/xlf/Strings.cs.xlf | Updates MSB3821 source string; marks translation as needing review. |
| src/Tasks/Resources/Strings.resx | Updates MSB3821 English resource string with security guidance link. |
| src/Tasks/GenerateResource.cs | Extends MotW “dangerous” detection to cover ResXFileRef and typed entries (ChangeWave-gated). |
Copilot's findings
- Files reviewed: 15/15 changed files
- Comments generated: 2
|
/review |
|
Dependency Management — LGTM |
Code Review — Design-Level Findings🔴 MAJOR: No tests for new
|
There was a problem hiding this comment.
Expert Review — 24-Dimension Analysis
| # | Dimension | Verdict |
|---|---|---|
| 1 | Backwards Compatibility Vigilance | 🔴 1 BLOCKING |
| 2 | ChangeWave Discipline | 🟠 1 MAJOR |
| 4 | Test Coverage & Completeness | 🟠 1 MAJOR |
| 6 | Logging & Diagnostics Rigor | 🟡 1 MODERATE |
| 12 | Code Simplification | 💬 1 NIT |
| 14 | Naming Precision | 💬 1 NIT |
✅ 18/24 dimensions clean.
🔴 BLOCKING — Backwards Compatibility
The ResXFileRef check (line 1004–1006) is unconditional — it has no ChangeWave gate.
This is a hard breaking change: any .resx file downloaded from the internet (MotW applied) that uses the standard WinForms designer pattern of ResXFileRef for image resources will now fail with MSB3821. The immediately adjacent branch (else if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave18_8))) is correctly gated — the ResXFileRef branch appears to have been overlooked. The AllowMOTW registry key is machine-wide and is not a viable per-project workaround.
Fix: Gate both checks behind the same ChangeWave (see inline comment on line 1006).
🟠 MAJOR — Missing items
- Test coverage — Both new behaviors (ResXFileRef detection, Wave18_8 typed-entry blocking) have zero test coverage. Add
[WindowsOnlyFact]-gated unit tests toGenerateResource_Tests.cs. -
ChangeWaves.md— The Wave18_8 section indocumentation/wiki/ChangeWaves.mddoes not document this behavior. Users cannot discover theMSBUILDDISABLEFEATURESFROMVERSION=18.8opt-out.
The security intent of this PR is correct and valuable — ResXFileRef in MotW-tagged files is a real risk. The fix just needs to respect the ChangeWave discipline that MSBuild uses for all behavioral changes, and needs test coverage to maintain that security guarantee over time.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
patchdiff.githubusercontent.com
To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:
network:
allowed:
- defaults
- "patchdiff.githubusercontent.com"See Network Configuration for more information.
Generated by Expert Code Review (command) for issue #14015 · 2.8K AIC · ⊞ 29.8K ambient context
Comment /review to run again
…testable helper - Extract the .resx/.resw content danger scan into a static, platform-agnostic ResourceFileContentsAreDangerous(TextReader) helper so it is unit-testable on all TFMs (the surrounding zone/COM check remains full-framework only). - Add ResourceFileTrustTests covering: plain string (not dangerous), mimetype (dangerous), ResXFileRef (dangerous even with Wave18_8 disabled), typed entry with Wave18_8 enabled (dangerous) and disabled (not dangerous). - Document the new MotW/typed-entry behavior and the MSBUILDDISABLEFEATURESFROMVERSION=18.8 opt-out under ChangeWaves.md 18.8.
JanProvaznik
left a comment
There was a problem hiding this comment.
it should be changewave 18.9
Add Wave18_9 to ChangeWaves and gate the GenerateResource MotW typed-entry detection behind it; update tests and ChangeWaves.md (### 18.9 section, MSBUILDDISABLEFEATURESFROMVERSION=18.9 opt-out). ResXFileRef detection remains unconditional.
Context
ResXFileRefcould lead to adding linked resources - so it should not be processed if 'mark of the web' metadata is present. Going forward - we should not allow any typed entry (as for unknown types theType.GetTypeis eventually called, which can probe for assemblies on disk).Additionaly - clarifying the messaging for MotW - as general guidance is unchanged - users are still responsible for reviewing/trusting the msbuild inputs and env.
Related
https://github.com/MicrosoftDocs/visualstudio-docs-pr/pull/15493