[PR #3192] [MERGED] Launcher on Windows: update without the self-deleting copy Defender flags as Wacatac #4839

Closed
opened 2026-11-03 05:08:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3192
Author: @kacpherek
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: fix/launcher-windows-update-no-relocated-copy


📝 Commits (4)

  • 9130fae Launcher on Windows: update by renaming the running file aside, not self_replace
  • 8d680ba Launcher on Windows: delete the binary an update moved aside
  • 1a1aae6 Merge remote-tracking branch 'origin/main' into pr-3192
  • 0240b30 Launcher on Windows: remove an interrupted update's copy too

📊 Changes

4 files changed (+76 additions, -17 deletions)

View changed files

📝 launcher/Cargo.lock (+0 -12)
📝 launcher/Cargo.toml (+0 -1)
📝 launcher/src/backend.rs (+74 -4)
📝 launcher/src/main.rs (+2 -0)

📄 Description

Fixes #3175

What and why

Microsoft Defender quarantines a file named .horizon-launcher.<random>.__relocated__.exe as Trojan:Script/Wacatac.H!ml when the launcher updates itself on Windows. It's a false positive from Defender's machine-learning model (the !ml part), but what set it off is real: on Windows, self_replace::self_replace does what a self-deleting dropper does:

  1. renames the running horizon-launcher.exe to .horizon-launcher.<32 random letters>.__relocated__.exe;
  2. copies it again as .horizon-launcher.<random>.__selfdelete__.exe, opened with FILE_FLAG_DELETE_ON_CLOSE;
  3. starts that copy with the launcher's process handle; the copy waits for the launcher to exit, deletes the original, then starts a hidden cmd.exe /c exit that inherits the handle so the copy deletes itself too;
  4. to make that work, the crate puts a hook in .CRT$XCV that runs before main in every launch of the launcher, update or not.

The Windows exe isn't Authenticode-signed either, so Defender has nothing else to go on for a fresh build.

Now Windows does the same thing the macOS bundle update already does: the running launcher is renamed to horizon-launcher.exe.old-<pid>-<n> in its own folder (Windows lets a running exe be renamed, just not written or deleted), and the new binary takes its path. The next start deletes horizon-launcher.exe.old-*, retrying for a few seconds in the background because the launcher it restarted from is still exiting. Nothing is copied under a random name, no helper process is started, and self-replace is gone from the launcher's dependencies (the Unix path stopped using it already).

restart() is unchanged: exe_path() was read at start, so it still starts the new binary at the original path.

Not covered

The reporter also saw a UAC prompt. Nothing in the launcher asks for elevation on its own (no runas, no manifest asking for it); I asked in the issue which program the prompt named.

Self-check

cargo clippy --all-targets --features gpui/runtime_shaders -- -D warnings in launcher/ passes on macOS. The new Windows functions were type-checked and linted for x86_64-pc-windows-msvc on their own; the full Windows build is left to CI. Not run on a Windows machine.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3192 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/launcher-windows-update-no-relocated-copy` --- ### 📝 Commits (4) - [`9130fae`](https://github.com/horizon-rust/horizon/commit/9130faeae99ab51f4bd8aa11d311bf4ebc4c5811) Launcher on Windows: update by renaming the running file aside, not self_replace - [`8d680ba`](https://github.com/horizon-rust/horizon/commit/8d680ba46af021d56cc99b68653cbf4386a142b9) Launcher on Windows: delete the binary an update moved aside - [`1a1aae6`](https://github.com/horizon-rust/horizon/commit/1a1aae69ec1e3bd59aa312d7ca5215fd57f8bccc) Merge remote-tracking branch 'origin/main' into pr-3192 - [`0240b30`](https://github.com/horizon-rust/horizon/commit/0240b305c919a2ddb8f34b2f25e92873d2dc95f9) Launcher on Windows: remove an interrupted update's copy too ### 📊 Changes **4 files changed** (+76 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `launcher/Cargo.lock` (+0 -12) 📝 `launcher/Cargo.toml` (+0 -1) 📝 `launcher/src/backend.rs` (+74 -4) 📝 `launcher/src/main.rs` (+2 -0) </details> ### 📄 Description Fixes #3175 ## What and why Microsoft Defender quarantines a file named `.horizon-launcher.<random>.__relocated__.exe` as `Trojan:Script/Wacatac.H!ml` when the launcher updates itself on Windows. It's a false positive from Defender's machine-learning model (the `!ml` part), but what set it off is real: on Windows, `self_replace::self_replace` does what a self-deleting dropper does: 1. renames the running `horizon-launcher.exe` to `.horizon-launcher.<32 random letters>.__relocated__.exe`; 2. copies it again as `.horizon-launcher.<random>.__selfdelete__.exe`, opened with `FILE_FLAG_DELETE_ON_CLOSE`; 3. starts that copy with the launcher's process handle; the copy waits for the launcher to exit, deletes the original, then starts a hidden `cmd.exe /c exit` that inherits the handle so the copy deletes itself too; 4. to make that work, the crate puts a hook in `.CRT$XCV` that runs before `main` in **every** launch of the launcher, update or not. The Windows exe isn't Authenticode-signed either, so Defender has nothing else to go on for a fresh build. Now Windows does the same thing the macOS bundle update already does: the running launcher is renamed to `horizon-launcher.exe.old-<pid>-<n>` in its own folder (Windows lets a running exe be renamed, just not written or deleted), and the new binary takes its path. The next start deletes `horizon-launcher.exe.old-*`, retrying for a few seconds in the background because the launcher it restarted from is still exiting. Nothing is copied under a random name, no helper process is started, and `self-replace` is gone from the launcher's dependencies (the Unix path stopped using it already). `restart()` is unchanged: `exe_path()` was read at start, so it still starts the new binary at the original path. ## Not covered The reporter also saw a UAC prompt. Nothing in the launcher asks for elevation on its own (no `runas`, no manifest asking for it); I asked in the issue which program the prompt named. ## Self-check `cargo clippy --all-targets --features gpui/runtime_shaders -- -D warnings` in `launcher/` passes on macOS. The new Windows functions were type-checked and linted for `x86_64-pc-windows-msvc` on their own; the full Windows build is left to CI. Not run on a Windows machine. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:08:19 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4839
No description provided.