Skip to content

fix(security): fail closed when shell candidates are absent - #1747

Merged
Aaronontheweb merged 2 commits into
devfrom
fix/1746-shell-approval-empty-candidates
Aug 4, 2026
Merged

fix(security): fail closed when shell candidates are absent#1747
Aaronontheweb merged 2 commits into
devfrom
fix/1746-shell-approval-empty-candidates

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Summary

  • Require a nonempty shell candidate set before the approval exemption can allow a call.
  • Keep zero-candidate shell calls at RequiresApproval.
  • Cover empty input, whitespace, parser rejection, and all five exempt commands.
  • Prove that authorization evaluation does not execute the parser-rejected command.

Validation

  • dotnet test Netclaw.slnx --no-restore
  • dotnet slopwatch analyze
  • pwsh ./scripts/Add-FileHeaders.ps1 -Verify
  • git diff --check

Closes #1746

Copilot AI review requested due to automatic review settings August 3, 2026 21:42
@Aaronontheweb Aaronontheweb added security Security-related changes bug Something isn't working labels Aug 3, 2026

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - tightly targeted fix in the event that ShellSyntaxTree can't make heads or tails of the command being parsed

@Aaronontheweb
Aaronontheweb enabled auto-merge (squash) August 3, 2026 21:43
if (OperatingSystem.IsWindows())
return;

var markerPath = Path.Combine(Path.GetTempPath(), $"netclaw-approval-{Guid.NewGuid():N}");

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a security bug in the tool approval gate for shell_execute.
It makes the shell approval exemption fail closed when the matcher extracts zero candidates.

Changes:

  • Require a nonempty extracted candidate set before ApprovalExemptShellCandidates can allow a shell call.
  • Keep zero-candidate shell calls at RequiresApproval, including parser rejection cases.
  • Add evaluator tests for empty input, whitespace input, five exempt commands, and “no execution during authorization” proof.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Netclaw.Actors/Tools/DispatchingToolExecutor.cs Prevents an empty candidate set from being treated as an approval-exempt proof.
src/Netclaw.Actors.Tests/Tools/DispatchingToolExecutorTests.cs Adds regression tests that cover the fail-closed behavior and exemption cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Aaronontheweb

Copy link
Copy Markdown
Collaborator Author

The Windows failure is unrelated to #1746. A one-second regex wall-clock timeout failed under scheduler pressure.

PR #1748 replaces scanner timeouts with the linear non-backtracking engine. We should merge #1748 first, then rebase this pull request on dev.

Copilot AI review requested due to automatic review settings August 3, 2026 23:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@Aaronontheweb
Aaronontheweb merged commit 1d38725 into dev Aug 4, 2026
22 checks passed
@Aaronontheweb
Aaronontheweb deleted the fix/1746-shell-approval-empty-candidates branch August 4, 2026 00:20
@Aaronontheweb Aaronontheweb mentioned this pull request Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security Security-related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(security): fail closed when shell approval extraction returns no candidates

2 participants