Skip to content

fix(core) disable command_might_be_dangerous when unsandboxed#15036

Open
dylan-hurd-oai wants to merge 3 commits intomainfrom
dh--sandbox--dangerous-commands
Open

fix(core) disable command_might_be_dangerous when unsandboxed#15036
dylan-hurd-oai wants to merge 3 commits intomainfrom
dh--sandbox--dangerous-commands

Conversation

@dylan-hurd-oai
Copy link
Collaborator

Summary

If we are in a mode that is already explicitly un-sandboxed, then ApprovalPolicy::Never should not block dangerous commands.

Testing

  • Existing unit test covers old behavior
  • Added a unit test for this new case

AskForApproval::Never => Decision::Forbidden,
AskForApproval::Never => {
if sandbox_is_explicitly_disabled {
// If the sandbox is explicitly disabled, we should allow the command to run
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could also be because no sandbox is available, like for Windows users who have not installed our sandbox?

Copy link
Collaborator Author

@dylan-hurd-oai dylan-hurd-oai Mar 18, 2026

Choose a reason for hiding this comment

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

Ah I might be misunderstanding the intent of FileSystemSandboxKind. Should we instead use the following logic?

let sandbox_is_explicitly_disabled =  matches!(
    sandbox_policy,
    SandboxPolicy::DangerFullAccess | SandboxPolicy::ExternalSandbox { .. },
)

I've updated to switch to this instead

@bolinfest
Copy link
Collaborator

Here's something that has been on my personal backlog:

Introduce a NoSandboxAvailable variant to SandboxMode and make sure ReadOnly means what we think it means everywhere it is used.

Currently, because we cannot distinguish between NoSandboxAvailable and FileSystemSandboxKind::Unrestricted, I don't think this change is safe.

Also, the point about prefix_rule() still stands, though I admit that if the agent is truly running unsandboxed and it is determined to do something, prefix_rule() is unlikely to stop it unless it's a setuid binary or something that can take an action as root that the agent has no other way of running...

@dylan-hurd-oai
Copy link
Collaborator Author

dylan-hurd-oai commented Mar 18, 2026

re: prefix_rule(), I don't think this change supersedes any ExecPolicy decisions, since this change is in render_decision_for_unmatched_command - I added an additional test to confirm this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants