fix(agent): let sandboxed Python stat writable parents #25

Merged
HumanBean merged 2 commits from futondestroyer/Beanstalk-contributions:codex/windows-base-path into main 2026-11-15 23:07:46 +00:00
Member

Windows farm builds fail before compiling because Python's os.makedirs(existing_directory, exist_ok=True) checks the parent first. An AppContainer can access the granted directory but cannot stat its parent, so Python recurses until mkdir on the drive root fails with WinError 5. This reproduced with a game-free Python probe as well as the farm reports for Longshot PR 910.

Change

Grant only FILE_READ_ATTRIBUTES (0x80), without inheritance, on each writable root's immediate parent. Do not grant metadata on a drive root, a broad system/profile path or a parent containing protected agent credentials. Read and modify grants retain their existing masks; metadata grants do not subsume nested grants because they do not inherit.

Security review required: two maintainers

This deliberately adds a small amount of directory metadata visibility to the sandbox. The written reason is Python's parent existence check, not access to any parent contents. It grants no listing, file data, execution, sibling writes, permission changes or inherited access. Parents farther up the tree remain inaccessible. The new negative integration checks verify these boundaries. Please obtain the two maintainer reviews required by CONTRIBUTING.md before merging/deploying; this patch has not been installed into the volunteer worker.

Validation

  • Windows core suite: 1,536 checks passed.
  • Locked Release solution build: zero warnings and zero errors.
  • Real Windows AppContainer, managed Python 3.14.7: before the fix, an existing writable directory reproduces WinError 5 on the drive root. After the fix, existing and nested makedirs calls and a write inside the granted root pass.
  • The checked-in game-free AppContainer regression denies parent listing, sibling reads, sibling writes, sibling stat (no inheritance), and grandparent stat.
  • git diff --check passes. Only source, documentation and made-up test fixtures are included.

The worker remains on the official signed nightly. No claim is made that a full Longshot base build or gameplay report has passed with this patch; the next acceptance step after reviewed rollout is a normal approved Windows farm job.

Reproduction details and the regression command: docs/windows-makedirs.md.

Windows farm builds fail before compiling because Python's os.makedirs(existing_directory, exist_ok=True) checks the parent first. An AppContainer can access the granted directory but cannot stat its parent, so Python recurses until mkdir on the drive root fails with WinError 5. This reproduced with a game-free Python probe as well as the farm reports for Longshot PR 910. ## Change Grant only FILE_READ_ATTRIBUTES (0x80), without inheritance, on each writable root's immediate parent. Do not grant metadata on a drive root, a broad system/profile path or a parent containing protected agent credentials. Read and modify grants retain their existing masks; metadata grants do not subsume nested grants because they do not inherit. ## Security review required: two maintainers This deliberately adds a small amount of directory metadata visibility to the sandbox. The written reason is Python's parent existence check, not access to any parent contents. It grants no listing, file data, execution, sibling writes, permission changes or inherited access. Parents farther up the tree remain inaccessible. The new negative integration checks verify these boundaries. Please obtain the two maintainer reviews required by CONTRIBUTING.md before merging/deploying; this patch has not been installed into the volunteer worker. ## Validation - Windows core suite: 1,536 checks passed. - Locked Release solution build: zero warnings and zero errors. - Real Windows AppContainer, managed Python 3.14.7: before the fix, an existing writable directory reproduces WinError 5 on the drive root. After the fix, existing and nested makedirs calls and a write inside the granted root pass. - The checked-in game-free AppContainer regression denies parent listing, sibling reads, sibling writes, sibling stat (no inheritance), and grandparent stat. - git diff --check passes. Only source, documentation and made-up test fixtures are included. The worker remains on the official signed nightly. No claim is made that a full Longshot base build or gameplay report has passed with this patch; the next acceptance step after reviewed rollout is a normal approved Windows farm job. Reproduction details and the regression command: docs/windows-makedirs.md.
fix(agent): let sandboxed Python stat writable parents
Some checks failed
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 3s
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
ab896f5e99
Grant only non-inherited FILE_READ_ATTRIBUTES on safe immediate parents of writable roots, so Python makedirs does not recurse into inaccessible drive roots. Keep listing, sibling data and writes denied. Requires two maintainer reviews for the sandbox permission change.

Assisted-by: OpenAI Codex

Co-Authored-By: Codex <[email protected]>
Author
Member

Included the regression project lockfile generated by the shared agent build settings. Its locked AppContainer run passes, including all five denied-access assertions; the permission scope and two-maintainer review requirement are unchanged.

Included the regression project lockfile generated by the shared agent build settings. Its locked AppContainer run passes, including all five denied-access assertions; the permission scope and two-maintainer review requirement are unchanged.
test(agent): lock the Windows filesystem regression project
Some checks are pending
CI / Coordinator tests (pull_request) Waiting to run
CI / Agent build and checks (pull_request) Waiting to run
CI / Coordinator image (pull_request) Waiting to run
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 4s
1492d5d515
Assisted-by: OpenAI Codex

Co-Authored-By: Codex <[email protected]>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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!25
No description provided.