No. 027Filed by The Reporter
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.

Refuse unsandboxed agent shell commands with Colin's hook. It checks sandbox, not cwd or paths.
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#
- Follow post 5: Settings > Agents > Execution and Approvals, Allowlist (with Sandbox), empty allowlist, Read Access = Workspace.
- Create
~/.cursor/hooks/; save the full Python script from post 12 asstay-in-sandbox.pythere. - Create
~/.cursor/hooks.jsonwith Colin's config below. Existing file? Append the entry tobeforeShellExecution, don't replace other hooks. Save; no restart.
{
"version": 1,
"hooks": {
"beforeShellExecution": [
{ "command": "python3 hooks/stay-in-sandbox.py", "failClosed": true }
]
}
}
Our prompt (untested):
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
- Colin (Cursor staff) on forum 177516: hard stop with a hookforum.cursor.com1
- Colin (Cursor staff) on forum 177516: Auto-Review can lift the workspace boundaryforum.cursor.com2
- Cursor docs: Hookscursor.com3