T09 · Insecure Skill Coding Practices
- Location
tools/permission_manager.py:153- Finding
Permission Checker Authorization Bypass Through Substring-Based Command Allowlisting
- Content
View full analysis
RuleEffect: """ 检查命令安全性 返回: "allow" | "ask" | "deny" """ # 检查危险模式 for pattern in tool_perm.dangerous_patterns: if re.search(pattern, command, re.IGNORECASE): return "deny" # 检查安全命令白名单 for safe in tool_perm.safe_commands: if safe == "*": return "allow" if safe in command: return "allow" # 默认需要询问 return "ask" ``` ```bash RESULT=$(python3 "$TOOLS_DIR/permission_manager.py" check "$TOOL" "$COMMAND" 2>/dev/null) case "$RESULT" in *"ALLOW"*) exit 0 ;; ``` ### Technical Analysis The permission checker treats a command as safe when any allowlisted string occurs anywhere within the complete command text: ```python if safe in command: return "allow" ``` This is not an effective command authorization boundary. It does not parse the executable, arguments, shell control operators, pipelines, redirections, substitutions, or additional commands. An unsafe compound command can therefore include an allowlisted substring such as `echo`, `ls`, or `cat` and receive an `allow` result. The allowlist also incl ...[truncated 2225 chars]- Remediation
View remediation
