Skip to content

fix: RunOnce startup items report an honest 'cannot disable' instead of a fake success#1428

Merged
laurentiu021 merged 1 commit into
mainfrom
fix/startup-runonce-honest-toggle
Jul 10, 2026
Merged

fix: RunOnce startup items report an honest 'cannot disable' instead of a fake success#1428
laurentiu021 merged 1 commit into
mainfrom
fix/startup-runonce-honest-toggle

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

Summary

Fresh ultra-audit finding (services-O-S, P2), verified against current source.

The Startup scan lists both the Run and RunOnce registry keys, and SetEnabledAsync keyed purely off the entry's scope (RegistryCurrentUser/RegistryLocalMachine). So disabling a RunOnce entry wrote the "disabled" blob to …\Explorer\StartupApproved\Run\{name} and returned true. But Windows has no StartupApproved\RunOnce subkey and never consults StartupApproved for RunOnce keys — so the command still ran at the next boot while the UI reported "Disabled". For a startup manager aimed at non-technical users, a disable that claims success but doesn't disable is a trust/correctness defect.

Fix

SetEnabledAsync now detects a RunOnce entry (its RegistryKey ends with RunOnce) and returns a truthful non-success with a plain-language message — "Run-once item — runs next boot, then removes itself; cannot be disabled here." — instead of writing an ineffective blob. The item stays visible (the user still sees it's scheduled to run once), and the ViewModel already reverts the checkbox on a false return, so the toggle snaps back with the explanation.

Regression test

SetEnabledAsync_RunOnce_ReturnsFalseWithHonestMessage_AndDoesNotDisable (HKCU + HKLM RunOnce): returns false, status contains "run-once", IsEnabled stays true. Red before the fix (returned true, flipped IsEnabled to false, and wrote the real HKCU registry as a side effect); green after (the guard short-circuits before any registry access).

Checks

  • All 3 projects build 0 warnings / 0 errors
  • Leak scan on diff: clean
  • Plain Run entries are unaffected — only keys ending in RunOnce hit the guard.

…of a fake success

The scan lists both Run and RunOnce registry keys, and SetEnabledAsync keyed purely
off the entry's scope, so disabling a RunOnce entry wrote the disabled blob to
StartupApproved\Run and returned true. Windows has no StartupApproved\RunOnce and
never consults StartupApproved for RunOnce keys, so the item still ran at next boot
while the UI showed 'Disabled' — a system-mutation toggle that silently lied.

SetEnabledAsync now detects a RunOnce entry (RegistryKey ends with 'RunOnce') and
returns a truthful non-success with a plain-language message instead of writing an
ineffective blob. The item stays visible (the user still sees it's scheduled once).
The ViewModel already reverts the checkbox on a false return, so the toggle snaps
back and the status explains why.

Fixes ultra-audit finding P2 #35.

Regression test: SetEnabledAsync_RunOnce_ReturnsFalseWithHonestMessage_AndDoesNotDisable
(HKCU + HKLM RunOnce) — returns false, status contains 'run-once', IsEnabled stays
true. Red before (returned true, IsEnabled=false, AND wrote the real HKCU registry);
green after (short-circuits before any write).
@laurentiu021 laurentiu021 merged commit 887dc7e into main Jul 10, 2026
4 checks passed
@laurentiu021 laurentiu021 deleted the fix/startup-runonce-honest-toggle branch July 10, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant