Skip to content

windows: start a sandbox from session 0 without a session folder grant - #793

Open
TurtIeSocks wants to merge 1 commit into
anthropics:mainfrom
TurtIeSocks:windows-session-zero-bno
Open

TurtIeSocks wants to merge 1 commit into
anthropics:mainfrom
TurtIeSocks:windows-session-zero-bno

Conversation

@TurtIeSocks

Copy link
Copy Markdown
Contributor

Summary

From session 0 (ssh, a task set to run whether logged on or not) every launch fails with NtOpenDirectoryObject(\Sessions\0\BaseNamedObjects, READ_CONTROL|WRITE_DAC): NTSTATUS 0xC0000034. Session 0's objects live in the global \BaseNamedObjects, which every service shares, so it shouldn't be granted. It doesn't need to be: Everyone already holds CREATE_OBJECT | CREATE_SUBDIRECTORY there.

 grant_sandbox_on_session_bno
+  if broker_session() == 0: return Ok
   open \Sessions\<ts>\BaseNamedObjects, add the srt-sandbox ACE

Evidence

Windows 11 ARM64, over ssh (session 0), through a tool that vendors this srt-win source:

  • Before: the 0xC0000034 error above
    After: cmd, Git Bash sh and git run in the sandbox. A write outside the write roots and a read of a denied folder are refused, the proxy returns 403 for a host not on the allowlist, and a direct connection is blocked

cargo test --lib: 191 passed. profile::tests::objects_the_caller_may_not_change_are_classed_and_do_not_stop_the_grant fails on that machine on main too.

Merge Danger

Door: two-way

Blast Radius: session 0 launches only

Disclaimer: Code was generated by Claude 🤖 - reviewed and tested by a human 🐢

From session 0 (ssh, a scheduled task set to run whether logged on or
not), every launch failed before the runner started:
grant_sandbox_on_session_bno opened \Sessions\0\BaseNamedObjects, which
does not exist, and failed with NTSTATUS 0xC0000034. Session 0's named
objects live in the global \BaseNamedObjects instead.

That folder must not be granted: every service shares it, and only SYSTEM
and Administrators can write its DACL. It also needs no grant. Its DACL
already gives Everyone QUERY | TRAVERSE | CREATE_OBJECT |
CREATE_SUBDIRECTORY (0x2000F), and the lockdown token keeps Everyone
enabled, so msys2's per-DLL subdirectory, which the grant exists for, can
already be made there.

So grant_sandbox_on_session_bno returns without opening anything in
session 0. broker_session() reads the session once for it and
open_session_bno, and session_bno_path() holds the rule as a pure function
with a test each way.

Checked on Windows 11 ARM64 over ssh: cmd, Git Bash's sh and git run in
the sandbox; a write outside the write roots and a read of a denied
folder are refused; the proxy allows the allowed host, returns 403 for
another, and a direct connection is blocked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant