T09 · Insecure Skill Coding Practices
- Location
SKILL.md:48- Finding
Unsafe Shell Path Interpolation in File Move Operation
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 48–51
Vulnerability Type: Unquoted shell arguments enabling command injection and unsafe file operations
Risk Level: MediumVulnerable Code
bash mv <源文件> <Obsidian路径>/Technical Analysis
The workflow instructs the agent to substitute a source filename and an Obsidian vault path directly into a shell command without quoting either operand or separating arguments safely.
File and directory names can contain whitespace, shell metacharacters, command substitutions, or option-like prefixes. If substituted into a shell command as written, these values may be split into multiple arguments or interpreted as shell syntax. In addition, the command does not use
--to prevent filenames beginning with-from being interpreted as options.The destination is discovered from the local environment or may be supplied by the user. The workflow does not require canonicalizing the path, confirming that it belongs to the intended vault, checking for symbolic-link redirection, or preventing an existing file from being overwritten.
Attack Path
- An attacker influences the source filename or provides a crafted Obsidian vault path.
- The crafted value includes whitespace, shell metacharacters, command substitution syntax, or an option-like prefix.
- The agent replaces the placeholders in the documented
mvcommand without safe argument handling. - The shell interprets part of the path as syntax, additional arguments, or command options.
- Commands execute with the agent process's privileges, or files are moved to or overwrite unintended locations.
Actual exploitability depends on whether the executing agent interpolates the values into a shell command as documented and whether an attacker can influence either path.
Impact Assessment
Successful shell injection could execute arbitrary commands with the privileges of the agent process. This could expose, alter, or delete files ...[truncated 420 chars]
- Remediation
View remediation
Remediation Suggestions
- Prefer a structured file-operation API that accepts the source and destination as separate arguments rather than constructing a shell command.
- If shell execution is unavoidable, assign paths to variables and quote every expansion:
bash source_path="..." vault_path="..." mv -n -- "$source_path" "$vault_path/"- Validate and canonicalize both paths before moving the file.
- Verify that the canonical destination remains within an explicitly approved Obsidian vault.
- Reject unexpected control characters and other unsafe path content.
- Check for symbolic links in destination path components where redirection would violate the intended boundary.
- Use
-nor require explicit confirmation before replacing an existing file. - Confirm that the source is a regular file and that the destination directory exists before performing the operation.
- Execute the operation with only the minimum filesystem permissions required.
