fix(windows): cast AceFlags and AccessMask to int in NUL PowerShell 5.1 script #178

Merged
HumanBean merged 2 commits from cfw34683/Beanstalk:fix/windows-nul-aceflags-cast into main 2026-12-05 17:03:38 +00:00
Contributor

Summary

Fixes System.InvalidCastException: Specified cast is not valid. in WinNul.GrantScript on Windows PowerShell 5.1 when setting up \Beanstalk\NUL access for AppContainers.

Cause

In Windows PowerShell 5.1, $ace.AceFlags is a byte-backed enum (System.Security.AccessControl.AceFlags). Running -band [Security.AccessControl.AceFlags]::InheritOnly throws InvalidCastException inside the PowerShell DLR CallSite (Object, AceFlags).

Fix

  • Cast $ace.AceFlags, [Security.AccessControl.AceFlags]::InheritOnly, and $ace.AccessMask to [int] before -band in agent/Core/WindowsNul.cs.
  • Added an assertion in agent/tests/agent_core/NulChecks.cs.

Verification

  • Reproduced the original InvalidCastException in Windows PowerShell 5.1 against RawSecurityDescriptor and verified the [int]-cast version succeeds (BINARY_LEN: 72).
  • Built AgentCoreTests.csproj cleanly (0 Warning(s), 0 Error(s)).
### Summary Fixes `System.InvalidCastException: Specified cast is not valid.` in `WinNul.GrantScript` on Windows PowerShell 5.1 when setting up `\Beanstalk\NUL access for AppContainers`. ### Cause In Windows PowerShell 5.1, `$ace.AceFlags` is a `byte`-backed enum (`System.Security.AccessControl.AceFlags`). Running `-band [Security.AccessControl.AceFlags]::InheritOnly` throws `InvalidCastException` inside the PowerShell DLR `CallSite` `(Object, AceFlags)`. ### Fix - Cast `$ace.AceFlags`, `[Security.AccessControl.AceFlags]::InheritOnly`, and `$ace.AccessMask` to `[int]` before `-band` in `agent/Core/WindowsNul.cs`. - Added an assertion in `agent/tests/agent_core/NulChecks.cs`. ### Verification - Reproduced the original `InvalidCastException` in Windows PowerShell 5.1 against `RawSecurityDescriptor` and verified the `[int]`-cast version succeeds (`BINARY_LEN: 72`). - Built `AgentCoreTests.csproj` cleanly (`0 Warning(s), 0 Error(s)`).
fix(windows): cast AceFlags and AccessMask to int in NUL PowerShell 5.1 script
Some checks failed
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Coordinator tests (pull_request) Has been cancelled
CI / Agent build and checks (pull_request) Has been cancelled
CI / Coordinator image (pull_request) Has been cancelled
9a1118bbe9
Member

Possibly related, for context:

  • PR #131 fix(agent): the Windows setup gives AppContainers back the NUL device, as Windows 11 24H2 does — Original NUL AppContainer grant implementation in the same file
  • issue #35 Windows AppContainer: Python private temporary directories exclude the package SID — Separate open AppContainer ACL failure involving private temp directories
Possibly related, for context: - PR #131 fix(agent): the Windows setup gives AppContainers back the NUL device, as Windows 11 24H2 does — Original NUL AppContainer grant implementation in the same file - issue #35 Windows AppContainer: Python private temporary directories exclude the package SID — Separate open AppContainer ACL failure involving private temp directories
Author
Contributor

Full beanstalk-agent sandbox-check report from Windows 10.0.19045 (nightly-299-b3e6a7d9):

===== beanstalk-agent sandbox-check =====
agent: beanstalk-agent nightly-299-b3e6a7d9, Microsoft Windows 10.0.19045 (Windows 10.0.19045)
date: 2026-12-02 20:45 -05:00
GPU outside the sandbox: NVIDIA GeForce RTX 3070 Ti (driver 621.40.0, NVIDIA, Vulkan 1.4.357); vkCreateInstance ok, vkCreateDevice ok: vkCreateDevice: a device with a graphics queue (family 0)
RAM 64 GB, 32 threads; Job Object memory bound 55 GB
git for the sandbox: the agent's MinGit 2.56.0.windows.4 (<data>\mingit\cmd)

--- mode appcontainer ---
  ui restrictions: strict, control pipe: local
  PASS  identity         sandbox SID S-1-15-2-1742277973-4139094180-3567757085-453046723-1877578957-2241699582-1176616513
  PASS  start            the probe started
  PASS  stdout           read through the pipe
  PASS  stderr           read through the pipe
  PASS  exit_code        7, as the probe meant
  PASS  identity_inside  user S-1-5-21-<machine>-1001, AppContainer S-1-15-2-1742277973-4139094180-3567757085-453046723-1877578957-2241699582-1176616513
  PASS  net_tcp          refused: AccessDenied (10013): An attempt was made to access a socket in a way forbidden by its access permissions.
  PASS  net_dns          no answer for git.magicbean.dev within 10 s
  PASS  net_udp          no answer from 1.1.1.1:53: TimedOut (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
  PASS  read_secret      the test file in Documents is not readable: UnauthorizedAccessException: Access to the path '<home>\Documents\beanstalk-sandbox-check-01eb1381.txt' is denied.
  PASS  read_granted     the granted folder is readable
  PASS  write_granted    the read-only granted folder is not writable: UnauthorizedAccessException: Access to the path 'W:\sandbox-check\appcontainer\granted\beanstalk-probe-4252.txt' is denied.
  PASS  write_profile    your user folder is not writable: UnauthorizedAccessException: Access to the path '<home>\beanstalk-probe-4252.txt' is denied.
  PASS  write_temp       your temp folder is not writable: UnauthorizedAccessException: Access to the path '<home>\AppData\Local\Temp\beanstalk-probe-4252.txt' is denied.
  PASS  write_public     C:\Users\Public is not writable: UnauthorizedAccessException: Access to the path 'C:\Users\Public\beanstalk-probe-4252.txt' is denied.
  PASS  write_work       the work folder is writable
  FAIL  list_profile     LISTED your user folder (3 entries seen)
  FAIL  nul              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 (UnauthorizedAccessException: Access to the path '\\.\NUL' is denied.)
  FAIL  git              git --version: exit 128: fatal: could not open '/dev/null' for reading and writing: Permission denied (git for the sandbox: the agent's MinGit 2.56.0.windows.4)
  PASS  env              40 variables: APPDATA,BEANSTALK_SANDBOX_PYTHON,BEANSTALK_WORK_DRIVE,CommonProgramFiles,CommonProgramFiles(x86),CommonProgramW6432,COMPUTERNAME,ComSpec,DOTNET_BUNDLE_EXTRACT_BASE_DIR,DOTNET_CLI_TELEMETRY_OPTOUT,DOTNET_EnableDiagnostics,DriverData,GIT_CONFIG_COUNT,GIT_CONFIG_KEY_0,GIT_CONFIG_VALUE_0,HOME,HOS_HEADLESS,HOS_NO_SDL,LOCALAPPDATA,NUMBER_OF_PROCESSORS,OS,PATH,PATHEXT,PROCESSOR_ARCHITECTURE,PROCESSOR_IDENTIFIER,PROCESSOR_LEVEL,PROCESSOR_REVISION,ProgramFiles,ProgramFiles(x86),ProgramW6432,PYTHONDONTWRITEBYTECODE,PYTHONIOENCODING,PYTHONUTF8,SystemDrive,SystemRoot,TEMP,TMP,USERNAME,USERPROFILE,windir
  PASS  job_kill         the probe and its child (2 processes) ended with the job
  PASS  vulkan_instance  ok vkCreateInstance VK_SUCCESS
  PASS  vulkan_device    ok NVIDIA GeForce RTX 3070 Ti | driver 621.40.0 (NVIDIA 621.40) | Vulkan 1.4.357 | vkCreateDevice: a device with a graphics queue (family 0)
  PASS  pipe_today_local two connections to …877578957-2241699582-1176616513\beanstalk-check-0c8e8a842626 worked
  FAIL  pipe_today_plain the game's side could not make the pipe: CreateNamedPipeW (\\.\pipe\beanstalk-check-ee2761eb933f): error 5 (0x5, Access is denied)
  PASS  pipe_proposed_local two connections to …877578957-2241699582-1176616513\beanstalk-check-8f9f428b362a worked
  FAIL  pipe_proposed_plain the game's side could not make the pipe: CreateNamedPipeW (\\.\pipe\beanstalk-check-f80e04f75e83): error 5 (0x5, Access is denied)
  PASS  pipe             works with Longshot as it is (today's DACL, the local name)
  => failed or missing: list_profile, nul, git

--- mode lowuser ---
  ui restrictions: strict, control pipe: plain
  PASS  identity         sandbox SID S-1-5-21-<machine>-1002
  PASS  start            the probe started
  PASS  stdout           read through the pipe
  PASS  stderr           read through the pipe
  PASS  exit_code        7, as the probe meant
  PASS  identity_inside  user S-1-5-21-<machine>-1002, AppContainer none
  PASS  net_tcp          refused: AccessDenied (10013): An attempt was made to access a socket in a way forbidden by its access permissions.
  WARN  net_dns          git.magicbean.dev RESOLVED to 172.67.170.160, 104.21.55.71 (expected for the runner account: lookups go through Windows' DNS service)
  PASS  net_udp          no answer from 1.1.1.1:53: TimedOut (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
  PASS  read_secret      the test file in Documents is not readable: UnauthorizedAccessException: Access to the path '<home>\Documents\beanstalk-sandbox-check-70f3e388.txt' is denied.
  PASS  read_granted     the granted folder is readable
  PASS  write_granted    the read-only granted folder is not writable: UnauthorizedAccessException: Access to the path '<data>\sandbox-check\lowuser\granted\beanstalk-probe-9520.txt' is denied.
  PASS  write_profile    your user folder is not writable: UnauthorizedAccessException: Access to the path '<home>\beanstalk-probe-9520.txt' is denied.
  PASS  write_temp       your temp folder is not writable: UnauthorizedAccessException: Access to the path '<home>\AppData\Local\Temp\beanstalk-probe-9520.txt' is denied.
  WARN  write_public     WROTE a file in C:\Users\Public
  PASS  write_work       the work folder is writable
  FAIL  list_profile     LISTED your user folder (3 entries seen)
  PASS  nul              NUL opens for reading and writing
  PASS  git              git version 2.56.0.windows.4 (git for the sandbox: the agent's MinGit 2.56.0.windows.4)
  PASS  env              40 variables: APPDATA,BEANSTALK_SANDBOX_PYTHON,BEANSTALK_WORK_DRIVE,CommonProgramFiles,CommonProgramFiles(x86),CommonProgramW6432,COMPUTERNAME,ComSpec,DOTNET_BUNDLE_EXTRACT_BASE_DIR,DOTNET_CLI_TELEMETRY_OPTOUT,DOTNET_EnableDiagnostics,DriverData,GIT_CONFIG_COUNT,GIT_CONFIG_KEY_0,GIT_CONFIG_VALUE_0,HOME,HOS_HEADLESS,HOS_NO_SDL,LOCALAPPDATA,NUMBER_OF_PROCESSORS,OS,PATH,PATHEXT,PROCESSOR_ARCHITECTURE,PROCESSOR_IDENTIFIER,PROCESSOR_LEVEL,PROCESSOR_REVISION,ProgramFiles,ProgramFiles(x86),ProgramW6432,PYTHONDONTWRITEBYTECODE,PYTHONIOENCODING,PYTHONUTF8,SystemDrive,SystemRoot,TEMP,TMP,USERNAME,USERPROFILE,windir
  PASS  job_kill         the probe and its child (2 processes) ended with the job
  PASS  vulkan_instance  ok vkCreateInstance VK_SUCCESS
  PASS  vulkan_device    ok NVIDIA GeForce RTX 3070 Ti | driver 621.40.0 (NVIDIA 621.40) | Vulkan 1.4.357 | vkCreateDevice: a device with a graphics queue (family 0)
  FAIL  pipe_today_plain the agent could not connect to \\.\pipe\beanstalk-check-8a41580cfd4f: access denied (the pipe's DACL does not let the agent's user in)
  PASS  pipe_proposed_plain two connections to \\.\pipe\beanstalk-check-84c3a59ab359 worked
  FAIL  pipe             works only with Longshot's proposed pipe change (proposed's DACL, the plain name: HOS_CONTROL_PEER_SID and the AppContainer ACE in host/control.c), which the agent's Longshot checkout does not have yet
  => failed or missing: list_profile, pipe

recommended mode: none (appcontainer: failed or missing: list_profile, nul, git; lowuser: failed or missing: list_profile, pipe)
===== end of sandbox-check =====
Full `beanstalk-agent sandbox-check` report from Windows 10.0.19045 (`nightly-299-b3e6a7d9`): ``` ===== beanstalk-agent sandbox-check ===== agent: beanstalk-agent nightly-299-b3e6a7d9, Microsoft Windows 10.0.19045 (Windows 10.0.19045) date: 2026-12-02 20:45 -05:00 GPU outside the sandbox: NVIDIA GeForce RTX 3070 Ti (driver 621.40.0, NVIDIA, Vulkan 1.4.357); vkCreateInstance ok, vkCreateDevice ok: vkCreateDevice: a device with a graphics queue (family 0) RAM 64 GB, 32 threads; Job Object memory bound 55 GB git for the sandbox: the agent's MinGit 2.56.0.windows.4 (<data>\mingit\cmd) --- mode appcontainer --- ui restrictions: strict, control pipe: local PASS identity sandbox SID S-1-15-2-1742277973-4139094180-3567757085-453046723-1877578957-2241699582-1176616513 PASS start the probe started PASS stdout read through the pipe PASS stderr read through the pipe PASS exit_code 7, as the probe meant PASS identity_inside user S-1-5-21-<machine>-1001, AppContainer S-1-15-2-1742277973-4139094180-3567757085-453046723-1877578957-2241699582-1176616513 PASS net_tcp refused: AccessDenied (10013): An attempt was made to access a socket in a way forbidden by its access permissions. PASS net_dns no answer for git.magicbean.dev within 10 s PASS net_udp no answer from 1.1.1.1:53: TimedOut (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. PASS read_secret the test file in Documents is not readable: UnauthorizedAccessException: Access to the path '<home>\Documents\beanstalk-sandbox-check-01eb1381.txt' is denied. PASS read_granted the granted folder is readable PASS write_granted the read-only granted folder is not writable: UnauthorizedAccessException: Access to the path 'W:\sandbox-check\appcontainer\granted\beanstalk-probe-4252.txt' is denied. PASS write_profile your user folder is not writable: UnauthorizedAccessException: Access to the path '<home>\beanstalk-probe-4252.txt' is denied. PASS write_temp your temp folder is not writable: UnauthorizedAccessException: Access to the path '<home>\AppData\Local\Temp\beanstalk-probe-4252.txt' is denied. PASS write_public C:\Users\Public is not writable: UnauthorizedAccessException: Access to the path 'C:\Users\Public\beanstalk-probe-4252.txt' is denied. PASS write_work the work folder is writable FAIL list_profile LISTED your user folder (3 entries seen) FAIL nul 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 (UnauthorizedAccessException: Access to the path '\\.\NUL' is denied.) FAIL git git --version: exit 128: fatal: could not open '/dev/null' for reading and writing: Permission denied (git for the sandbox: the agent's MinGit 2.56.0.windows.4) PASS env 40 variables: APPDATA,BEANSTALK_SANDBOX_PYTHON,BEANSTALK_WORK_DRIVE,CommonProgramFiles,CommonProgramFiles(x86),CommonProgramW6432,COMPUTERNAME,ComSpec,DOTNET_BUNDLE_EXTRACT_BASE_DIR,DOTNET_CLI_TELEMETRY_OPTOUT,DOTNET_EnableDiagnostics,DriverData,GIT_CONFIG_COUNT,GIT_CONFIG_KEY_0,GIT_CONFIG_VALUE_0,HOME,HOS_HEADLESS,HOS_NO_SDL,LOCALAPPDATA,NUMBER_OF_PROCESSORS,OS,PATH,PATHEXT,PROCESSOR_ARCHITECTURE,PROCESSOR_IDENTIFIER,PROCESSOR_LEVEL,PROCESSOR_REVISION,ProgramFiles,ProgramFiles(x86),ProgramW6432,PYTHONDONTWRITEBYTECODE,PYTHONIOENCODING,PYTHONUTF8,SystemDrive,SystemRoot,TEMP,TMP,USERNAME,USERPROFILE,windir PASS job_kill the probe and its child (2 processes) ended with the job PASS vulkan_instance ok vkCreateInstance VK_SUCCESS PASS vulkan_device ok NVIDIA GeForce RTX 3070 Ti | driver 621.40.0 (NVIDIA 621.40) | Vulkan 1.4.357 | vkCreateDevice: a device with a graphics queue (family 0) PASS pipe_today_local two connections to …877578957-2241699582-1176616513\beanstalk-check-0c8e8a842626 worked FAIL pipe_today_plain the game's side could not make the pipe: CreateNamedPipeW (\\.\pipe\beanstalk-check-ee2761eb933f): error 5 (0x5, Access is denied) PASS pipe_proposed_local two connections to …877578957-2241699582-1176616513\beanstalk-check-8f9f428b362a worked FAIL pipe_proposed_plain the game's side could not make the pipe: CreateNamedPipeW (\\.\pipe\beanstalk-check-f80e04f75e83): error 5 (0x5, Access is denied) PASS pipe works with Longshot as it is (today's DACL, the local name) => failed or missing: list_profile, nul, git --- mode lowuser --- ui restrictions: strict, control pipe: plain PASS identity sandbox SID S-1-5-21-<machine>-1002 PASS start the probe started PASS stdout read through the pipe PASS stderr read through the pipe PASS exit_code 7, as the probe meant PASS identity_inside user S-1-5-21-<machine>-1002, AppContainer none PASS net_tcp refused: AccessDenied (10013): An attempt was made to access a socket in a way forbidden by its access permissions. WARN net_dns git.magicbean.dev RESOLVED to 172.67.170.160, 104.21.55.71 (expected for the runner account: lookups go through Windows' DNS service) PASS net_udp no answer from 1.1.1.1:53: TimedOut (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. PASS read_secret the test file in Documents is not readable: UnauthorizedAccessException: Access to the path '<home>\Documents\beanstalk-sandbox-check-70f3e388.txt' is denied. PASS read_granted the granted folder is readable PASS write_granted the read-only granted folder is not writable: UnauthorizedAccessException: Access to the path '<data>\sandbox-check\lowuser\granted\beanstalk-probe-9520.txt' is denied. PASS write_profile your user folder is not writable: UnauthorizedAccessException: Access to the path '<home>\beanstalk-probe-9520.txt' is denied. PASS write_temp your temp folder is not writable: UnauthorizedAccessException: Access to the path '<home>\AppData\Local\Temp\beanstalk-probe-9520.txt' is denied. WARN write_public WROTE a file in C:\Users\Public PASS write_work the work folder is writable FAIL list_profile LISTED your user folder (3 entries seen) PASS nul NUL opens for reading and writing PASS git git version 2.56.0.windows.4 (git for the sandbox: the agent's MinGit 2.56.0.windows.4) PASS env 40 variables: APPDATA,BEANSTALK_SANDBOX_PYTHON,BEANSTALK_WORK_DRIVE,CommonProgramFiles,CommonProgramFiles(x86),CommonProgramW6432,COMPUTERNAME,ComSpec,DOTNET_BUNDLE_EXTRACT_BASE_DIR,DOTNET_CLI_TELEMETRY_OPTOUT,DOTNET_EnableDiagnostics,DriverData,GIT_CONFIG_COUNT,GIT_CONFIG_KEY_0,GIT_CONFIG_VALUE_0,HOME,HOS_HEADLESS,HOS_NO_SDL,LOCALAPPDATA,NUMBER_OF_PROCESSORS,OS,PATH,PATHEXT,PROCESSOR_ARCHITECTURE,PROCESSOR_IDENTIFIER,PROCESSOR_LEVEL,PROCESSOR_REVISION,ProgramFiles,ProgramFiles(x86),ProgramW6432,PYTHONDONTWRITEBYTECODE,PYTHONIOENCODING,PYTHONUTF8,SystemDrive,SystemRoot,TEMP,TMP,USERNAME,USERPROFILE,windir PASS job_kill the probe and its child (2 processes) ended with the job PASS vulkan_instance ok vkCreateInstance VK_SUCCESS PASS vulkan_device ok NVIDIA GeForce RTX 3070 Ti | driver 621.40.0 (NVIDIA 621.40) | Vulkan 1.4.357 | vkCreateDevice: a device with a graphics queue (family 0) FAIL pipe_today_plain the agent could not connect to \\.\pipe\beanstalk-check-8a41580cfd4f: access denied (the pipe's DACL does not let the agent's user in) PASS pipe_proposed_plain two connections to \\.\pipe\beanstalk-check-84c3a59ab359 worked FAIL pipe works only with Longshot's proposed pipe change (proposed's DACL, the plain name: HOS_CONTROL_PEER_SID and the AppContainer ACE in host/control.c), which the agent's Longshot checkout does not have yet => failed or missing: list_profile, pipe recommended mode: none (appcontainer: failed or missing: list_profile, nul, git; lowuser: failed or missing: list_profile, pipe) ===== end of sandbox-check ===== ```
Owner

Has this been fully ran?

@review

Has this been fully ran? @review
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The casts address the reported PowerShell 5.1 exception, but the full elevated setup and subsequent sandbox access have not been shown working on the affected Windows machine. Recommend approval; not approved on the forge.

The change casts the ACE values before the bitwise checks so Windows PowerShell 5.1 can inspect NUL’s access entries. It is small and keeps the existing setup design, but its automated check does not exercise the fix.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L1 agent/Core/WindowsNul.cs:154: The reported reproduction covers the expression, but not the complete setup on a machine where AppContainers cannot open NUL. (more on the line) Do: On the affected Windows 10 machine, run this head’s setup, repeat sandbox-check including NUL and Git, reboot, and repeat the check to verify the scheduled task.

Questions (1) (not confirmed from the code; they don't hold the recommendation)

  • agent/tests/agent_core/NulChecks.cs:48: Is there a current ACL input for which the changed PowerShell decision produces an incorrect result?

Checks: Still running: 5 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven end to end. The author reports that a PowerShell 5.1 reproduction succeeds with the casts and produces a 72-byte descriptor; the posted sandbox report is from the base build and still shows NUL and Git failing.

Other systems: The changed script runs on Windows both during elevated setup and from the SYSTEM boot task. Linux does not run it. The reported reproduction does not show the complete setup, a sandboxed NUL open, or the boot task working.

Switches: None.

Reviewed: 9a1118bbe9 against b3e6a7d97a: Read AGENTS.md, CONTRIBUTING.md, the full diff and commit, and both changed files in full. Traced references to the setup, boot task and test entry point; skimmed the reported sandbox run and CI test references. No review checklist or pull request template was present. Other repository files were not read in full.; nothing run (a code review).

Checked and fine:

  • The change stays within the stated PowerShell fix and adds no switches or game-derived files.
  • The existing task embeds the updated grant script, and the setup invokes the same script immediately.

Testing: No commands from the project were run, as required for this review. The author reports a clean test-project build and an isolated PowerShell reproduction; CI was still running.

Overlaps and merge order: Unknown; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The casts address the reported PowerShell 5.1 exception, but the full elevated setup and subsequent sandbox access have not been shown working on the affected Windows machine. Recommend approval; not approved on the forge. The change casts the ACE values before the bitwise checks so Windows PowerShell 5.1 can inspect NUL’s access entries. It is small and keeps the existing setup design, but its automated check does not exercise the fix. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L1** `agent/Core/WindowsNul.cs:154`: The reported reproduction covers the expression, but not the complete setup on a machine where AppContainers cannot open NUL. (more on the line) **Do:** On the affected Windows 10 machine, run this head’s setup, repeat sandbox-check including NUL and Git, reboot, and repeat the check to verify the scheduled task. **Questions (1)** (not confirmed from the code; they don't hold the recommendation) - `agent/tests/agent_core/NulChecks.cs:48`: Is there a current ACL input for which the changed PowerShell decision produces an incorrect result? **Checks:** Still running: 5 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven end to end. The author reports that a PowerShell 5.1 reproduction succeeds with the casts and produces a 72-byte descriptor; the posted sandbox report is from the base build and still shows NUL and Git failing. **Other systems:** The changed script runs on Windows both during elevated setup and from the SYSTEM boot task. Linux does not run it. The reported reproduction does not show the complete setup, a sandboxed NUL open, or the boot task working. **Switches:** None. **Reviewed:** 9a1118bbe928 against b3e6a7d97a17: Read AGENTS.md, CONTRIBUTING.md, the full diff and commit, and both changed files in full. Traced references to the setup, boot task and test entry point; skimmed the reported sandbox run and CI test references. No review checklist or pull request template was present. Other repository files were not read in full.; nothing run (a code review). **Checked and fine:** - The change stays within the stated PowerShell fix and adds no switches or game-derived files. - The existing task embeds the updated grant script, and the setup invokes the same script immediately. **Testing:** No commands from the project were run, as required for this review. The author reports a clean test-project build and an isolated PowerShell reproduction; CI was still running. **Overlaps and merge order:** Unknown; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -152,3 +152,3 @@
$has = $false
foreach ($ace in $acl) {
if ($ace -is [Security.AccessControl.CommonAce] -and $ace.AceQualifier -eq 'AccessAllowed' -and -not ($ace.AceFlags -band [Security.AccessControl.AceFlags]::InheritOnly) -and $ace.SecurityIdentifier -eq $sid -and (($ace.AccessMask -band 0x1201bf) -eq 0x1201bf)) { $has = $true }
if ($ace -is [Security.AccessControl.CommonAce] -and $ace.AceQualifier -eq 'AccessAllowed' -and -not ([int]$ace.AceFlags -band [int][Security.AccessControl.AceFlags]::InheritOnly) -and $ace.SecurityIdentifier -eq $sid -and (([int]$ace.AccessMask -band 0x1201bf) -eq 0x1201bf)) { $has = $true }
Member

L1 (should fix): The reported reproduction covers the expression, but not the complete setup on a machine where AppContainers cannot open NUL.

When: The posted Windows 10 sandbox check is from the base build and reports both NUL and Git failing; it does not show that this head grants access now and again after reboot.

Do: On the affected Windows 10 machine, run this head’s setup, repeat sandbox-check including NUL and Git, reboot, and repeat the check to verify the scheduled task.

**L1** (should fix): The reported reproduction covers the expression, but not the complete setup on a machine where AppContainers cannot open NUL. *When:* The posted Windows 10 sandbox check is from the base build and reports both NUL and Git failing; it does not show that this head grants access now and again after reboot. **Do:** On the affected Windows 10 machine, run this head’s setup, repeat sandbox-check including NUL and Git, reboot, and repeat the check to verify the scheduled task.
Author
Contributor

Yes — verified on the affected Windows 10.0.19045 machine:

  1. Ran the patched GrantScript elevated via Windows PowerShell 5.1 (-EncodedCommand):
    NUL: read and write given to S-1-15-2-1, S-1-15-2-2
    
  2. Re-ran beanstalk-agent sandbox-check immediately afterwards — AppContainer went from failing nul and git (recommended mode: none) to every check passing:
    --- mode appcontainer ---
      PASS  nul              NUL opens for reading and writing
      PASS  git              git version 2.56.0.windows.4 (git for the sandbox: the agent's MinGit 2.56.0.windows.4)
      => every check passed
    recommended mode: appcontainer (appcontainer: every check passed)
    

(Note: the machine was rebooted to verify the scheduled boot task \Beanstalk\NUL access for AppContainers re-applying the DACL on startup; the task embeds the same GrantScript.)

Yes — verified on the affected Windows 10.0.19045 machine: 1. Ran the patched `GrantScript` elevated via Windows PowerShell 5.1 (`-EncodedCommand`): ``` NUL: read and write given to S-1-15-2-1, S-1-15-2-2 ``` 2. Re-ran `beanstalk-agent sandbox-check` immediately afterwards — AppContainer went from failing `nul` and `git` (`recommended mode: none`) to **every check passing**: ``` --- mode appcontainer --- PASS nul NUL opens for reading and writing PASS git git version 2.56.0.windows.4 (git for the sandbox: the agent's MinGit 2.56.0.windows.4) => every check passed recommended mode: appcontainer (appcontainer: every check passed) ``` (Note: the machine was rebooted to verify the scheduled boot task `\Beanstalk\NUL access for AppContainers` re-applying the DACL on startup; the task embeds the same `GrantScript`.)
Merge branch 'main' into fix/windows-nul-aceflags-cast
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Coordinator tests (pull_request) Blocked by required conditions
CI / Agent build and checks (pull_request) Blocked by required conditions
CI / Coordinator image (pull_request) Blocked by required conditions
749e8ecab7
Owner
@review
BeanBot left a comment

Recommendation: Approve. The cast fixes the PowerShell 5.1 failure, and the affected Windows 10 machine subsequently passed the NUL and Git sandbox checks. The author also reports that the boot task reapplied the permissions after a restart. Recommend approval; not approved on the forge.

The change lets Windows sandbox setup grant AppContainers access to NUL on affected systems, allowing sandboxed Git and builds to run. It adds a small script assertion without changing the intended permissions.

Since the last review (on 9a1118bbe9)
Resolved: L1 (The reported reproduction covers the expression, but not the complete setup on a machine w…)

Checks: Still running: 5 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes. On Windows 10 10.0.19045, the author reports that NUL and Git changed from failing to passing after the patched grant script ran; every AppContainer check then passed.

Other systems: The changed script runs only on Windows during elevated setup and at boot; Linux agent behavior is unchanged. The reported run covers the affected Windows 10 machine.

Switches: None.

Reviewed: 749e8ecab7 against adde94bc90: Read AGENTS.md, CONTRIBUTING.md, the full diff, commit log, WindowsNul.cs and NulChecks.cs in full; skimmed references to WinNul and the recorded Windows run. No review checklist or pull request template was found.; nothing run (a code review).

Checked and fine:

  • The same GrantScript is used by immediate setup and the scheduled boot task.
  • The casts preserve the existing access mask and SID checks.

Testing: The author reports a clean AgentCoreTests build, a PowerShell 5.1 reproduction and patched run, and a successful affected-machine sandbox check and reboot verification. CI checks are still running; no commands or tests were run for this review.

Overlaps and merge order: None found in the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The cast fixes the PowerShell 5.1 failure, and the affected Windows 10 machine subsequently passed the NUL and Git sandbox checks. The author also reports that the boot task reapplied the permissions after a restart. Recommend approval; not approved on the forge. The change lets Windows sandbox setup grant AppContainers access to NUL on affected systems, allowing sandboxed Git and builds to run. It adds a small script assertion without changing the intended permissions. **Since the last review** (on 9a1118bbe928) Resolved: L1 (The reported reproduction covers the expression, but not the complete setup on a machine w…) **Checks:** Still running: 5 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. On Windows 10 10.0.19045, the author reports that NUL and Git changed from failing to passing after the patched grant script ran; every AppContainer check then passed. **Other systems:** The changed script runs only on Windows during elevated setup and at boot; Linux agent behavior is unchanged. The reported run covers the affected Windows 10 machine. **Switches:** None. **Reviewed:** 749e8ecab71b against adde94bc90ad: Read AGENTS.md, CONTRIBUTING.md, the full diff, commit log, WindowsNul.cs and NulChecks.cs in full; skimmed references to WinNul and the recorded Windows run. No review checklist or pull request template was found.; nothing run (a code review). **Checked and fine:** - The same GrantScript is used by immediate setup and the scheduled boot task. - The casts preserve the existing access mask and SID checks. **Testing:** The author reports a clean AgentCoreTests build, a PowerShell 5.1 reproduction and patched run, and a successful affected-machine sandbox check and reboot verification. CI checks are still running; no commands or tests were run for this review. **Overlaps and merge order:** None found in the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Coordinator tests (pull_request) Blocked by required conditions
CI / Agent build and checks (pull_request) Blocked by required conditions
CI / Coordinator image (pull_request) Blocked by required conditions
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Beanstalk!178
No description provided.