Security Guardian banner
rtk-ai rtk-ai

Security Guardian

Security community intermediate

Description

Comprehensive security analysis for RTK CLI tool, focusing on **command injection**, **shell escaping**, **hook security**, and **malicious input handling**.

Installation

Terminal
claude install-skill https://github.com/rtk-ai/rtk

README


description: CLI security expert for RTK - command injection, shell escaping, hook security

Security Guardian

Comprehensive security analysis for RTK CLI tool, focusing on **command injection**, **shell escaping**, **hook security**, and **malicious input handling**.

When to Use

    undefined

RTK Security Threat Model

RTK faces unique security challenges as a CLI proxy that:

    undefined

Threat Categories

Threat Severity Impact Mitigation
Command Injection 🔴 CRITICAL Remote code execution Input validation, shell escaping
Shell Escaping 🔴 CRITICAL Arbitrary command execution Platform-specific escaping
Hook Injection 🟡 HIGH Hook hijacking, command interception Permission checks, signature validation
Malicious Output 🟡 MEDIUM RTK crash, DoS Robust parsing, error handling
Path Traversal 🟢 LOW File access outside filters/ Path sanitization

Security Analysis Workflow

1. Threat Identification

**Questions to ask** for every code change:

Input Validation:
- Does this code accept user input?
- Is the input validated before use?
- Can special characters (;, |, &, $, `, \, etc.) cause issues?

Shell Execution:
- Does this code execute shell commands?
- Are command arguments properly escaped?
- Is std::process::Command used (safe) or shell=true (dangerous)?

Output Parsing:
- Does this code parse external command output?
- Can malformed output cause panics or crashes?
- Are regex patterns tested against malicious input?

Hook Integration:
- Does this code modify hooks?
- Are hook permissions validated (executable bit)?
- Is hook source code integrity checked?

2. Code Audit Patterns

**Command Injection Detection**:

// 🔴 CRITICAL: Shell injection vulnerability
let user_input = env::args().nth(1).unwrap();
let cmd = format!("git log {}", user_input); // DANGEROUS!
std::process::Command::new("sh")
    .arg("-c")
    .arg(&cmd) // Attacker can inject: `; rm -rf /`
    .spawn();

// ✅ SAFE: Use Command builder, not shell
use std::process::Command;

let user_input = env::args().nth(1).unwrap();
Command::new("git")
    .arg("log")
    .arg(&user_input) // Safely passed as argument, not interpreted by shell
    .spawn();

**Shell Escaping Vulnerability**:

// 🔴 CRITICAL: No escaping for special chars
fn execute_raw(cmd: &str, args: &[&str]) -> Result {
    let full