T09 · Insecure Skill Coding Practices
- Location
SKILL.md:63- Finding
Shell Command Injection Through User-Controlled SQL and File Paths
- Content
View full analysis
sql execute "" ``` ```bash dbskiter --output-mode=ai --database=<数据库名> sql import <文件路径> --table=<表名> --format=<格式> ``` ```bash dbskiter --output-mode=ai --database=<数据库名> sql batch <文件路径> ``` The execution workflow explicitly instructs the agent to insert user-provided SQL into a shell command: ```text 步骤1:提取用户提供的SQL 步骤2:执行 dbskiter --output-mode=ai --database= sql execute "" 步骤3:展示结果(最多50行) 步骤4:告知总行数和耗时 ``` ### Technical Analysis The skill constructs command-line examples by directly embedding user-controlled SQL, database names, table names, and file paths into shell command strings. SQL is placed inside double quotes, while several file and identifier arguments are left unquoted. Shell double quotes do not neutralize command substitution. Constructs such as `$(command)` and backticks remain active inside double-quoted arguments. Unquoted file paths additionally allow shell separators, redirections, glob expansion, and other metacharacters to alter the intended command. The document does not require argument-array execution, shell avoidance, strict validation, or platform-appropriate escaping. If an agent follows these templates through a shell, specially crafted user input can cause commands to execute before `dbskiter` receives the resulting argument. ### Attack Path 1. An attacker asks the agent to execute SQL containing shell syntax, for example: ```sql SELECT '$(id > /tmp/dbskiter-command-injection)' ``` 2. Following the documented workflow, the agent constructs a command similar to: ```bash dbskiter --output-mode=ai --database=prod sql execute "SELECT '$(id > /tmp/dbskiter-command-injection)'" ``` 3. The shell evaluates `$(...)` b ...[truncated 1101 chars]- Remediation
View remediation
