Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues remain: elevated installs can consume attacker-controlled SQLite state, and forced reinstalls can fail then delete untouched installation data during rollback.
2 open issues
What changed in this PR
This PR broadens WinGet’s elevated-process restrictions to prevent package operations from using data writable without administrator privileges. It also separates fresh portable installations from operations that load existing installation state.
Changes:
- Centralizes elevation checks across uninstall, repair, uninstall-previous, portable upgrades, and font operations.
- Refactors portable installation state and SQLite cleanup, and derives dependency upgrade status independently.
- Adds regression tests, consistent error messages, and release notes.
| File | Description |
|---|---|
| src/Microsoft.Management.Deployment/Converters.h | Maps elevation rejection to an install error. |
| src/AppInstallerSharedLib/SQLiteStorageBase.cpp | Adds database deletion and shared-memory sidecar handling. |
| src/AppInstallerSharedLib/Public/winget/SQLiteStorageBase.h | Declares database cleanup API. |
| src/AppInstallerSharedLib/Errors.cpp | Updates elevation error guidance. |
| src/AppInstallerCommonCore/Public/winget/ManifestCommon.h | Declares installer-data classification helper. |
| src/AppInstallerCommonCore/Manifest/ManifestCommon.cpp | Classifies user-scope installer data by type. |
| src/AppInstallerCLITests/WorkflowBase.cpp | Tests shared elevation guards. |
| src/AppInstallerCLITests/UpdateFlow.cpp | Makes portable update tests independent of host elevation. |
| src/AppInstallerCLITests/UninstallFlow.cpp | Expands user-scope uninstall protection tests. |
| src/AppInstallerCLITests/SQLiteWrapper.cpp | Tests database and sidecar cleanup. |
| src/AppInstallerCLITests/RepairFlow.cpp | Tests rejection before repair preparation. |
| src/AppInstallerCLITests/PortableInstaller.cpp | Tests fresh, upgrade, and rollback state handling. |
| src/AppInstallerCLITests/InstallFlow.cpp | Tests elevation rules for installation paths. |
| src/AppInstallerCLITests/InstallDependenciesFlow.cpp | Tests dependency-specific upgrade state. |
| src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters | Groups the new workflow tests. |
| src/AppInstallerCLITests/AppInstallerCLITests.vcxproj | Includes the new workflow tests in builds. |
| src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw | Consolidates localized elevation errors and translation context. |
| src/AppInstallerCLICore/Workflows/WorkflowBase.h | Documents shared elevation guard contracts. |
| src/AppInstallerCLICore/Workflows/WorkflowBase.cpp | Implements shared elevation guards. |
| src/AppInstallerCLICore/Workflows/UninstallFlow.cpp | Applies centralized checks before uninstall preparation. |
| src/AppInstallerCLICore/Workflows/ShellExecuteInstallerHandler.h | Corrects repair workflow documentation. |
| src/AppInstallerCLICore/Workflows/ShellExecuteInstallerHandler.cpp | Removes the repair guard moved earlier in the workflow. |
| src/AppInstallerCLICore/Workflows/RepairFlow.cpp | Checks elevation before preparing repairs. |
| src/AppInstallerCLICore/Workflows/PortableFlow.h | Updates portable workflow contracts. |
| src/AppInstallerCLICore/Workflows/PortableFlow.cpp | Resolves installed scope and guards portable updates. |
| src/AppInstallerCLICore/Workflows/InstallFlow.cpp | Checks uninstall-previous and font installation support. |
| src/AppInstallerCLICore/Workflows/FontFlow.h | Declares and documents font elevation checks. |
| src/AppInstallerCLICore/Workflows/FontFlow.cpp | Guards font installation and removal by scope. |
| src/AppInstallerCLICore/Workflows/DependenciesFlow.h | Clarifies dependency context outputs and operation selection. |
| src/AppInstallerCLICore/Workflows/DependenciesFlow.cpp | Sets upgrade flags from each dependency’s installed state. |
| src/AppInstallerCLICore/Resources.h | Replaces operation-specific elevation resource identifiers. |
| src/AppInstallerCLICore/PortableInstaller.h | Makes operation type explicit and adjusts cleanup state. |
| src/AppInstallerCLICore/PortableInstaller.cpp | Separates fresh installation from existing-state handling. |
| doc/release-notes/1.31/user-scope-elevation-guards.md | Documents restrictions and dependency fixes. |
Review effort: Balanced
This comment was marked as outdated.
This comment was marked as outdated.
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
ranm-msft
left a comment
There was a problem hiding this comment.
Please fix the signed/unsigned comparison blocking the current build.
| if (recordToIndex) | ||
| { | ||
| auto index = PortableIndex::Open(indexPath.u8string(), SQLiteStorageBase::OpenDisposition::Read); | ||
| REQUIRE(index.GetAllPortableFiles().size() == (installFileFirst ? 1 : 0)); |
There was a problem hiding this comment.
This comparison fails the /WX build because size() is unsigned while (installFileFirst ? 1 : 0) is int; current x86 CI reports C4389 followed by C2220 here. Please use a correctly typed expected count and rerun both architecture builds.
ranm-msft
left a comment
There was a problem hiding this comment.
The signed/unsigned comparison I flagged is fixed, and the x64/x86 builds and tests are green. Withdrawing that concern. I am not approving yet; this security-sensitive change still needs a focused independent or domain-owner review at the current head.
There was a problem hiding this comment.
🟡 Changes recommended
A failed cross-volume copy during a portable archive upgrade can leave an untracked partial directory that survives uninstall without purging and blocks upgrade retries.
1 open issue
2 resolved since last review
Review effort: Balanced
ranm-msft
left a comment
There was a problem hiding this comment.
Reviewed the current diff and prior feedback. Installed-state guards and portable rollback/index ownership address the earlier concerns. Functional CI is green, and the independent human review covers this exact head.


📖 Description
Standardizes and broadens the blocks in place to prevent elevated processes from acting on data writable at a lower integrity level. The goal of this change is to prevent the potential for EoP attacks via system artifacts for packages.
I am hoping to follow it up reasonably soon with another change to allow these scenarios to function once again, but safely by running the intended action at a lower integrity level.
🔍 Validation
Tests are added, but mostly to ensure the security aspects. This will certainly cause failures in some scenarios that previously worked, but that is unavoidable without the much more complex change mentioned earlier.
Microsoft Reviewers: Open in CodeFlow