Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/omarchy-windows-vm
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,19 @@ prepare_caller_mounts() {
# Privacy is an explicit preflight step for both already-pinned sources, not
# a side effect halfway through the two-mount transaction. Old umask-022
# installs are hardened together before either Docker-facing anchor changes.
chmod 0700 -- "/proc/$BASHPID/fd/$storage_fd" "/proc/$BASHPID/fd/$shared_fd" || {
# GNU chmod keeps a directory's setuid/setgid bits across a four-digit numeric
# mode, so a stray 2700 on ~/Windows would survive 0700 and fail the check
# below; the five-digit form clears every special bit as well.
chmod 00700 -- "/proc/$BASHPID/fd/$storage_fd" "/proc/$BASHPID/fd/$shared_fd" || {
echo "omarchy-windows-vm: could not make the storage and shared directories private" >&2
exec {storage_fd}<&-
exec {shared_fd}<&-
return 1
}
storage_mode=$(stat -Lc '%a' "/proc/$BASHPID/fd/$storage_fd" 2>/dev/null) || storage_mode=""
shared_mode=$(stat -Lc '%a' "/proc/$BASHPID/fd/$shared_fd" 2>/dev/null) || shared_mode=""
if [[ $storage_mode != 700 || $shared_mode != 700 ]]; then
echo "omarchy-windows-vm: storage and shared directories must be mode 0700 (got ${storage_mode:-unknown} and ${shared_mode:-unknown})" >&2
exec {storage_fd}<&-
exec {shared_fd}<&-
return 1
Expand Down
10 changes: 10 additions & 0 deletions test/shell.d/windows-vm-mount-boundary-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ if setpriv --reuid=1001 --regid=1001 --clear-groups cat "$EXPECTED_SHARED/shared
fi
pass "cross-filesystem symlink sources bind by identity and migrated 0700 leaves deny another account"

# A caller can leave setgid or other special bits on ~/Windows (mode 2700).
# Numeric chmod as root keeps those bits on directories, so hardening must
# still land on exactly 0700 instead of failing the launch without a message.
chmod 2700 /home/shared-target
chmod 4700 /home/storage-target
with_vm_lock prepare_caller_mounts || fail "root rejected pinned sources carrying stray special mode bits"
[[ $(command stat -Lc '%a' /home/storage-target) == 700 &&
$(command stat -Lc '%a' /home/shared-target) == 700 ]] || fail "hardening left special mode bits on the pinned sources"
pass "root strips stray setuid/setgid bits while hardening the pinned sources"

# Existing production boundary components are never repaired in place when
# their ownership or write permissions are unsafe. Both the preparation path
# and the final pre-Docker guard must fail closed without disturbing the binds.
Expand Down