#886

fix(sandbox): guard the Windows write-jail invariant and disclose the DenyRead trade

OpenVasanthdev2004wants to merge intofrom

Partial work on #869. It does not close it, and I would rather say that up front than have the checkbox suggest otherwise.

The regression risk

#865 removed the World SID from the WRITE_RESTRICTED token. That is the whole write jail: every principal carries Everyone, so while it was a restricting SID the write half of the access check passed for free on any Everyone-writable path, and confinement fell back to the user's own permissions.

That fix has no CI protection. The only test covering it, TestWindowsRestrictedTokenDeniesWritesToEveryoneWritablePaths, sits behind ZERO_SANDBOX_REAL_SMOKE=1, and rg ZERO_SANDBOX_REAL_SMOKE .github/ comes back empty. So anything that restored the unconditional World SID would go green. This is not hypothetical: #640's branch predates #865 and conflicts on that exact hunk.

CreateRestrictedToken works unelevated against the caller's own token, so there was never a reason this needed the real-runner harness. Four unit tests now read the token's restricted-SID list directly:

  • the WRITE_RESTRICTED token must not carry the World SID
  • neither shape may carry Users, Authenticated Users, INTERACTIVE, BATCH, Administrators, SYSTEM, SERVICE, NETWORK, or the user's own SID. #869 names these as the ones that would reopen the same class of bypass, and the runner's comment already states the rule
  • the capability SID must be present, so a token that passed by having no keys at all would still fail
  • the non-WRITE_RESTRICTED shape still carries the World SID

The last one documents the open gap instead of asserting the end state. It skips with a note if that stops being true, so whoever closes #869 gets told to replace it rather than finding a mystery failure.

Mutation-verified: flipping the guard back to unconditional produces

the World SID is a restricting SID on the write-restricted token, which collapses the write jail:
[S-1-5-21-... S-1-5-5-0-426223 S-1-1-0]

and the production file is byte-identical to main afterwards.

The invisible trade

Setting denyRead selects the token shape without WRITE_RESTRICTED, because the restricted-SID check has to cover reads for read-deny to mean anything, and that shape has to keep the World SID or the token cannot open cmd.exe. The trade is deliberate and well documented in the token source. It was just never surfaced: someone who set denyRead to protect credentials had no way to learn they had given up write confinement to get it.

The plan now carries a warning saying exactly that. Keyed off the same field the runner reads (PermissionProfile.FileSystem.DenyRead, not policy.DenyRead) so the two cannot drift, and scoped to the Windows restricted-token backend with native isolation actually active. Zero never populates denyRead on Windows itself, so the default posture stays silent and this only reaches users who configured it.

What is still open

Closing #869 needs a read-side grant that is not a universal group: AppContainer or LPAC with a capability SID, or the per-workspace principals from #808. That is a different piece of work and I have not attempted it here. #662 still must not land before it, since it would move every Windows user onto the unfixed shape.

I deliberately did not touch whether denyRead should be rejected outright on this tier. That is #640's call to make.

Verification

go build, go vet, gofmt -l clean. Full internal/sandbox suite green on real Windows, and internal/cli green too since it consumes the plan's warnings. Production diff is one file, +28/-1.

Summary by CodeRabbit

  • Bug Fixes

    • Added a Windows-specific warning when read access is denied using the native restricted-token sandbox, clarifying that write protection outside the workspace is no longer enforced.
    • Warnings are limited to the affected configuration and do not appear for default settings or other sandbox backends.
  • Tests

    • Added coverage validating warning behavior and Windows sandbox token access restrictions.

Activity

344
coderabbitai[bot]3mo ago

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 72a69e6e-9b74-41de-8e55-70ae6a2dcded

📥 Commits

Reviewing files that changed from the base of the PR and between f22df706c14db61b8fde34dca8e60ca012a97960 and cdac013ae9102fce41e3108688d750e80219a259.

📒 Files selected for processing (2)
  • internal/sandbox/manager.go
  • internal/sandbox/windows_deny_read_warning_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/sandbox/manager.go
  • internal/sandbox/windows_deny_read_warning_test.go

Walkthrough

BackendPlan now warns when native Windows restricted-token execution combines with configured DenyRead paths. Windows tests cover warning scope and restricted-token SID composition.

Changes

Windows sandbox behavior

Layer / File(s)Summary
Deny-read warning path
internal/sandbox/manager.go, internal/sandbox/windows_deny_read_warning_test.go
BackendPlan warns when native Windows restricted-token execution uses non-empty DenyRead paths. Tests cover warning content, empty settings, host platform, and backend scope.
Restricted-token SID invariants
internal/sandbox/windows_token_windows_test.go
Windows-only tests verify capability SID retention and exclusion of the World, broad group, and current-user SIDs from restricted SID lists. Tests also document existing non-write-restricted behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Gitlawb/zero issue 869 — The warning and tests directly address the Windows denyRead write-confinement gap.

Possibly related PRs

  • Gitlawb/zero#865 — Tests the Windows restricted-token SID behavior covered by this PR.

Suggested reviewers: gnanam1990, anandh8x

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the Windows write-jail regression protection and the DenyRead tradeoff warning added by the pull request.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-restricted-sid-invariant

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]3mo ago

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c66d346b-3fc4-4ddc-be98-aaf306e0cb6f

📥 Commits

Reviewing files that changed from the base of the PR and between 1b304e136a931a9276d265d6b36d53d3893cc5bb and e1269619204de77a29f7e830ecbc7a2648a57053.

📒 Files selected for processing (2)
  • internal/sandbox/windows_command_runner_windows.go
  • internal/sandbox/windows_unelevated_guidance_windows_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/sandbox/windows_command_runner_windows.go

Walkthrough

BackendPlan now warns when native Windows restricted-token execution uses configured DenyRead paths. Windows tests cover warning scope and token SID composition. ACL failure guidance now provides valid recovery instructions and preserves failed setup state.

Changes

Windows sandbox behavior

Layer / File(s)Summary
Deny-read warning path
internal/sandbox/manager.go, internal/sandbox/windows_deny_read_warning_test.go
BackendPlan warns when native Windows restricted-token execution uses non-empty DenyRead paths. Tests cover warning content, empty settings, host platform, and backend scope.
Restricted-token SID invariants
internal/sandbox/windows_token_windows_test.go
Windows-only tests verify capability SID retention and exclusion of the World, broad group, and current-user SIDs from restricted SID lists. Tests also document existing non-write-restricted behavior.
Windows setup recovery guidance
internal/sandbox/windows_command_runner_windows.go, internal/sandbox/windows_unelevated_guidance_windows_test.go
The ACL failure message now directs users to run elevated zero sandbox setup or disable sandboxing through user configuration. Tests verify error propagation and that failed setup does not record an applied-plan marker.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Gitlawb/zero#869 — The warning and tests directly address the Windows denyRead write-confinement gap.
  • Gitlawb/zero#662 — The changes cover the Windows DenyRead and WRITE_RESTRICTED interaction described by this issue.

Possibly related PRs

  • Gitlawb/zero#681 — Modifies sandbox DenyRead handling in the same code area.
  • Gitlawb/zero#812 — Covers related Windows restricted-token and SID behavior.
  • Gitlawb/zero#865 — Covers the same Windows DenyRead and WRITE_RESTRICTED interaction.

Suggested reviewers: gnanam1990, anandh8x, kevincodex1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the Windows write-jail protection and DenyRead tradeoff addressed by the pull request.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-restricted-sid-invariant

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]3mo ago

WARNING

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.
Your current included review allowance is based on your included PR review attempts over the past 7 days.

Next review available in: 21 minutes

Limit details: You’ve used all 3 included reviews currently available. Your 40 included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3e662961-c97e-4499-bd0a-ee309af0a285

📥 Commits

Reviewing files that changed from the base of the PR and between e1269619204de77a29f7e830ecbc7a2648a57053 and 434676b94b43feb74600721e367ff2bce1e21f95.

📒 Files selected for processing (1)
  • internal/sandbox/windows_token_windows_test.go

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c66d346b-3fc4-4ddc-be98-aaf306e0cb6f

📥 Commits

Reviewing files that changed from the base of the PR and between 1b304e136a931a9276d265d6b36d53d3893cc5bb and e1269619204de77a29f7e830ecbc7a2648a57053.

📒 Files selected for processing (2)
  • internal/sandbox/windows_command_runner_windows.go
  • internal/sandbox/windows_unelevated_guidance_windows_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/sandbox/windows_command_runner_windows.go

Walkthrough

BackendPlan now warns when native Windows restricted-token execution uses configured DenyRead paths. Windows tests cover warning scope and token SID composition. ACL failure guidance now provides valid recovery instructions and preserves failed setup state.

Changes

Windows sandbox behavior

Layer / File(s)Summary
Deny-read warning path
internal/sandbox/manager.go, internal/sandbox/windows_deny_read_warning_test.go
BackendPlan warns when native Windows restricted-token execution uses non-empty DenyRead paths. Tests cover warning content, empty settings, host platform, and backend scope.
Restricted-token SID invariants
internal/sandbox/windows_token_windows_test.go
Windows-only tests verify capability SID retention and exclusion of the World, broad group, and current-user SIDs from restricted SID lists. Tests also document existing non-write-restricted behavior.
Windows setup recovery guidance
internal/sandbox/windows_command_runner_windows.go, internal/sandbox/windows_unelevated_guidance_windows_test.go
The ACL failure message now directs users to run elevated zero sandbox setup or disable sandboxing through user configuration. Tests verify error propagation and that failed setup does not record an applied-plan marker.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Gitlawb/zero#869 — The warning and tests directly address the Windows denyRead write-confinement gap.
  • Gitlawb/zero#662 — The changes cover the Windows DenyRead and WRITE_RESTRICTED interaction described by this issue.

Possibly related PRs

  • Gitlawb/zero#681 — Modifies sandbox DenyRead handling in the same code area.
  • Gitlawb/zero#812 — Covers related Windows restricted-token and SID behavior.
  • Gitlawb/zero#865 — Covers the same Windows DenyRead and WRITE_RESTRICTED interaction.

Suggested reviewers: gnanam1990, anandh8x, kevincodex1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the Windows write-jail protection and DenyRead tradeoff addressed by the pull request.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-restricted-sid-invariant

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]3mo ago

WARNING

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.
Your current included review allowance is based on your included PR review attempts over the past 7 days.

Next review available in: 21 minutes

Limit details: You’ve used all 3 included reviews currently available. Your 40 included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3e662961-c97e-4499-bd0a-ee309af0a285

📥 Commits

Reviewing files that changed from the base of the PR and between e1269619204de77a29f7e830ecbc7a2648a57053 and 434676b94b43feb74600721e367ff2bce1e21f95.

📒 Files selected for processing (1)
  • internal/sandbox/windows_token_windows_test.go

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c66d346b-3fc4-4ddc-be98-aaf306e0cb6f

📥 Commits

Reviewing files that changed from the base of the PR and between 1b304e136a931a9276d265d6b36d53d3893cc5bb and e1269619204de77a29f7e830ecbc7a2648a57053.

📒 Files selected for processing (2)
  • internal/sandbox/windows_command_runner_windows.go
  • internal/sandbox/windows_unelevated_guidance_windows_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/sandbox/windows_command_runner_windows.go

Walkthrough

BackendPlan now warns when native Windows restricted-token execution uses configured DenyRead paths. Windows tests cover warning scope and token SID composition. ACL failure guidance now provides valid recovery instructions and preserves failed setup state.

Changes

Windows sandbox behavior

Layer / File(s)Summary
Deny-read warning path
internal/sandbox/manager.go, internal/sandbox/windows_deny_read_warning_test.go
BackendPlan warns when native Windows restricted-token execution uses non-empty DenyRead paths. Tests cover warning content, empty settings, host platform, and backend scope.
Restricted-token SID invariants
internal/sandbox/windows_token_windows_test.go
Windows-only tests verify capability SID retention and exclusion of the World, broad group, and current-user SIDs from restricted SID lists. Tests also document existing non-write-restricted behavior.
Windows setup recovery guidance
internal/sandbox/windows_command_runner_windows.go, internal/sandbox/windows_unelevated_guidance_windows_test.go
The ACL failure message now directs users to run elevated zero sandbox setup or disable sandboxing through user configuration. Tests verify error propagation and that failed setup does not record an applied-plan marker.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Gitlawb/zero#869 — The warning and tests directly address the Windows denyRead write-confinement gap.
  • Gitlawb/zero#662 — The changes cover the Windows DenyRead and WRITE_RESTRICTED interaction described by this issue.

Possibly related PRs

  • Gitlawb/zero#681 — Modifies sandbox DenyRead handling in the same code area.
  • Gitlawb/zero#812 — Covers related Windows restricted-token and SID behavior.
  • Gitlawb/zero#865 — Covers the same Windows DenyRead and WRITE_RESTRICTED interaction.

Suggested reviewers: gnanam1990, anandh8x, kevincodex1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the Windows write-jail protection and DenyRead tradeoff addressed by the pull request.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-restricted-sid-invariant

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]3mo ago

Walkthrough

Native Windows restricted-token plans now warn when DenyRead disables write confinement. Notices propagate through enforcement metadata, tool results, model output, and human display. Windows tests cover token SIDs, warning scope, notice visibility, and ACL setup failures.

Changes

Windows sandbox behavior

Layer / File(s)Summary
Sandbox enforcement contract and planning
internal/execution/contracts.go, internal/sandbox/runner.go, internal/sandbox/manager.go
Enforcement conversion is centralized in EnforcementFor. Applicable plans now carry enforcement notices and identify actual Windows restricted-token execution.
Deny-read warning and metadata propagation
internal/sandbox/manager.go, internal/sandbox/runner.go, internal/sandbox/windows_deny_read_warning_test.go, internal/tools/bash.go, internal/tools/sandbox_notice_meta_test.go
Native Windows restricted-token plans with DenyRead emit warnings. Command metadata stores notices as sandbox_notices. Tests cover warning scope and propagation.
Enforcement notice visibility
internal/tools/types.go, internal/tools/tool_outcome.go, internal/agent/types.go, internal/agent/loop.go, internal/tools/sandbox_notice_visibility_test.go
Tool and agent results preserve notices. Model output and human display prepend non-empty notices while retaining command output.
Restricted-token SID invariants
internal/sandbox/windows_token_windows_test.go
Windows-only tests verify capability SID retention and exclusion of World, broad group, and current-user SIDs from restricted SID lists.
Windows setup recovery guidance
internal/sandbox/windows_command_runner_windows.go, internal/sandbox/windows_unelevated_guidance_windows_test.go
ACL failure guidance now recommends elevated zero sandbox setup or disabling sandboxing through user configuration. Failed plans are not recorded as applied.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 819e2

The PR adds Windows token-invariant checks and a scoped warning for the deny-read tradeoff. The remaining concern is a bounded missing failure-path regression test, not evidence of a production defect, so no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant CommandPlan
  participant SandboxRunner
  participant CommandTool
  participant AgentLoop
  participant Displays
  CommandPlan->>SandboxRunner: determine enforcement and notices
  SandboxRunner->>CommandTool: provide enforcement metadata
  CommandTool->>AgentLoop: return EnforcementNotices
  AgentLoop->>Displays: prepend notices to model and human output

Suggested reviewers: anandh8x, gnanad1990, kevincodex1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 67.65% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 12 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the main changes: protecting the Windows write-jail invariant and disclosing the DenyRead tradeoff.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-restricted-sid-invariant

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]3mo ago

Walkthrough

Native Windows restricted-token plans now warn when DenyRead disables write confinement. Notices propagate through enforcement metadata, tool results, hooks, plugins, model output, and human display. Windows tests cover token SIDs, warning scope, notice visibility, and ACL setup failures.

Changes

Windows sandbox behavior

Layer / File(s)Summary
Sandbox enforcement contract and planning
internal/execution/contracts.go, internal/sandbox/runner.go
EnforcementFor centralizes command-plan conversion. Applicable plans now carry enforcement notices and identify actual Windows restricted-token execution.
Deny-read warning and metadata propagation
internal/sandbox/manager.go, internal/sandbox/runner.go, internal/sandbox/windows_deny_read_*.go, internal/tools/bash.go, internal/tools/sandbox_notice_meta_test.go
Native Windows restricted-token plans with DenyRead emit warnings. Command metadata stores notices as sandbox_notices. Tests cover warning scope and propagation.
Enforcement notice visibility
internal/tools/types.go, internal/tools/tool_outcome.go, internal/agent/..., internal/hooks/..., internal/plugins/..., internal/tools/*notice*_test.go
Tool, agent, hook, and plugin results preserve notices. Model output and human display prepend non-empty notices while retaining command output.
Restricted-token SID invariants
internal/sandbox/windows_token_windows_test.go
Windows-only tests verify capability SID retention and exclusion of World, broad group, and current-user SIDs from restricted SID lists.
Windows setup recovery guidance
internal/sandbox/windows_command_runner_windows.go, internal/sandbox/windows_unelevated_guidance_windows_test.go
ACL failure guidance recommends elevated zero sandbox setup or disabling sandboxing through user configuration. Failed plans are not recorded as applied.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: 🟡 Moderate · up to a8100

The PR adds Windows write-jail protection and a deny-read warning, but the current code can still omit enforcement notices on blocked or failed operations, while a key Windows test skips when the restricted-token plan is missing. That can hide a disabled sandbox boundary or prevent users from seeing an important security tradeoff, so the PR is not merge-ready until these paths are corrected.

Sequence Diagram(s)

sequenceDiagram
  participant CommandPlan
  participant SandboxRunner
  participant CommandTool
  participant AgentLoop
  participant HookAndPluginHandlers
  participant Displays
  CommandPlan->>SandboxRunner: determine enforcement and notices
  SandboxRunner->>CommandTool: provide enforcement metadata
  CommandTool->>AgentLoop: return EnforcementNotices
  CommandTool->>HookAndPluginHandlers: return enforcement notices
  AgentLoop->>Displays: prepend notices to model and human output

Suggested reviewers: anandh8x, gnanam1990, kevincodex1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 63.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 17 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the main changes: protecting the Windows write-jail invariant and disclosing the DenyRead tradeoff.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-restricted-sid-invariant

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]3mo ago

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 64d58434-6fb2-4156-b662-ba77a8136af3

📥 Commits

Reviewing files that changed from the base of the PR and between 767c5e12bdcadce14f55648c1b3296c2bc6372d8 and 45c29de5447347a83c2cee423a87232826cbf7de.

📒 Files selected for processing (1)
  • internal/sandbox/windows_deny_read_disclosure_test.go

Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


Walkthrough

Native Windows restricted-token plans now warn when DenyRead disables write confinement. Notices propagate through enforcement metadata, tool results, hooks, plugins, model output, and human display. Windows tests cover token SIDs, warning scope, notice visibility, and ACL setup failures.

Changes

Windows sandbox behavior

Layer / File(s)Summary
Sandbox enforcement contract and planning
internal/execution/contracts.go, internal/sandbox/runner.go, internal/sandbox/windows_deny_read_disclosure_test.go
EnforcementFor centralizes command-plan conversion. Applicable plans now carry enforcement notices and identify actual Windows restricted-token execution.
Deny-read warning and metadata propagation
internal/sandbox/manager.go, internal/sandbox/runner.go, internal/sandbox/windows_deny_read_*.go, internal/tools/bash.go, internal/tools/sandbox_notice_meta_test.go
Native Windows restricted-token plans with DenyRead emit warnings. Command metadata stores notices as sandbox_notices. Tests cover warning scope and propagation.
Enforcement notice visibility
internal/tools/types.go, internal/tools/tool_outcome.go, internal/agent/..., internal/hooks/..., internal/plugins/..., internal/tools/*notice*_test.go
Tool, agent, hook, and plugin results preserve notices. Model output and human display prepend non-empty notices while retaining command output.
Restricted-token SID invariants
internal/sandbox/windows_token_windows_test.go
Windows-only tests verify capability SID retention and exclusion of World, broad group, and current-user SIDs from restricted SID lists.
Windows setup recovery guidance
internal/sandbox/windows_command_runner_windows.go, internal/sandbox/windows_unelevated_guidance_windows_test.go
ACL failure guidance recommends elevated zero sandbox setup or disabling sandboxing through user configuration. Failed plans are not recorded as applied.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: 🟡 Moderate · up to 45c29

The PR strengthens Windows sandbox checks and surfaces a configuration tradeoff, but failed executions can still lose enforcement notices and the Windows disclosure test can skip when restricted-token setup is absent, allowing regressions to pass unnoticed. These are bounded but concrete issues that should be fixed or explicitly accepted before merge.

Sequence Diagram(s)

sequenceDiagram
  participant CommandPlan
  participant SandboxRunner
  participant CommandTool
  participant AgentLoop
  participant HookDispatch
  participant PluginActivate
  participant Displays
  CommandPlan->>SandboxRunner: determine enforcement and notices
  SandboxRunner->>CommandTool: provide enforcement metadata
  CommandTool->>AgentLoop: return EnforcementNotices
  CommandTool->>HookDispatch: return enforcement notices
  CommandTool->>PluginActivate: return notices for launched children
  AgentLoop->>Displays: prepend notices to model and human output

Suggested reviewers: anandh8x, gnanam1990, kevincodex1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 69.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 56 functions across 17 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the main changes: protecting the Windows write-jail invariant and disclosing the DenyRead tradeoff.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-restricted-sid-invariant

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]3mo ago

Walkthrough

Native Windows restricted-token plans now warn when DenyRead disables write confinement. Notices propagate through enforcement metadata, tool results, hooks, plugins, model output, and human display. Windows tests cover token SIDs, warning scope, notice visibility, and ACL setup failures.

Changes

Windows sandbox behavior

Layer / File(s)Summary
Sandbox enforcement contract and planning
internal/execution/contracts.go, internal/sandbox/manager.go, internal/sandbox/runner.go, internal/sandbox/windows_deny_read_*.go
EnforcementFor centralizes command-plan conversion. Applicable Windows restricted-token plans now carry deny-read notices.
Restricted-token SID invariants
internal/sandbox/windows_token_windows_test.go
Windows-only tests verify capability SID retention and exclusion of World, broad group, and current-user SIDs.
Windows setup recovery guidance
internal/sandbox/windows_command_runner_windows.go, internal/sandbox/windows_unelevated_guidance_windows_test.go
ACL failure guidance recommends elevated setup or disabling sandboxing through user configuration. Failed plans are not recorded as applied.
Notice transport through command results
internal/tools/bash.go, internal/tools/exec_command.go, internal/tools/types.go, internal/tools/tool_outcome.go, internal/tools/*notice*_test.go
Command metadata stores notices as sandbox_notices. Tool results restore and expose those notices.
Enforcement notice visibility
internal/agent/..., internal/hooks/..., internal/plugins/...
Agent, hook, and plugin results preserve notices. Model output and human display prepend non-empty notices while retaining command output.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: 🟡 Moderate · up to 45c29

This PR strengthens Windows token regression protection and surfaces the deny-read/write-confinement tradeoff, but the current head is not merge-ready because some failure paths can misstate enforcement for commands that never started or omit enforcement notices on execution errors, while security-boundary checks can pass when required token or plan state is unavailable. These bounded correctness and assurance issues should be fixed or explicitly accepted before merge.

Sequence Diagram(s)

sequenceDiagram
  participant CommandPlan
  participant SandboxRunner
  participant CommandTool
  participant AgentLoop
  participant HookDispatch
  participant PluginActivate
  participant Displays
  CommandPlan->>SandboxRunner: determine enforcement and notices
  SandboxRunner->>CommandTool: provide enforcement metadata
  CommandTool->>AgentLoop: return EnforcementNotices
  CommandTool->>HookDispatch: return enforcement notices
  CommandTool->>PluginActivate: return notices for launched children
  AgentLoop->>Displays: prepend notices to model and human output

Suggested reviewers: anandh8x, gnanam1990, kevincodex1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 70.49% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 61 functions across 20 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the main changes: protecting the Windows write-jail invariant and disclosing the DenyRead tradeoff.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-restricted-sid-invariant

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]3mo ago

NOTE

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 419d96f4-a39d-4cf6-9508-da71c8f5c74b

📥 Commits

Reviewing files that changed from the base of the PR and between 45c29de5447347a83c2cee423a87232826cbf7de and 37611ffe2e2533374a69510aa8cebcc3c37da480.

📒 Files selected for processing (3)
  • internal/agent/enforcement_notice_projection_test.go
  • internal/agent/loop.go
  • internal/tools/types.go

Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


Walkthrough

Native Windows restricted-token plans now warn when DenyRead disables write confinement. Notices propagate through enforcement metadata, tool results, hooks, plugins, model output, and human display. Windows tests cover token SIDs, warning scope, notice visibility, and ACL setup failures.

Changes

Windows sandbox behavior

Layer / File(s)Summary
Sandbox enforcement contract and planning
internal/execution/contracts.go, internal/sandbox/manager.go, internal/sandbox/runner.go, internal/sandbox/windows_deny_read_*.go
EnforcementFor centralizes command-plan conversion. Applicable Windows restricted-token plans now carry deny-read notices.
Restricted-token SID invariants
internal/sandbox/windows_token_windows_test.go
Windows-only tests verify capability SID retention and exclusion of World, broad group, and current-user SIDs.
Windows setup recovery guidance
internal/sandbox/windows_command_runner_windows.go, internal/sandbox/windows_unelevated_guidance_windows_test.go
ACL failure guidance recommends elevated setup or disabling sandboxing through user configuration. Failed plans are not recorded as applied.
Notice transport through command results
internal/tools/bash.go, internal/tools/exec_command.go, internal/tools/types.go, internal/tools/tool_outcome.go, internal/tools/*notice*_test.go
Command metadata stores notices as sandbox_notices. Tool results restore and expose those notices.
Enforcement notice visibility
internal/agent/..., internal/hooks/..., internal/plugins/...
Agent, hook, and plugin results preserve notices. Model output and human display prepend non-empty notices while retaining command output.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: 🟡 Moderate · up to 37611

This PR adds Windows token-invariant checks and surfaces the denyRead tradeoff, but enforcement notices can still be lost on plugin failures or falsely reported when hooks do not launch a child process, while token-security checks may be skipped after lookup failures. These behaviors can hide or misstate sandbox enforcement, so merge should wait for fixes or explicit owner acceptance.

Sequence Diagram(s)

sequenceDiagram
  participant CommandPlan
  participant SandboxRunner
  participant CommandTool
  participant AgentLoop
  participant HookDispatch
  participant PluginActivate
  participant Displays
  CommandPlan->>SandboxRunner: determine enforcement and notices
  SandboxRunner->>CommandTool: provide enforcement metadata
  CommandTool->>AgentLoop: return EnforcementNotices
  CommandTool->>HookDispatch: return enforcement notices
  CommandTool->>PluginActivate: return notices for launched children
  AgentLoop->>Displays: prepend notices to model and human output

Suggested reviewers: gnanam1990, anandh8x, kevincodex1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly identifies the two main changes: protecting the Windows write-jail invariant and disclosing the DenyRead tradeoff.
Docstring Coverage✅ PassedDocstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-restricted-sid-invariant

Comment @coderabbitai help to get the list of available commands.

Vasanthdev20041mo ago

Merged main at 2ffe1831 and renamed this branch's imports to the Twigpine module path from #1105. The merge had no conflicts, and nothing else changed. The rename also covers the two internal/workspaceindex imports that #1153 fixes on main, so that hunk drops out of this diff once #1153 lands. go vet for windows, linux and darwin, go test ./..., the release build and smoke, and govulncheck all pass here.

Vasanthdev20041mo ago

3ad039e9 takes the one item from CodeRabbit's 9 September review that only lived in the review body, never as a thread: the paragraph describing publishAdapterLaunch in internal/mcp/client.go appeared twice, once above launchedOnce, where it described the wrong closure. That copy is gone. Comment-only.

Vasanthdev200417d ago

Merged current main (8288ae81) into this branch at 53ddd02a. It had gone unmergeable and was 39 commits behind.

One conflict, in internal/agent/loop.go at the final return of executeToolCall: main added DenialReason: denialCategoryForResult(result) to the result literal, and this branch wraps the same literal in withAppliedHookNotices. I kept both, the new field inside the wrapped literal. Every line main added to that file since the old base is present in the merged file, and denialCategoryForResult is called from the same three places as on main.

On the merged tree, on Windows: gofmt and vet clean, go test ./... green, release build and smoke pass, govulncheck reports no vulnerabilities (the Go 1.26.11 bump comes in with main), git diff --check clean.

@jatmn the conflict resolution dismissed your approval, sorry. The only hand-edited hunk is the one above.