Validate installer download destination#678
Merged
Merged
Conversation
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run |
1 similar comment
Contributor
Author
|
/azp run |
Contributor
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR hardens PackageParser.DownloadFileAsync to better normalize server-provided filenames (via Content-Disposition) and adds a defense-in-depth validation to ensure the resolved installer download path cannot escape the intended download directory.
Changes:
- Normalize
Content-Dispositionfilenames withPath.GetFileName(...)and validate the resolved download path remains withinInstallerDownloadPath. - Add a new unit test ensuring directory traversal sequences in
Content-Dispositiondon’t escape the download directory. - Improve test reliability/cleanup for zip-with-nested-installers scenarios and expand test utilities for HTTP mocking and cleanup.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs | Wraps zip/nested-installer test setup/cleanup in try/finally and ensures stale resource copies are removed before running. |
| src/WingetCreateTests/WingetCreateTests/UnitTests/PackageParserTests.cs | Adds a regression test asserting Content-Disposition traversal can’t write outside the download directory. |
| src/WingetCreateTests/WingetCreateTests/TestUtils.cs | Adds helper overload to mock Content-Disposition filenames and improves cleanup utilities used by tests. |
| src/WingetCreateCore/Common/PackageParser.cs | Normalizes server-provided filenames and adds a “stay within download dir” validation before writing the installer to disk. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Madhusudhan-MSFT
approved these changes
Jul 22, 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
Improves how the installer download path is derived from the server response.
The filename from the
Content-Dispositionheader is now normalized the sameway as the URL-derived filenames, and a check ensures downloads always land
inside the intended installer download directory.
🔗 References
🔍 Validation
✅ Checklist
📋 Issue Type
Microsoft Reviewers: Open in CodeFlow