Skip to main content

Module security

Module security 

Source
Expand description

Security Module - Command validation and blocklist

Provides security validation for exec: commands:

  • Control character detection (blocks null bytes, escape sequences)
  • Blocklist for dangerous command patterns
  • Unicode NFKC normalization to prevent confusable bypass
  • Full validation combining both checks

ยงUnicode Confusable Protection

Attackers may attempt to bypass the blocklist using Unicode confusables:

  • Fullwidth characters: rm vs ๏ฝ’๏ฝ (U+FF52, U+FF4D)
  • Math bold/italic: sudo vs ๐˜€๐˜‚๐—ฑ๐—ผ (U+1D600 range)
  • Combining characters: rm with zero-width joiners

NFKC (Compatibility Decomposition + Canonical Composition) normalizes these variants to their ASCII equivalents before blocklist checking.

See ADR-TBD for security design decisions.

Functionsยง

check_blocklist
Check command against blocklist
check_shell_mode_blocklist
Check command against shell-mode-specific blocklist.
sensitive_env_vars
Returns the list of sensitive env var names that should be stripped from child processes to prevent API key leakage.
strip_sensitive_env_vars
Remove sensitive API key env vars from a Command before spawning.
validate_command_string
Validate command string for control characters
validate_env_vars
Validate environment variables for dangerous names.
validate_exec_command
Full security validation for exec commands
validate_exec_command_with_shell
Full security validation for exec commands with explicit shell mode flag.