Skip to content

fix(upgrades): never take the Windows service host for a supervisor - #538

Closed
0721-art wants to merge 1 commit into
ompweb-dev:mainfrom
0721-art:fix/windows-service-host-supervisor
Closed

0721-art wants to merge 1 commit into
ompweb-dev:mainfrom
0721-art:fix/windows-service-host-supervisor

Conversation

@0721-art

@0721-art 0721-art commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

Win32_Process returns an empty ExecutablePath for processes the current account may not read, and svchost.exe is one of them on a non-admin account. inspectWindowsSupervisor filtered the process chain by that path, so the service host stayed a candidate; the Win32_Service query then matched the Schedule service every scheduled task's tree hangs under, and the update refused with not_controllable (access denied on the wrong service).

This carries the process name instead and filters by it:

  • ProcessInfo gains name: Win32_Process.Name, /proc/<pid>/comm on Linux, ps -o comm= elsewhere.
  • isServiceHostProcess(row) compares name, falling back to the image path when a listing has none.
  • The supervisor query drops the service host through that predicate.

Why the name and not the path

The path is exactly what is unreadable in the failing case; the name comes from the same listing and is readable, so the filter stops depending on an ACL. It also survives an image being replaced while the process runs.

Verification

Windows 11, the 0.7.3 install shape (a non-admin omp-web-host scheduled task running omp-web.js host), inspecting the live daemon:

  • before, installed 0.7.3 code: {"kind":"windows-service","name":"Schedule","configHash":"42a8607f…"}
  • after, this branch: {"kind":"windows-task","path":"\\","name":"omp-web-host","scripts":["…/omp-web-host.ps1"],"configHash":"0beeef23…"}

npm run typecheck clean. npm run lint unchanged: 7 pre-existing react-hooks/exhaustive-deps warnings, 0 errors.

bun test --parallel lib/upgrade-process.test.mjs → 7 pass, 9 skip, 4 fail. The four failures are New-ScheduledTaskAction/Register-ScheduledTask access-denied on this machine and reproduce identically on a clean main (6 pass, 9 skip, 4 fail there) — the new test is the difference. lib/upgrade-process.windows-service.test.mjs covers the task/service paths and needs the elevated CI account it already assumes.

The new test feeds the rows a non-admin account actually gets:

assert.equal(serviceHost("svchost.exe", ""), true);   // empty ExecutablePath: the reported case
assert.equal(serviceHost("", "C:/Windows/System32/svchost.exe"), true);
assert.equal(serviceHost("node.exe", "E:/Nodev/node.exe"), false);

Fixes #537

Summary by CodeRabbit

  • Bug Fixes
    • Windows upgrade process detection now identifies service-host processes by name, with an executable-path fallback when the name is unavailable. This helps prevent service hosts from being mistaken for supervisor processes. Detection is case-insensitive and distinguishes service hosts from unrelated processes.

`Win32_Process` returns an empty `ExecutablePath` for processes the account may
not read, and `svchost.exe` is one of them. The supervisor lookup filtered the
process chain by that path, so the service host stayed a candidate; on a
task-scheduled install the `Win32_Service` query then matched the `Schedule`
service every task's tree hangs under, and the update refused with
`not_controllable` — access denied on the wrong service.

Carry the process name (Win32_Process.Name, /proc/<pid>/comm, `ps` comm) and
filter the service host by name, keeping the image-path check as the fallback
for a listing that has no name. A regression test feeds the rows that a
non-admin account actually gets: `svchost.exe` with no executable path.

Fixes ompweb-dev#537
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Process enumeration now records process names across Linux, Windows, and other POSIX platforms. Windows supervisor discovery uses a new helper to identify and exclude svchost.exe processes by name, falling back to the executable basename.

Changes: Windows service-host detection

Layer / File(s) Summary
Process names and service-host detection
lib/upgrade-process.ts, lib/upgrade-process.test.mjs
ProcessInfo now includes a process name, populated during platform-specific enumeration. The exported isServiceHostProcess helper checks the name and falls back to the executable basename. Tests cover case-insensitive matches, unavailable paths, and non-matching process names.
Windows supervisor filtering
lib/upgrade-process.ts
Windows supervisor discovery excludes ancestry rows identified as service hosts by isServiceHostProcess.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: andrebrait

Merge Risk: Minimal · up to c038b

This change makes non-admin Windows in-app updates correctly identify a daemon run by the scheduled task instead of the svchost.exe Schedule service. No actionable merge-blocking risk remains.

Security architecture risk: Minimal · up to c038b

The change corrects supervisor selection when Windows hides executable paths. No introduced or worsened risk to process ownership, upgrade recovery, or privilege boundaries was identified; existing authorization and identity checks remain in place.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed security-relevant outcome is selection of the service or scheduled task controlling a local installation's process. No new network entrypoint, credential source, or cross-service dependency is introduced by this diff. The web-auth relationship is only an unresolved lexical name match, not evidence of expanded authentication reachability.

Trust Boundaries and Controls

  • observed — Supervisor classification does not itself grant control authority. Existing Windows preflight revalidates configuration and checks service or task access. Task preflight also checks demand-start permission and rejects different task credentials for callers that are neither administrators nor SYSTEM.

Resilience and Maintainability Implications

  • observed — Existing lifecycle safeguards remain: stale process identities are rejected, Windows configuration hashes are rechecked before control, service stop verifies process-tree membership, and task restart restricts replacement discovery using task engines, script roots, and newly observed processes. These are unchanged safeguards, not proof that every concurrent mutation is atomic.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the Windows service host (svchost.exe) is no longer treated as a supervisor during upgrade inspection. The raw summary confirms the new isServiceHostProcess helper and…
Linked Issues check Passed Issue #537 requires that service hosts be identified by process name when the executable path is unavailable, with a regression test. At the reviewed head, lib/upgrade-process.ts exports isServiceHost…
Out of Scope Changes check Passed The changes support the objective of name-based service-host detection. These are: the ProcessInfo name field and its population on Linux, Windows, and other POSIX; the export of ProcessInfo and isSer…
Full details: Title check

Explanation

The title names the main change: the Windows service host (svchost.exe) is no longer treated as a supervisor during upgrade inspection. The raw summary confirms the new isServiceHostProcess helper and the exclusion of service-host processes from supervisor candidates. The objectives match this fix for issue #537, which covers identifying the omp-web-host scheduled task instead of the Schedule service. The title is specific, concise, and follows the conventional fix(scope) form.

Full details: Linked Issues check

Explanation

Issue #537 requires that service hosts be identified by process name when the executable path is unavailable, with a regression test. At the reviewed head, lib/upgrade-process.ts exports isServiceHostProcess(row), which matches /^svchost.exe$/i against row.name, falling back to basename(row.exe) only when name is empty. ProcessInfo gains a name field. The Windows listing fills it from Win32_Process.Name, Linux from /proc/<pid>/comm, and other POSIX from ps -o comm=. The supervisor-side change, which drops service hosts through this predicate, is described in the PR summary and the raw summary. I could not read that hunk directly because the diff and the truncated file read did not return it. The test file lib/upgrade-process.test.mjs (+12 lines, per the raw summary) adds the regression case: svchost.exe with empty path returns true, and node.exe and ompweb.exe return false. The PR reports a live before/after run on Windows 11 that moved the result from the Schedule service to the omp-web-host task. The WMI launch-timeout note is a suggestion in the issue, not a requirement, so its absence does not fail this check. Residual uncertainty: the supervisor query call site was not verified in source.

Full details: Out of Scope Changes check

Explanation

The changes support the objective of name-based service-host detection. These are: the ProcessInfo name field and its population on Linux, Windows, and other POSIX; the export of ProcessInfo and isServiceHostProcess; the supervisor filter that uses the predicate; and the new regression test. The PR does not add the WMI fallback launcher or ReturnValue reporting that the issue marks as optional. No unrelated changes were identified in the available evidence. The unverified part is the Windows supervisor call-site hunk, which the diff tool did not return.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2916cebb-2168-48e0-8596-f0ce59d94e1a
Commits

Reviewing files that changed from the base of the PR and between 8b8e2c1 and c038b80.

Files selected for processing: 2

  • lib/upgrade-process.test.mjs
  • lib/upgrade-process.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@0721-art

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #539: same diagnosis, same name-based filter, and that version also carries the CHANGELOG entry and a test in the windows-service suite, so it is the better fit for the release flow.

For the record, the only extra here was populating name on Linux (/proc/<pid>/comm) and macOS (ps comm); the filter only matters on Windows, so #539's optional name is the smaller change. Thanks for picking it up.

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.

Windows: in-app update refuses with not_controllable — a task-scheduled daemon is misdetected as the Windows service 'Schedule'

1 participant