Skip to content

windows-vm: actually clear setgid on the shared/storage source before launch - #11714

Closed
tjardick wants to merge 1 commit into
omacom:quattrofrom
tjardick:fix-windows-vm-setgid-remediation
Closed

tjardick wants to merge 1 commit into
omacom:quattrofrom
tjardick:fix-windows-vm-setgid-remediation

Conversation

@tjardick

Copy link
Copy Markdown

What happened

prepare_caller_mounts() hardens ~/.windows and ~/Windows to mode 0700 before binding them in as the protected Docker anchors, using a bare numeric chmod 0700. GNU chmod treats an absolute numeric mode as a silent no-op for any setuid/setgid bit a directory already carries — only an explicit symbolic clear (u-s,g-s) removes it.

The dockurr/windows container marks ~/Windows setgid while it shares that directory over SMB/9p to the guest. So on every launch after the first, prepare_caller_mounts's own mode check silently fails (that branch has no echo on failure), surfacing only as the generic "Failed to start Windows VM!" notification with zero diagnostic anywhere — not the terminal, not the journal.

Verified in isolation, independent of any container:

$ tmpd=$(mktemp -d); chmod 2700 "$tmpd"; stat -c '%a' "$tmpd"
2700
$ chmod 0700 "$tmpd"; echo rc=$?; stat -c '%a' "$tmpd"
rc=0
2700          # <- silently unchanged
$ chmod u-s,g-s -- "$tmpd"; chmod 0700 -- "$tmpd"; stat -c '%a' "$tmpd"
700           # <- actually cleared

The fix

Add the symbolic clear (chmod u-s,g-s) before the existing numeric chmod 0700 in prepare_caller_mounts(), so the remediation it already attempts actually works.

Also adds a regression test to test/shell.d/windows-vm-mount-boundary-test.sh that reproduces the setgid drift on the legacy shared source and asserts prepare_caller_mounts recovers it instead of failing closed.

One honesty note on testing: that suite simulates the root/pkexec boundary via unshare + mount namespaces, and in my sandboxed dev environment it fails before reaching my new assertion — but it fails identically against unmodified quattro, so that's a pre-existing environment limitation on my end, not something this change introduces. The core mechanism above is verified directly and reliably reproduces both the bug and the fix.

Duplicate reports this addresses

This exact root cause has been independently reported many times: #11575, #10321, #10486, #10151, #10004, #9943, #10047, #9374, #10983, #9567, #9884, #10608, #10369, #10256, #9746, #11490, #11603, #10114, #9630, #10149, #10856, #11262.

🤖 Generated with Claude Code

… launch

prepare_caller_mounts() hardens ~/.windows and ~/Windows to mode 0700 before
binding them in as the protected Docker anchors, using a bare numeric
`chmod 0700`. GNU chmod treats an absolute numeric mode as a no-op for any
setuid/setgid bit a directory already carries -- only an explicit symbolic
clear (`u-s,g-s`) removes it. The dockurr/windows container marks ~/Windows
setgid while it shares that directory over SMB/9p to the guest, so every
launch after the first quietly failed prepare_caller_mounts's own mode
check, with no diagnostic anywhere (that branch has no echo on failure) --
just the generic "Failed to start Windows VM!" notification.

Verified in isolation, independent of the container: chmod 0700 on a plain
directory that already carries setgid reports success (rc=0) and leaves the
mode unchanged; chmod u-s,g-s -- then chmod 0700 clears it reliably.

Add the symbolic clear before the existing numeric chmod, and add a
regression test that reproduces the drift on the legacy shared source and
confirms prepare_caller_mounts recovers it instead of failing closed.

Same root cause as the following independently reported issues: omacom#11575,
omacom#10321, omacom#10486, omacom#10151, omacom#10004, omacom#9943, omacom#10047, omacom#9374, omacom#10983, omacom#9567, omacom#9884,
omacom#10608, omacom#10369, omacom#10256, omacom#9746, omacom#11490, omacom#11603, omacom#10114, omacom#9630, omacom#10149,
omacom#10856, omacom#11262.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@bjarneo

bjarneo commented Sep 20, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #9322, which covers the same Windows VM mount set-ID hardening. I keep that one open and close this one to consolidate review. If you feel this is the wrong decision, please open the PR again with a note on the difference.

@bjarneo bjarneo closed this Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants