Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions internal/sandbox/runner_windows_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,22 @@ func TestWindowsUnelevatedRealSandboxSmoke(t *testing.T) {

root := t.TempDir()
outside := t.TempDir()
privateDir := filepath.Join(root, "private")
if err := os.MkdirAll(privateDir, 0o700); err != nil {
t.Fatalf("MkdirAll private: %v", err)
}
secretFile := filepath.Join(privateDir, "secret.txt")
if err := os.WriteFile(secretFile, []byte("super-secret"), 0o600); err != nil {
t.Fatalf("WriteFile secret: %v", err)
}

sandboxHome := filepath.Join(root, ".zero-sandbox")
profile := PermissionProfile{
FileSystem: FileSystemPolicy{
Kind: FileSystemRestricted,
ReadRoots: []string{root},
WriteRoots: []WritableRoot{{Root: root, ProtectedMetadataNames: []string{".git", ".zero", ".agents"}}},
DenyRead: []string{privateDir},
IncludePlatformRoots: true,
AllowTemp: true,
},
Expand Down Expand Up @@ -179,6 +189,11 @@ func TestWindowsUnelevatedRealSandboxSmoke(t *testing.T) {
t.Fatalf("expected the unelevated setup marker to be recorded: %v", err)
}

// DenyRead check: reading from the privateDir must be blocked (exit code 1)
runWindowsRealSmokeCommand(t, runnerExe, config, []string{
"cmd.exe", "/d", "/s", "/c", "type " + secretFile,
}, 1)

outsideMarker := filepath.Join(outside, "unelevated-write-denied.txt")
runWindowsRealSmokeCommand(t, runnerExe, config, []string{
"cmd.exe", "/d", "/s", "/c", "echo leaked>" + outsideMarker,
Expand Down
2 changes: 1 addition & 1 deletion internal/sandbox/windows_token_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func createWindowsRestrictedTokenFromBase(base windows.Token, capabilitySIDs []w
var restricted windows.Token
result, _, callErr := procCreateRestrictedToken.Call(
uintptr(base),
uintptr(windowsDisableMaxPrivilege|windowsLUAToken|windowsWriteRestricted),
uintptr(windowsDisableMaxPrivilege|windowsLUAToken),
0,
0,
0,
Expand Down
Loading