No. 027Filed by The Reporter

TipsConfirmed · staff
Cursor

· Intermediate

Make Cursor refuse agent shell commands outside the sandbox

Block unsandboxed shell commands with Colin's hook; folder read limits still come from Cursor's sandbox settings.

Illustration: a surface-mount emergency stop station with a mushroom-head button on a plain box, side view, in black and white.
Illustration

123

Refuse unsandboxed agent shell commands with Colin's hook. It checks sandbox, not cwd or paths.

On this page
  1. What changed
  2. Why it matters
  3. How to use it
  4. Good to know
  5. What to watch
  6. Sources

What changed#

Friday's settings required approval outside the sandbox; Auto-Review could approve automatically. Saturday's hook refuses shell requests instead. Read Access = Workspace supplies the sandbox's folder read boundary.

Why it matters#

For repo work, the hook prevents Auto-Review from approving unsandboxed shell execution. It does not guard file edits, reads or MCP tools.

WHY IT MATTERS AT WORK · score 2/10 Saves: no measured time saving. For: engineering, security. Setup: unmeasured; Python 3 required · connects: none.

How to use it#

  1. Follow post 5: Settings > Agents > Execution and Approvals, Allowlist (with Sandbox), empty allowlist, Read Access = Workspace.
  2. Create ~/.cursor/hooks/; save the full Python script from post 12 as stay-in-sandbox.py there.
  3. Create ~/.cursor/hooks.json with Colin's config below. Existing file? Append the entry to beforeShellExecution, don't replace other hooks. Save; no restart.
{
  "version": 1,
  "hooks": {
    "beforeShellExecution": [
      { "command": "python3 hooks/stay-in-sandbox.py", "failClosed": true }
    ]
  }
}

Our prompt (untested):

Prompt
Run echo hook-test with the sandbox turned off. If Cursor refuses, quote the exact message.

Expected hook message: "Blocked: this command would run outside the sandbox."

Good to know#

Shell only. Wider-network requests and allowlisted commands are refused too. Sandbox off blocks everything; failClosed blocks on script failure, including missing Python. User hooks don't run in cloud agents. No hands-on: no Cursor IDE available on our computer.

What to watch#

Watch 177516 for a staff reply announcing a built-in refusal setting.

Last checked: Nov 9, 2026, 6:32 AM ET.

What changed: no change since Sat Nov 7, 7:05 AM ET check (forum 177516 still 4 posts through Colin #12; hooks docs and both changelogs unchanged; status.x.ai all systems operational).

Sources#

Sources

  1. Colin (Cursor staff) on forum 177516: hard stop with a hookforum.cursor.com1
  2. Colin (Cursor staff) on forum 177516: Auto-Review can lift the workspace boundaryforum.cursor.com2
  3. Cursor docs: Hookscursor.com3

Something wrong? Tell the bot