Skip to content

security(windows): predictable updater staging path can overwrite another file #742

Closed

Description

@PierrunoYT

Summary

The Windows updater stages verified executable bytes at the predictable path <target>.new and opens that path with truncating, link-following semantics.

If an update runs elevated and a lower-privileged process can create or race files in the installation directory, that process can precreate <target>.new as a hard link or supported reparse-point link to another file writable by the updater. The update then truncates and overwrites the linked target with the Zero executable bytes.

Severity

High when an elevated update operates in an installation directory writable by a lower-privileged user or process. Low when the installation directory is writable only by the same principal running the updater.

Affected code

  • internal/update/apply.go:220-245 uses the fixed <target>.new path and opens it with O_CREATE|O_WRONLY|O_TRUNC.
  • internal/update/replace_windows.go:20-35 later trusts that staged pathname during replacement.

The dangerous operation is the truncating open of .new. The .old rename/removal sequence operates on the final pathname entry and is not itself the same arbitrary-overwrite primitive.

Reproduction outline

  1. Install zero.exe in a directory where the victim performs updates with higher privileges but the attacker can create or replace sibling files.
  2. Before the update writes <zero.exe>.new, create that path as a hard link or applicable reparse-point link to another file writable by the elevated updater.
  3. Trigger zero update.
  4. Observe the updater truncate and write verified executable bytes through the staged path to the unintended file.

A focused Windows reproduction is still needed to document which reparse-point types are followed by the exact Go/Windows combination. Hard-link behavior should be tested separately.

Impact

This provides an attacker-controlled arbitrary file overwrite primitive, with the written content fixed to the verified Zero executable. Depending on the selected target, that can corrupt system/application state or replace a security-sensitive executable/configuration file. Exploitability depends on installation-directory ACLs and updater privilege separation.

Suggested fix

  • Create a cryptographically random staging filename in the destination directory.
  • Use exclusive creation and no-follow/reparse-point-safe handle semantics.
  • Verify that the opened object is a new regular file with the expected owner/location.
  • Write, flush, and close through that verified handle.
  • Atomically replace the target using Windows APIs that preserve object identity.
  • Add integration tests for precreated hard links/reparse points and concurrent staging-path races.

Activity

  1. PierrunoYT commented on Jul 18, 2026

    @PierrunoYT
    ContributorAuthor

    I'm working on this.

  2. added
    issue-approvedReviewed and approved by the core team; community PRs may implement this issue.
    on Jul 21, 2026
  3. added 3 commits that reference this issue on Aug 11, 2026
    da8d425
    09cfb6a
    dccccb5
  4. added a commit that references this issue on Aug 11, 2026
    cabfeef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue-approvedReviewed and approved by the core team; community PRs may implement this issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions