fix(windows): skip TooWide folders in WinDrive.Above to preserve list_profile #179
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Beanstalk!179
Loading…
Reference in a new issue
No description provided.
Delete branch "cfw34683/Beanstalk:fix/windows-above-skip-toowide"
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?
Summary
Prevents
WindowsSandboxfrom grantingWinAccess.List(FILE_LIST_DIRECTORY) onUSERPROFILE/LOCALAPPDATA/Userswhenhome.Datais in the default%LOCALAPPDATA%\Beanstalk\datalocation.Cause
WindowsSandbox.csiteratesWinDrive.Above(home.Data)and appliesWinAccess.List(0x00100081, which includesFILE_LIST_DIRECTORY), granting the AppContainer SID andbeanstalk-runner(S,RD,RA)on%USERPROFILE%.WindowsSelfTest.cs(list_profile) then immediately fails because the sandbox can list%USERPROFILE%.Fix
WinDrive.SafeAbove(path, tooWide)inagent/Core/WindowsPlan.csto filter outWinHost.TooWide()paths.WindowsSandbox.cstoWinDrive.SafeAbove(home.Data, WinHost.TooWide()).agent/tests/agent_core/WindowsChecks.cs.Verification
dotnet build agent\tests\agent_core\AgentCoreTests.csproj --configuration Releasesucceeded (0 Warning(s), 0 Error(s)).Possibly related, for context:
Has this been ran fully?
@review
Recommendation: Request changes. The change leaves previously granted profile permissions in place, so affected Windows installations can continue to fail the sandbox self-test. The Windows behavior has not been verified in a run.
The filter prevents new listing grants on paths classified as too wide, protecting profile listings on fresh setups. Existing ACLs persist, however, and removing ancestor listings could affect Windows tool startup.
Blocking (2): must change before merging.
agent/Core/WindowsSandbox.cs:120: Skipping broad folders does not remove listing ACEs already granted by earlier versions. (more on the line) Do: Revoke the old broad-folder grants for the affected sandbox SIDs during migration, handling failures safely, and test an upgrade from an existing grant.@fixor@rebasetry first). (for the author)Nits (1): optional.
docs/windows-clang.md:47: The Windows clang documentation still says preparation grants listings on the profile and Local folders. When: A maintainer diagnosing LLVM permissions is told those grants exist even though this change skips them on a fresh setup. Do: Update the ancestor-grant description to match the filter and any migration behavior.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
agent/Core/WindowsSandbox.cs:120: The changed Windows permissions have not been exercised in a sandbox or a build. (more on the line) Do: Run the Windows sandbox self-test and a real compile and link on a fresh default-path setup, then repeat the self-test after upgrading a setup with the old grants. Exercise both sandbox modes where available.@fixcan do L1 and L2.Questions (1) (not confirmed from the code; they don't hold the recommendation)
agent/tests/agent_core/WindowsChecks.cs:130: Is there a current case where sandbox preparation grants listing on the profile despite this test passing?Checks: Still running: 5 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven. The PR reports a successful test-project build, but no executed self-test or Windows build demonstrating the fix.
Other systems: The changed path is Windows-only and applies to both AppContainer and the runner-account fallback when a work drive is available. LLVM tools can resolve paths back through the omitted ancestors; the repository records a prior linker startup failure on that path. Linux sandbox behavior is unchanged.
Switches: None added, changed, or removed.
Reviewed:
f0cae3a4ebagainstb3e6a7d97a: Read the repository rules, commit and complete diff, the changed sandbox path, ACL handling, self-test, work-drive logic and the added test. Skimmed portions of the larger changed files and the surrounding documentation; no review checklist or pull request template was present.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during review. The PR reports a successful Release build of AgentCoreTests; CI checks were still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -118,3 +118,3 @@WinAcl.Apply(grants, Sid, Ledger, LowLabel, skipped);if (drive != null)foreach (var above in WinDrive.Above(home.Data))foreach (var above in WinDrive.SafeAbove(home.Data, WinHost.TooWide()))L1 (blocking): Skipping broad folders does not remove listing ACEs already granted by earlier versions.
When: After the previous code grants the sandbox SID listing access to the profile, updating to this version leaves that ACE in place. The self-test can still list the profile and rejects the sandbox, so the affected agent remains unable to take jobs.
Do: Revoke the old broad-folder grants for the affected sandbox SIDs during migration, handling failures safely, and test an upgrade from an existing grant.
L3 (should fix): The changed Windows permissions have not been exercised in a sandbox or a build.
When: With the default data path, profile and Local listings are withheld; the self-test must pass without them, and LLVM tools that resolve a real path must still start and link.
Do: Run the Windows sandbox self-test and a real compile and link on a fresh default-path setup, then repeat the self-test after upgrading a setup with the old grants. Exercise both sandbox modes where available.
f0cae3a4eb92230c2d8dRebased onto
main(adde94b, which already includesWinDrive.SafeAbovefrom #180) and addressed BeanBot's review items in92230c2:main— no conflicts.WinDrive.WideAbove(path, tooWide), aHasExplicitAce()short-circuit inWinAcl.SetforREVOKE_ACCESS(so already-clean/unowned folders are a fast no-op), and migration revocation inWindowsSandbox.Prepareto strip stale sandbox SID ACEs fromTooWideancestors (catchingWinErrorsafely on unowned folders likeC:\Users). Added unit tests forSafeAbove,WideAbove, and a Windows NTFS upgrade-revocation test inWindowsChecks.cs.docs/windows-clang.mdto documentSafeAboveand stale broad-folder grant revocation.Verified
dotnet build agent/Appanddotnet build agent/tests/agent_core -c Releasepass with 0 warnings, 0 errors.@review
Recommendation: Approve. The code is ready: only testing is left. The migration removes stale explicit grants for the sandbox SID when it can update the affected ACLs, but its effect on sandbox checks and a real Windows build has not been demonstrated. Recommend approval; not approved on the forge.
The change revokes old broad-ancestor permissions during Windows sandbox preparation and adds an idempotent ACL check. It preserves the existing safe-ancestor grants, at the cost of inspecting the affected ACLs during preparation.
Nits (1): optional.
docs/windows-clang.md:47: The safe-ancestor examples still include Local, although LOCALAPPDATA is excluded by WinHost.TooWide. When: A maintainer diagnosing LLVM permissions is told those grants exist even though this change skips them on a fresh setup. Do: Remove Local from the examples of folders granted listing and describe it as excluded.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
agent/Core/WindowsSandbox.cs:120: The changed Windows permissions have not been exercised in a sandbox or a build. When: With the default data path, profile and Local listings are withheld; the self-test must pass without them, and LLVM tools that resolve a real path must still start and link. Do: Run the Windows sandbox self-test and a real compile and link on a fresh default-path setup, then repeat the self-test after upgrading a setup with the old grants. Exercise both sandbox modes where available.@fixcan do L2.Since the last review (on
f0cae3a4eb)Resolved: L1 (Skipping broad folders does not remove listing ACEs already granted by earlier versions.); L4 (It conflicts with its base branch: bring it up to date (
@fixor@rebasetry first).)Still open: L2 (The safe-ancestor examples still include Local, although LOCALAPPDATA is excluded by WinHo…); L3 (The changed Windows permissions have not been exercised in a sandbox or a build.)
Checks: Still running: 5 checks.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven: the author reports successful builds, but no Windows sandbox self-test or game build exercising the permission change is reported.
Other systems: The shared preparation path affects both AppContainer and low-user Windows sandboxes, including resolved data paths. Linux is unaffected. A Windows run is still needed to check sandbox isolation and tool startup.
Switches: None.
Reviewed:
92230c2d8dagainstadde94bc90: Read the repository rules, the complete diff and commit, and the changed ACL, path-planning, sandbox and documentation sections; the large code and test files were only partially read. No pull request template or review checklist was found.; nothing run (a code review).Checked and fine:
Testing: The author reports successful agent and test-project builds. No tests were run during this review; CI is still running. Exercise both Windows sandbox modes, including an upgraded installation with stale grants, list_profile, tool startup and a build.
Overlaps and merge order: SafeAbove was merged in #180 before this change; the current base includes it.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.