Skip to content

fix(agent): stop refusing Windows installs over permissions Maple does not own - #1518

Merged
AnthonyRonning merged 4 commits into
masterfrom
claude/windows-private-staging
Nov 9, 2026
Merged

AnthonyRonning merged 4 commits into
masterfrom
claude/windows-private-staging

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Three Windows reports on 0.0.20 were all Maple's own permission guard, not Windows failing (Windows error: none in each):

Report Support code Cause
steig (Windows 11 26300) MWI/installation/verify-checker-image/foreign-write-ace The payload unpacked into %TEMP% inherits whatever TEMP allows
Third user (Windows 11 26200) same same
User on Windows 10 19045, custom folder MWI/installation/validate-installation-parent/foreign-write-ace Any folder outside the profile inherits "Authenticated Users: Modify"
Same user, default folder "Choose a private local data location" An existing store file not owned by the user

Reproduced on the x64 QA VM with the signed releases:

  • TEMP=C:\Temp plus signed 0.0.20 gives exactly MWI/installation/verify-checker-image/foreign-write-ace at stage 24.
  • Signed 0.0.19 with store-v1\db\maple.db owned by Administrators (the user keeps full control) shows the user's "Choose a private local data location" screen exactly.

Our clean test machines never carry these permissions; real PCs often do (a moved TEMP, a profile copied from an old PC, domain groups, folders under a drive root).

Changes

  • Private staging. NSIS unpacks into %LOCALAPPDATA%\Maple Work Installer Staging\<pid>-<tick>, created with CreateDirectoryW and a protected ACL (D:P SYSTEM, Administrators, OWNER RIGHTS) through NSIS's own System plugin. Files written into it inherit only those entries, so the native per-file checks are unchanged and pass. Each run gets a new folder, and an existing one is never adopted. NSIS deletes the folder when it finishes; a later install removes runs older than an hour that a killed installer left behind.
  • No folder page. A folder outside the profile could only fail. InstallDirRegKey and /D= still apply.
  • Install parent not judged by its ACL. installation_parent keeps the link-free, pinned-path and directory checks but no longer reads permissions on a folder Maple doesn't own; the new root still gets its own protected ACL. The residual risk is another non-admin account with Full Control on %LOCALAPPDATA%\Programs, which no default profile has and which every per-user app shares.
  • Store repair. On Windows, a store object that only the user, SYSTEM or Administrators could have written, such as an Administrators-owned file from an elevated run, is restored to the private ACL (owner user, one full-control entry, protected). Anything another account could write is still refused, as are hard-linked files. The log now says which SID and what access, or what was repaired.
  • Report detail. Permission, owner and link refusals add a detail: line: the kind of account (authenticated-users, other-domain-account-rid-1001, same-domain-account-rid-512-domain-admins, capability, …), the access mask and whether the entry is inherited, or the link type and its position in the path. No names, SIDs or domain identifiers. Support codes are unchanged.
  • Host start: 30 s. A client waits 30 s, not 15 s, for a host it just spawned. On the emulated VM the 114 MB executable needed about 19 s just to reach main, so every normal launch of 0.0.19 showed "Maple host did not start". The idle exit and handshake timeouts stay at 15 s.

Testing

  • makensis -V2 -WX with NSIS 3.12 from the pinned nixpkgs.
  • New cross-platform tests for SID classification and the report detail line; updated Windows tests for parent admission and Administrators-owned store repair.
  • just ci-lint and just ci-test (pre-commit) on macOS. Windows code is compiled and tested by the ci:windows lanes.
  • VM smoke test of this PR's unsigned x64 Dev package (run 42582270343) on the Windows 11 x64 QA VM, as a standard user:
Case 0.0.20 / 0.0.19 This PR
TEMP=C:\Temp and Users:Modify on Programs verify-checker-image/foreign-write-ace installs, exit 0; staging folder and root removed afterwards
Normal launch on the emulated VM "Maple host did not start" every time reaches the sign-in page through the Start launcher
maple.db owned by Administrators "Choose a private local data location" opens; log: Store maple.db is owned by SYSTEM or Administrators; Maple restored its private permissions
generation.json writable by Everyone refused, no reason still refused; log: S-1-1-0 can write to it (access 0x00100116, explicit)
Existing app root writable by Everyone refused, no detail still refused; detail: account: everyone; access: 0x00100116; inherited: no; object: folder (now reported as inspect-existing-installation)
Interactive install folder page first no folder page; Close opens the app

ARM64 is built by CI only; there is no ARM64 VM yet. The first CI run's agent-test, agent-package-linux and research-desktop-windows failures were GitHub release downloads returning HTTP 504 (linuxdeploy, Tauri bundler), not this change.

🤖 Generated with Claude Code

…s not own

Three Windows reports on 0.0.20 were Maple's own permission guard, not
Windows failures: two stopped at verify-checker-image/foreign-write-ace
and one at validate-installation-parent, and the same user's store was
refused as not private. A relocated TEMP reproduces the first exactly:
with TEMP=C:\Temp, signed 0.0.20 fails with
MWI/installation/verify-checker-image/foreign-write-ace.

- NSIS unpacks the payload into a per-run folder under
  %LOCALAPPDATA%\Maple Work Installer Staging that it creates with a
  protected ACL (SYSTEM, Administrators, owner), instead of $PLUGINSDIR,
  which inherits whatever TEMP allows. The native per-file checks are
  unchanged and now see only entries Maple set. A later install removes
  runs left over from a killed installer after an hour.
- The folder page is gone: any folder outside the profile inherits write
  access for all signed-in users and could only fail.
- The parent of a new install root is no longer judged by its ACL. The
  root is created below it with its own protected ACL, and the path stays
  pinned and free of links as before.
- A Windows store object that only the user, SYSTEM or Administrators
  could have written, such as a SQLite file an elevated run left owned by
  Administrators, is restored to its private ACL instead of blocking the
  app forever. Anything another account could write is still refused,
  and the log now says which SID and access.
- Installer reports add a detail line for permission, owner and link
  refusals: the kind of account (authenticated-users,
  other-domain-account-rid-1001, ...), access mask, inheritance, or the
  link type and its position in the path. No names or SIDs. Support
  codes are unchanged.
- A client now waits 30 s, not 15 s, for a host it just spawned. On a
  slow PC or under antivirus the 114 MB executable alone can take longer
  than 15 s to start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AnthonyRonning AnthonyRonning added ci:windows Run Windows checks on this PR ci:package Build unsigned packages on this PR labels Nov 9, 2026
AnthonyRonning and others added 3 commits November 9, 2026 00:42
…llation

The VM test of the PR package showed an Everyone-writable Maple Work Dev
root reported as validate-installation-parent, though that branch checks
the app root itself and never its parent. Support would look at the
wrong folder. It now reports inspect-existing-installation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
NSIS unpacked its System plug-in into %TEMP% and locked that folder only
for elevated installers, so a TEMP shared with other accounts (C:\Temp)
let them replace the DLL before it loaded. Unpack plug-ins into a folder
under the profile's staging root before the first plug-in call.

The root now inherits the profile's entries, which name the user, instead
of a protected ACL whose OWNER RIGHTS entry followed whoever created it.
A root left behind by an interrupted elevated run (owned by
Administrators) blocked later normal installs at stage 21.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

Both findings are real. 4c52fb02 fixes both.

P1, System.dll loaded from TEMP. Confirmed in NSIS's own source: Initialize_____Plugins creates $PLUGINSDIR with GetTempFileName $TEMP. EW_CREATEDIR locks the folder down only when UserIsAdminGrpMember(), so a normal run inherits TEMP's entries. Master was worse, because it ran maple-agent.exe itself from there.

The installer now builds the plug-in folder before its first plug-in call:

  • CreateDirectory "$LOCALAPPDATA\Maple Work Installer Staging"
  • then GetTempFileName, Delete and CreateDirectory inside that root
  • then UnsafeStrCpy $PLUGINSDIR

Initialize_____Plugins skips any non-empty $PLUGINSDIR, so NSIS never creates a TEMP plug-in folder. NSIS still deletes $PLUGINSDIR on exit.

The only TEMP use left is the solid compressor's decompressed data block. NSIS opens it with share mode 0 and FILE_FLAG_DELETE_ON_CLOSE, so no other process can open it while the installer runs.

P2, an Administrators-owned root blocks normal installs. Agreed. The root is now created with plain CreateDirectory, so it inherits the profile's entries, and those name the user explicitly. A root left behind by an elevated run stays usable by a normal one, and the reverse also holds.

I kept each run's own folder as D:P(SY)(BA)(OW) rather than adding the user's SID. That folder is only used by the run that created it. In an elevated run, OW resolves to Administrators, so the elevated payload isn't writable by the same user's non-elevated processes through that folder's ACL. The tradeoff is that a killed elevated run leaves a folder that only a later elevated run can clean up.

Your exact fixture, a root with the old protected ACL owned by Administrators, still stops at stage 21 ("creating the installer's working folder"). New code never produces that root, and no release did either, so please delete it on test machines.

Related but out of scope: the NSIS uninstaller copies itself to %TEMP%\~nsu*.tmp\Un.exe before any script runs. That predates this PR and needs a different uninstall entry point, so it's tracked in #1530.

Verified on the x64 QA VM with the CI Dev package 0.0.21-785fca8, both runs silent and non-elevated (Medium integrity):

  • TEMP=C:\Temp, where Authenticated Users can modify: the install exits 0. A watcher saw System.dll load from %LOCALAPPDATA%\Maple Work Installer Staging\nszF201.tmp, owned by the user, with only SYSTEM, Administrators and the user in its ACL. The only file under C:\Temp was the exclusive data-block file, removed at exit.
  • An existing root and a protected 999-1 run folder, both owned by Administrators as an elevated run would leave them: the install exits 0 with support code: MWI/installation/installation/success.

A silent run still leaves one empty ns*.tmp folder in the root, because the working directory stays inside it at exit. The next install removes it after an hour.

@AnthonyRonning
AnthonyRonning merged commit 817ef05 into master Nov 9, 2026
25 checks passed
@AnthonyRonning
AnthonyRonning deleted the claude/windows-private-staging branch November 9, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:package Build unsigned packages on this PR ci:windows Run Windows checks on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant