WinGet’s COM API Can Crash Its Server Process: Proposed Fix Adds Input Validation
The article's text, from Joho no Todai's page.
Microsoft’s Windows Package Manager (WinGet) searches for, installs, updates, and removes applications on Windows. In addition to the command-line interface, WinGet offers a COM API that other programs can use to call its features directly.
At 20:59 UTC on December 5, a WinGet contributor reported a bug in the COM API. The contributor tested seven call paths on a specific Windows 11 setup and reported that the WinGet server process terminated unexpectedly in every case.
The tests ran on a 64-bit system with Windows 11 build 26300, App Installer (Microsoft.DesktopAppInstaller) 1.29.290.0, Microsoft.WinGet.Client 1.29.280, and PowerShell 7.6.10. The contributor ran the tests as a standard user without elevating to administrator.
A control test with a valid package search succeeded. In the failing tests, WindowsPackageManagerServer.exe, which handles requests locally, terminated. Windows Error Reporting identified an access violation in WindowsPackageManager.dll, with exception code 0xC0000005. In a synchronous search, the caller received 0x800706BE, a remote procedure call (RPC) failure. RPC is a mechanism for requesting work from another process.
COM lets other programs hand off work to WinGet and receive the results. In the synchronous search, the server stopped before it could return an input validation error, so the caller saw a communication failure.
How WinGet’s COM API behaves when a search fails
| Comparison | Released build test | Proposed fix test |
|---|---|---|
| Test environment | Windows 11 Build 26300 App Installer 1.29.290.0 64-bit・Standard user privileges | 64-bit development build IsolatedWindows VM |
| Input validation | Incomplete null checks | Rejects invalid input |
| Response | Communication error 0x800706BE (synchronous search) | Invalid search options InvalidOptions Invalid argument error E_INVALIDARG |
| Continued operation | Server processcrashes | A valid search succeedswith the existingCOM object |
Validating data before using it
The problem was that the API did not consistently check whether objects received from the caller were null, meaning there was no reference to a valid object.
In the package search source code on which the patch was based, the code read search options and filter data without first validating the references. Other operations also had insufficient input validation, including reading package version information, selecting installers, and combining catalogs that list available packages.
The proposed fix, published at 22:56 UTC on December 5, rejects invalid arguments before using them. A package search with invalid options would return InvalidOptions and the invalid-argument error E_INVALIDARG.
The treatment of null varies across APIs. The contributor also found incomplete validation in the code that handles updates when a candidate version is classified as unknown. The necessary conditions were unavailable in a VM running the released version, so that finding came from source inspection alone.
Update options are optional. Treating the absence of those options as an error would change the existing API contract. The proposed fix preserves the default behavior by returning the existing update error when the caller has not opted to allow updates with unknown versions.
Can the server keep working after invalid input?
The proposed changes include tests that check whether the API returns the appropriate error for invalid arguments. They also check whether existing COM objects remain usable afterward. In the package search test, the server rejects invalid input and then successfully completes a search with valid options.
According to the contributor, nine unit test cases passed 34 assertions in a 64-bit debug build. The contributor also ran integration tests of the development build in an isolated Windows VM.
The contributor reported that 16 tests passed in each of the packaged and unpackaged configurations. In each configuration, the tests covered both COM running in the caller’s process and COM running in a separate process.
The contributor disclosed using GitHub Copilot for implementation, testing, and verification and said they reviewed the changes personally. During code review, Copilot pointed out that tests calling the implementation directly did not show whether a packaged, out-of-process COM server remained available after receiving invalid input. The contributor added tests that made calls over COM, and Copilot’s subsequent review marked the issue resolved and recommended approval.
The tests cover argument validation and whether processing can continue after a failure. That matters to developers who call WinGet from another program. When a search returns a specific error, their code can log the reason or decide whether to proceed with subsequent work.
Review status and scope
The proposed fix, updated at 23:52 UTC on December 5, was awaiting the approval needed to merge it. A draft release note was added to the directory for version 1.31, but the change still needs to be accepted and distributed before it reaches the product.
WinGet is also available on supported Windows 10 versions and Windows Server 2025. The reproduction report for the released version covered the specific Windows 11 environment and COM API described above. It did not include results for the regular winget command, other versions, or other operating systems.
Automated app management saves people from having to search for and update apps individually. Whether it can be trusted depends on what it can do and how it handles failures. Were the search criteria invalid, or did the program carrying out the search stop? The information callers receive determines how they can respond.
Error handling is easy to overlook when everything works. A failure shows whether the program can be trusted to handle the job.
