nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] The execute_bash safety validator misses common spellings of "rm -rf /"

Open addyCooks opened this issue 1 month ago • 1 comments

Summary

The destructive-command check only matches the exact text rm -rf /. Other spellings of the same command pass the validator.

Steps to reproduce

Run executeBashTool.validator({command}) for each command below.

Expected behaviour

All variants of "recursive force delete of /" are blocked.

Actual behaviour

rm -rf /                      blocked
rm -fr /                      ALLOWED
rm -r -f /                    ALLOWED
rm -rf --no-preserve-root /   ALLOWED
rm -rf ~                      ALLOWED

A spec fails on the first allowed command: rm -fr / Value is not false: true. Outside yolo and headless mode bash still asks for approval, so this matters most when approval is off.

Environment

Windows 11, Node v22.22.3, Nanocoder 1.31.0 (main at 948a4e74)

Suggested fix

  • source/tools/execute-bash.tsx:232: parse the flags (any order, -r and -f together or apart, -R, --recursive, --force) and the target (/, /*, ~, $HOME), instead of one regex.
  • Or document the list as best-effort and stop saying matches are "blocked for safety".

addyCooks avatar Nov 02 '26 16:11 addyCooks

hey @addyCooks i would be happy to pick this up

Vishesh-Verma-07 avatar Nov 02 '26 18:11 Vishesh-Verma-07