Repository navigation
Validate file cache paths before accessing cached files - #6610
Open
AmirMS (AmelBawa-msft) wants to merge 3 commits into
Open
AmirMS (AmelBawa-msft) wants to merge 3 commits into
AmirMS (AmelBawa-msft) wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved validation gaps allow device aliases and normalized-away invalid components, while encoding conversion can reject valid Unicode paths.
3 open issues
What changed in this PR
This PR adds path validation to WinGet’s shared file cache to keep source-provided paths within the cache directory.
Changes:
- Rejects escaping paths, missing filenames, and selected Windows path aliases before cache access.
- Normalizes cache paths while preserving the original path for upstream requests.
- Adds tests for invalid paths, external reads/deletes/writes, and valid nested paths.
| File | Description |
|---|---|
src/AppInstallerCommonCore/FileCache.cpp |
Validates and normalizes paths before cache operations. |
src/AppInstallerCLITests/FileCache.cpp |
Adds path-validation and cache-containment regression tests. |
Review effort: Balanced
AmirMS (AmelBawa-msft)
marked this pull request as draft
October 23, 2026 17:52
JohnMcPMS
reviewed
Oct 23, 2026
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
FileCache::GetFilenow validates the relative path from source data before using it, so cache reads, cleanup, and writes stay inside the cache directory. This covers the manifest, package version data, and icon caches.It rejects paths that:
.ornested/C:\file,C:file, or\file..to leave the cache directory:or NUL, or ends in.or a space (Windows can resolve these to a different file)Rejected paths fail with
APPINSTALLER_CLI_ERROR_SOURCE_DATA_INTEGRITY_FAILURE. Valid paths are normalized for the cache; the upstream request still uses the original path.🔗 References
🔍 Validation
✅ Checklist
🤖 AI Assistance
📋 Issue Type
Microsoft Reviewers: Open in CodeFlow