Repository navigation
Limit YAML alias expansion to prevent excessive memory use - #6685
Merged
AmirMS (AmelBawa-msft) merged 3 commits intoNov 17, 2026
Merged
AmirMS (AmelBawa-msft) merged 3 commits into
AmirMS (AmelBawa-msft) merged 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new 10 MiB YAML alias-expansion limit introduces a user-visible loading restriction without the required release-note fragment.
1 open issue
What changed in this PR
This PR limits YAML alias expansion in WinGet’s shared YAML loader to prevent excessive memory use. Documents exceeding the 10 MiB alias-copy budget now fail with APPINSTALLER_CLI_ERROR_YAML_DOC_BUILD_FAILED.
Changes:
- Track repeated document-node visits and count copied node, tag, and scalar data.
- Add tests for supported aliases, excessive nested expansion, and large aliased values.
| File | Description |
|---|---|
| src/AppInstallerSharedLib/YamlWrapper.cpp | Enforce the alias-copy budget during YAML conversion. |
| src/AppInstallerCLITests/Yaml.cpp | Test normal alias handling and both expansion-limit scenarios. |
Review effort: Balanced
JohnMcPMS
reviewed
Nov 16, 2026
JohnMcPMS
approved these changes
Nov 17, 2026
ranm-msft
approved these changes
Nov 17, 2026
ranm-msft
left a comment
Contributor
There was a problem hiding this comment.
The alias budget accounts for repeated mappings, sequences and scalar data without changing ordinary alias behavior. The benign-alias, large-scalar and small-node tests cover the important boundaries.
AmirMS (AmelBawa-msft)
deleted the
user/amelbawa/fix-yaml-alias-expansion
branch
November 17, 2026 03:38
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.

📖 Description
Document::GetRoot()copies the anchored node each time an alias refers to it. Nested aliases can make a tiny YAML file expand to millions of nodes and use hundreds of MB.It now tracks which document nodes it has already converted. Any repeat visit is an alias copy, which counts its node size plus its tag and scalar length. Once alias copies add more than 10 MiB, loading fails with
APPINSTALLER_CLI_ERROR_YAML_DOC_BUILD_FAILED. Files under the limit load as before.🔗 References
🔍 Validation
✅ Checklist
🤖 AI Assistance
📋 Issue Type
Microsoft Reviewers: Open in CodeFlow