T09 · Insecure Skill Coding Practices
- Location
SKILL.md:70- Finding
Shell Command Injection Through Unquoted User-Controlled Arguments
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:70-80andSKILL.md:142
Vulnerability Type: OS command injection
Risk Level: HighComplete Code Snippet
bash cd /data/endecode-win-linux && python3 -m file_crypto --action encrypt --filePath <文件路径> --authId <身份令牌>bash cd /data/endecode-win-linux && python3 -m file_crypto --action encrypt --filePath <文件路径> --authId <身份令牌> --outputPath <输出路径> --expireTime <时间戳>bash cd /data/endecode-win-linux && python3 -m file_crypto --action decrypt --filePath <文件路径> --authId <身份令牌>bash cd /data/endecode-win-linux && python3 -m file_crypto --action getAuth --agentId <Agent标识>Technical Analysis
The Skill instructs the Agent to interpolate user-controlled file paths, output paths, authentication identifiers, expiration values, and Agent identifiers directly into shell command strings. None of these values are quoted, escaped, or validated before being placed in the command.
If the Agent executes these templates through a shell, metacharacters such as semicolons, command substitutions, redirection operators, pipes, or additional logical operators will be interpreted by the shell rather than passed as literal argument content. Validation performed by the Python module cannot prevent this issue because shell interpretation occurs before
file_cryptoreceives the arguments.File paths are particularly exposed because legitimate paths may contain spaces and shell-significant characters. The Skill also explicitly instructs the Agent to preserve paths as supplied, without defining an allowed directory, canonicalization process, or metacharacter restrictions.
Attack Path
- An attacker asks the Agent to encrypt or decrypt a purported server file.
- The attacker supplies a crafted path, output path, token, or Agent identifier containing shel ...[truncated 1648 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not construct a shell command by concatenating or interpolating user-controlled values.
- Invoke Python with an argument-array API that does not use a shell. For example, an implementation should use an equivalent of:
python subprocess.run( [ "python3", "-m", "file_crypto", "--action", action, "--filePath", file_path, "--authId", auth_id, ], cwd="/data/endecode-win-linux", shell=False, check=True, capture_output=True, text=True, ) - Restrict
actionto an explicit allowlist:encrypt,decrypt, orgetAuth. - Parse
expireTimeas an integer in application code and reject non-positive values before execution. - Canonicalize file paths and enforce an allowlisted server data root. Reject traversal outside that root, symbolic-link escapes, device files, directories, and unexpected file types.
- Enforce the documented maximum length and expected character format for
authIdandagentId. - Ensure output paths cannot overwrite configuration, executables, credentials, or other security-sensitive files.
- If shell invocation cannot be removed, apply robust platform-specific argument escaping to every value. Simple quote replacement or blacklist-based filtering is not sufficient.
- Run the file processor under a dedicated, minimally privileged operating-system account with filesystem and network restrictions.
