Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.

fix(security): refuse shell execution when sandbox disabled, remove local fallback - #76

Merged
hyhmrright merged 1 commit into
devfrom
fix/high-security-shell-sandbox-bypass
Mar 17, 2026
Merged

hyhmrright merged 1 commit into
devfrom
fix/high-security-shell-sandbox-bypass

Conversation

@hyhmrright

Copy link
Copy Markdown
Owner

Summary

  • When `sandbox_enabled=False`, `shell_exec` silently fell back to `_exec_local()` — executing arbitrary commands inside the backend container with no isolation whatsoever
  • Removed `_exec_local()` entirely (no remaining callers after this fix)
  • When sandbox is disabled, `shell_exec` now returns a hard refusal: `"Shell execution is not available: sandbox is disabled."`
  • Operators who want shell must explicitly enable the sandbox

Test plan

  • `sandbox_enabled=False` → refusal string returned, no execution occurs
  • `_exec_local` no longer exists (dead code removed)
  • Normal sandbox-enabled path unaffected

🤖 Generated with Claude Code

…ocal fallback

When sandbox_enabled=False, shell_exec now returns a hard refusal instead
of falling back to direct execution in the backend container. The local
execution fallback (_exec_local) was a security bypass — it ran arbitrary
commands inside the backend process with no isolation.

Changes:
- Remove _exec_local() entirely (no remaining callers)
- Return "Shell execution is not available: sandbox is disabled." when
  sandbox_enabled=False, with a structured warning log event
- Update comment: _BLOCKED_PATTERNS is a pre-filter, not a fallback guard
- Add case-insensitive bypass tests (RM -RF /, MkFs) — already handled
  correctly by cmd_lower normalization
- Remove test_shell.py (duplicate of test_shell_tool.py, fully covered)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🤖 Hi @hyhmrright, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions github-actions Bot added documentation Improvements or additions to documentation backend Backend (FastAPI/Python) changes labels Mar 17, 2026
@github-actions

Copy link
Copy Markdown

🤖 I'm sorry @hyhmrright, but I was unable to process your request. Please see the logs for more details.

@hyhmrright
hyhmrright merged commit 5240248 into dev Mar 17, 2026
13 of 14 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backend Backend (FastAPI/Python) changes documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant