Repository navigation
Description
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-245uses the fixed<target>.newpath and opens it withO_CREATE|O_WRONLY|O_TRUNC.internal/update/replace_windows.go:20-35later 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
- Install
zero.exein a directory where the victim performs updates with higher privileges but the attacker can create or replace sibling files. - 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. - Trigger
zero update. - 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
PierrunoYT commentedon Jul 18, 2026
I'm working on this.
security(update): bind the binary swap to the staged object, not its …
fix(update): keep the recovery copy a failed restore promised
security(update): stage binary replacement at an unpredictable, exclu…
security(update): bind the binary swap to the staged object, not its …
fix(update): keep the recovery copy a failed restore promised
security(update): stage binary replacement at an unpredictable, exclu…