Safety Levels
Caro includes a comprehensive safety system that validates all generated commands before execution. This page explains how safety validation works and how to configure it for your needs.
How Safety Validation Works
Every command generated by Caro goes through multiple validation steps:
- Pattern Matching - Checks against known dangerous command patterns
- Risk Assessment - Evaluates the potential impact of the command
- POSIX Compliance - Verifies the command uses standard utilities
- Path Validation - Checks for operations on protected system paths
Risk Levels
Commands are classified into four risk levels:
Safe
Commands that only read data or have no lasting effects. These execute without confirmation.
ls -la
cat file.txt
pwd
date Moderate
Commands that modify user data but are generally reversible. May require confirmation depending on safety level.
mv file.txt backup/
cp -r src/ dest/
git commit -m "message" High
Commands that can cause significant data loss or system changes. Require confirmation in moderate and strict modes.
rm -rf directory/
chmod -R 777 folder/
sudo apt-get remove package Critical
Commands that could damage the system or cause irreversible data loss. Blocked in strict and moderate modes.
rm -rf /
mkfs.ext4 /dev/sda
dd if=/dev/zero of=/dev/sda Safety Levels
Strict
Maximum protection for production systems and sensitive data:
- Blocks: High and Critical risk commands
- Confirms: Moderate risk commands
- Allows: Safe commands
$ caro --safety strict "delete all log files" Moderate (Default)
Balanced protection for everyday use:
- Blocks: Critical risk commands
- Confirms: High risk commands
- Allows: Safe and Moderate commands
$ caro --safety moderate "cleanup temp files" Permissive
Minimal restrictions for experienced users:
- Blocks: Nothing (only warns)
- Confirms: Critical risk commands
- Allows: All other commands with warnings
$ caro --safety permissive "format disk" Dangerous Command Patterns
Caro blocks or warns about these known dangerous patterns:
Filesystem Destruction
rm -rf /- Remove root filesystemrm -rf ~- Remove home directoryrm -rf /*- Remove all files
Disk Operations
mkfs.*- Format diskdd if=/dev/zero- Overwrite with zerosfdisk- Modify partitions
System Paths
/bin,/sbin- System binaries/usr- User programs/etc- System configuration/boot- Boot files
Other Dangerous Patterns
- Fork bombs:
:(){ :|:& };: - Recursive chmod:
chmod -R 777 / - Hidden sudo: Commands that escalate privileges unexpectedly
Bypassing Safety (Use with Caution)
The --confirm flag bypasses confirmation prompts.
Use only when you're certain about the command:
# Skip confirmation (dangerous!)
$ caro --confirm "remove all temp files" --confirm with commands you haven't reviewed.
Never use it in automated scripts without careful review.
Best Practices
- Use strict mode on production systems
- Use moderate mode for daily development
- Use permissive mode only in isolated environments
- Always review commands before execution
- Use
--dry-runto preview dangerous operations