fix(agent): the Windows setup gives AppContainers back the NUL device, as Windows 11 24H2 does #131
No reviewers
Labels
No labels
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Beanstalk!131
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Beanstalk:fix/nul-for-appcontainers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The root cause of "git can't start in the sandbox: could not open '/dev/null' ... Permission denied".
On some Windows builds, the NUL device's permissions have no entry for ALL APPLICATION PACKAGES, so nothing in an AppContainer can open NUL. Windows 11 24H2 has one by default:
(A;;0x1201bf;;;AC)(A;;0x1201bf;;;S-1-15-2-2)Git for Windows opens NUL at its very start. The compiler probes (
clang -### -c nul),cmd >nuland Python'sDEVNULLin Longshot's build would fail next. Affected PCs ran Windows 10 22H2 and some 26200/26300 builds. Since nightly-217, each of them fails one job and then stops taking jobs.What changes
agent/Core/WindowsNul.cs):\\.\NULfor READ_CONTROL | WRITE_DAC and adds an allow entry with mask 0x1201bf for S-1-15-2-1 and S-1-15-2-2, only where one is missing. It changes no other entry, and running it twice changes nothing.-EncodedCommand). The P/Invoke uses an in-memory dynamic assembly, so there is noAdd-Typeand no temp file.\Beanstalk\NUL access for AppContainers.%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exewith the grant inline.PSModulePathto Windows' own modules, soRegister-ScheduledTaskcan't load a module from the user's Documents.setup-windows-usernow does it as well;setupoffers it when the self-test finds the problem;setup-windows-nulandremove-windows-nulcommands, andremove-windows-userremoves the task too.The grant applies at once, so no reboot is needed.
nulcheck runs in the AppContainer before git. When it fails, the AppContainer is ruled out, so no job fails on it. The window and the main screen say: "Windows on this PC doesn't let sandboxed programs open NUL (some Windows builds); set up the Windows sandbox (one UAC prompt) to fix it".agent/README.mdanddocs/using.mdsay what it changes, why, and how to undo it (delete the task; the permission goes at the next boot).Not verifiable here
Only a real affected Windows PC can show these:
SetSecurityInfoon the NUL handle takes;\Device\MountPointManager) could be the next block, and the self-test would say so.The first check is on a maintainer's affected PC after the next nightly.
Tests
The agent's checks on a throwaway container: 2354 passed. New
NulCheckscover:🤖 Generated with Claude Code
On some Windows builds \Device\Null's DACL has no entry for ALL APPLICATION PACKAGES or ALL RESTRICTED APPLICATION PACKAGES, so no program in the AppContainer can open NUL: Git for Windows dies at its first open of /dev/null ("could not open '/dev/null' for reading and writing: Permission denied", several farm PCs in Nov 2026), and the build's compiler probes, cmd's >nul and Python's DEVNULL would follow. Windows 11 24H2 has both entries. - WinNul: adds the two missing entries (read and write, 0x1201bf, as 24H2) and changes nothing else. A device's DACL is made again at each boot, so the setup also registers the task \Beanstalk\NUL access for AppContainers: SYSTEM, at every boot, Windows' own powershell.exe with the script inline (-EncodedCommand, P/Invoke through an in-memory assembly): it runs or loads no file a non-administrator can write. Registered from XML inside the script, so no file sits between the agent and Task Scheduler. - One UAC prompt: setup-windows-nul (and the window's Fix the sandbox, and setup's offer when the self-test finds it); setup-windows-user does it too. remove-windows-nul and remove-windows-user remove the task. - The self-test's new nul check (before git) fails the AppContainer like git's, so no job fails on it; the window and the main screen say "Windows on this PC doesn't let sandboxed programs open NUL (some Windows builds); set up the Windows sandbox (one UAC prompt) to fix it". The self-test runs again after the fix, so the AppContainer is used at once. Assisted-by: Claude Code Co-Authored-By: Claude Opus 5.5 <[email protected]>Possibly related, for context:
WIP: fix(agent): the Windows setup gives AppContainers back the NUL device, as Windows 11 24H2 doesto fix(agent): the Windows setup gives AppContainers back the NUL device, as Windows 11 24H2 does