fix: all-users (Common) startup-folder toggles target HKLM, not HKCU#1430
Merged
Conversation
Both the per-user Startup folder and the all-users Common Startup folder were scanned and tagged with the same StartupSource.StartupFolder, so ApplyApprovedState read the enabled/disabled state for ALL folder items only from HKCU and SetEnabledAsync wrote the toggle blob for ALL folder items only to HKCU. Windows stores the StartupApproved\StartupFolder state for all-users shortcuts under HKLM. So for a shortcut in %ProgramData%\...\Startup: an item disabled via Task Manager (HKLM blob) showed as 'Enabled', and disabling it in SysManager wrote to HKCU where Windows never looks — returning success while the program still launched at logon. Added StartupSource.CommonStartupFolder (set in ReadStartupFolder from which special folder produced the entry). ApplyApprovedState now reads HKLM for common-folder entries; SetEnabledAsync routes them to HKLM (needs elevation — a non-elevated attempt surfaces the existing 'requires elevation' message). Per-user items unchanged. Fixes ultra-audit finding P2 #38. Regression tests: BuildStartupFolderEntry_Common_TaggedCommonStartupFolder and BuildStartupFolderEntry_PerUser_TaggedStartupFolder pin the source tagging (the discriminator the hive routing depends on). Red before (the isCommon param and the CommonStartupFolder enum value did not exist).
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.
Summary
Fresh ultra-audit finding (services-O-S, P2), verified against current source.
Both the per-user Startup folder and the all-users Common Startup folder were scanned and tagged with the same
StartupSource.StartupFolder. SoApplyApprovedStateread the enabled/disabled state for all folder items only from HKCU, andSetEnabledAsyncwrote the toggle blob for all folder items only to HKCU. But Windows stores theStartupApproved\StartupFolderstate for all-users shortcuts under HKLM.Consequences for a shortcut in
%ProgramData%\...\Startup:For a startup manager, a disable that reports success but doesn't disable is a trust/correctness defect.
Fix
StartupSource.CommonStartupFolder, set inReadStartupFolderbased on which special folder produced the entry (SpecialFolder.StartupvsSpecialFolder.CommonStartup).ApplyApprovedStatenow reads HKLM'sStartupApproved\StartupFolderfor common-folder entries.SetEnabledAsyncroutes common-folder entries to HKLM (needs administrator — a non-elevated attempt surfaces the existing "requires elevation" message, exactly like the HKLM Run path).Regression tests
BuildStartupFolderEntry_Common_TaggedCommonStartupFolder—isCommon: true→CommonStartupFolder.BuildStartupFolderEntry_PerUser_TaggedStartupFolder—isCommon: false→StartupFolder.Both are red before the fix (the
isCommonparameter and theCommonStartupFolderenum value did not exist). The hive routing depends entirely on this source tagging. (No test writes the registry — the toggle's HKLM write path needs elevation and would mutate real machine state, so it's excluded from the CI-safe unit suite.)Checks