Skip to content

Safety Validation

caro includes a comprehensive safety validation system to prevent dangerous command execution.

Commands are categorized into four risk levels:

LevelColorDescriptionExamples
SafeGreenNormal read operationsls, cat, find, grep
ModerateYellowFile modificationsmv, cp, chmod (non-system)
HighOrangeSystem-level changessudo, chown, system paths
CriticalRedBlocked - dangerousrm -rf /, fork bombs
Terminal window
# These patterns are BLOCKED:
rm -rf /
rm -rf ~
rm -rf /*
rm -rf /home
rm -rf /usr
rm -rf /bin
rm -rf /etc
Terminal window
# These patterns are BLOCKED:
dd if=/dev/zero of=/dev/sda
mkfs.ext4 /dev/sda
> /dev/sda
shred /dev/sda
Terminal window
# These patterns are BLOCKED:
:(){ :|:& };:
bomb() { bomb | bomb & }; bomb
while true; do $0 & done
Terminal window
# These patterns are flagged HIGH risk:
sudo su -
sudo bash
chmod 777 /
chmod -R 777 /etc
Terminal window
# Operations on these paths are flagged HIGH risk:
/bin/
/sbin/
/usr/bin/
/usr/sbin/
/etc/
/var/
/boot/
┌─────────────┐ ┌───────────────┐ ┌──────────────┐
│ Generated │────▶│ Pattern │────▶│ Path │
│ Command │ │ Matching │ │ Validation │
└─────────────┘ └───────────────┘ └──────────────┘
┌───────────────┐ ┌──────────────┐
│ Risk Level │◀────│ POSIX │
│ Assignment │ │ Compliance │
└───────────────┘ └──────────────┘

caro validates commands for POSIX compliance:

Standard POSIX utilities are preferred:

Terminal window
# File operations
ls, find, cp, mv, rm, mkdir, rmdir
# Text processing
cat, head, tail, grep, sed, awk, sort, uniq, wc
# System info
ps, df, du, who, date, uname
# Network
ping, curl, wget (where available)

When possible, bash-specific features are avoided for portability:

Terminal window
# Avoid:
[[ condition ]] # Use [ condition ] instead
$((arithmetic)) # Use expr instead where possible
{a..z} # Use seq or explicit lists

caro automatically quotes paths with special characters:

Terminal window
# Input: file with spaces.txt
# Output: "file with spaces.txt"
# Input: file's name.txt
# Output: "file's name.txt"
# Input: file$var.txt
# Output: 'file$var.txt'

For advanced users who understand the risks:

Terminal window
# Skip safety validation (DANGEROUS)
caro --unsafe "dangerous command"
# Acknowledge specific risk level
caro --allow-high-risk "system command"

These flags require explicit confirmation and are logged.

Customize safety behavior in config.toml:

[safety]
# Enable safety warnings (default: true)
warnings = true
# Require confirmation for moderate risk (default: true)
confirm_moderate = true
# Require confirmation for high risk (default: true)
confirm_high = true
# Block critical commands (default: true)
block_critical = true
# Custom blocked patterns
blocked_patterns = [
"custom-dangerous-command",
]
# Custom allowed patterns (override blocks)
allowed_patterns = [
"rm -rf ./node_modules", # Allow specific cleanup
]

If you find a way to bypass safety validation:

  1. Do not disclose publicly
  2. Email security@caro.sh with details
  3. Include the command that bypassed validation
  4. Wait for confirmation before public disclosure

We take security seriously and will respond within 48 hours.