omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

windows-vm: chmod 0700 preserves directory setgid bit, causing launch to fail safety check

Open VillainRU opened this issue 3 months ago • 7 comments

System details

  • CPU: AMD Ryzen 7 5700X3D
  • GPU: AMD Radeon RX 9070/9070 XT/9070 GRE (Navi 48)
  • Omarchy: 4.0.2-1
  • Kernel: 7.1.9-arch1-2
  • GNU coreutils: 9.11

What's wrong?

The Windows VM launcher exits immediately after successful polkit authorization and shows the critical notification:

Windows VM — Failed to start Windows VM

This happens when either VM source directory has a set-ID bit in addition to the expected private permissions. In my case, ~/Windows had mode 2700 (drwx--S---). The VM data itself and Docker were healthy.

Steps to reproduce

  1. Install/configure the Omarchy Windows VM.

  2. Add the set-group-ID bit to the shared directory:

    chmod g+s ~/Windows
    stat -c '%a' ~/Windows  # 2700
    
  3. Launch the VM from the menu or run omarchy-windows-vm launch.

  4. Approve the polkit prompt.

The launcher fails before starting the Docker container.

The underlying chmod behavior can also be reproduced without the VM:

dir=$(mktemp -d)
chmod 2700 "$dir"
chmod 0700 "$dir"
stat -c '%a' "$dir"       # still 2700
chmod a-s,u=rwx,go= "$dir"
stat -c '%a' "$dir"       # 700
rmdir "$dir"

Root cause

prepare_caller_mounts() attempts to normalize both directories and then requires their modes to equal exactly 700:

chmod 0700 -- "/proc/$BASHPID/fd/$storage_fd" "/proc/$BASHPID/fd/$shared_fd"

storage_mode=$(stat -Lc '%a' "/proc/$BASHPID/fd/$storage_fd")
shared_mode=$(stat -Lc '%a' "/proc/$BASHPID/fd/$shared_fd")
if [[ $storage_mode != 700 || $shared_mode != 700 ]]; then
  return 1
fi

GNU chmod deliberately preserves set-user-ID and set-group-ID bits on directories when a plain numeric mode such as 0700 is used. Therefore the normalization reports success but leaves 2700 unchanged, and the exact-mode check immediately rejects it.

Reference: https://www.gnu.org/software/coreutils/manual/html_node/Operator-Numeric-Modes.html

Expected behavior

The privacy normalization should explicitly clear special bits so that the following exact-mode safety check can succeed.

Suggested fix

Use a symbolic mode that clears set-ID bits explicitly:

-  chmod 0700 -- "/proc/$BASHPID/fd/$storage_fd" "/proc/$BASHPID/fd/$shared_fd" || {
+  chmod a-s,u=rwx,go= -- "/proc/$BASHPID/fd/$storage_fd" "/proc/$BASHPID/fd/$shared_fd" || {

chmod =700 also clears them with GNU coreutils, but the symbolic form makes the security intent explicit. I verified locally that it changes both 2700 and 700 inputs to exactly 700, after which the protected bind-mount checks pass.

VillainRU avatar Aug 31 '26 14:08 VillainRU

This is serious. I use the windows VM for work. Thank god i can rollback but the migration thing broke my VM. They should have implemented a check to NOT TOUCH existing VMs. That was a really bad slip.

Scav-OG avatar Aug 31 '26 19:08 Scav-OG

Confirmed, and fixed in #9605.

prepare_caller_mounts() in bin/omarchy-windows-vm hardens both mount sources with chmod 0700 and then asserts the mode is exactly 700. chmod with a numeric mode does not clear S_ISGID on a directory — the kernel preserves it whenever the caller is in the file's group or holds CAP_FSETID, which root always does. So a 2700 directory stays 2700, chmod still returns 0, and the != 700 branch rejects the source and returns 1 with nothing on stderr. Reproduced directly: mkdir /tmp/t && chmod 2700 /tmp/t && chmod 0700 /tmp/t && stat -c %a /tmp/t still prints 2700.

#9605 switches the three sites that make these directories private to a symbolic mode, which does clear the set-ID bits, and adds a message to the verification branch so a future failure here says why. Regression cases start the sources at 2700/6700; they fail against the current code and pass with the fix. ./test/cli and the four windows-vm suites pass on a clean VM.

This was reported three times independently — #9374, #9540 and #9567 — with the same root cause; #9605 closes all three.

Reviewed by Claude Opus 5 and by Codex at xhigh. Codex verified the mode arithmetic across every set-ID combination and caught that the existing suites start these directories at 0755, so they would have passed against the broken chmod; the regression cases came out of that. Waiting on a maintainer to merge.

omarchybot avatar Sep 01 '26 12:09 omarchybot

Ran into this today as well, Temp fix was running chmod g-s ~/Windows

chapaghetti avatar Sep 02 '26 18:09 chapaghetti

I hit this independently on an existing Windows VM. ~/Windows was mode 2700 (setgid). A plain chmod 0700 left it at 2700; explicitly running chmod g-s ~/Windows changed it to exact mode 700, after which the protected readiness check and launcher succeeded. No directory contents were changed.

In my case this was one of two independent blockers: the other was stale private RDP credentials. The proposed symbolic-mode fix in #9605 matches the successful local workaround.

davetist avatar Sep 03 '26 21:09 davetist

Still reproduces on omarchy 4.0.4-1 (kernel 7.2.5-3-omarchy, GNU coreutils 9.11), with #9605 unmerged.

~/Windows was mode 2700 after a working install and one guest shutdown; ~/.windows was 700, so only the shared source tripped the check. chmod g-s ~/Windows restored exact 700 and the next launch succeeded.

One diagnostic marker that may help others land here faster: the journal shows the pkexec session for __priv up_wait opening and closing within the same second, so the failure is visibly before Docker is ever invoked. omarchy-windows-vm status reports exited throughout, which reads like a container problem and is not one.

Nothing new on the cause, just confirmation that it is still live.

RemyDuijkeren avatar Sep 19 '26 04:09 RemyDuijkeren

Automated duplication check: this issue looks similar to #9334, which covers the same Windows VM setgid permission check. I keep that one open and close this one to keep the discussion in one place.

If you feel this is the wrong decision, please open the issue again with a note on the difference.

bjarneo avatar Sep 20 '26 18:09 bjarneo

Update: #12323 has merged into quattro. The reported numeric-chmod/setgid rejection is fixed in both mount-source hardening paths on quattro. Launch, install and removal re-harden the sources without weakening the exact mode-700 check.

Scope checked by GPT-6 in Codex and Codex Medium against the discussion and landed change; review independence is not guaranteed. No tests were rerun for this cleanup.

Omabot on behalf of DHH

omarchybot avatar Oct 04 '26 12:10 omarchybot