T09 · Insecure Skill Coding Practices
- Location
SKILL.md:17- Finding
Unsafe Shell Argument Handling and Untrusted Relative Script Execution
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 17-22
Vulnerability Type: Command injection and unsafe executable resolution
Risk Level: HighVulnerable Code Snippet
sh ./publish-skills.sh --root ".cursor/skills" ./publish-skills.sh --root ".cursor/skills" --skill "<skill-directory-name>"The surrounding instructions direct the agent to select batch or single-Skill publishing based on user input and substitute the requested Skill directory name into the second command.
Technical Analysis
The Skill instructs an agent to insert a user-controlled Skill directory name into a shell command without requiring strict input validation or execution through a shell-free argument-array API. Double quotes do not prevent every form of shell evaluation. For example, command substitutions such as
$(command)can still be evaluated when a generated command string is passed to a shell.The command also invokes
./publish-skills.shthrough a path relative to the current working directory. No instruction requires the agent to resolve the expected repository root, reject symbolic links, verify file ownership, or authenticate the script. Consequently, the executed file is whichever object occupies that path in the agent's current directory.Exploitation is conditional on the agent constructing and executing these instructions as a shell command string or operating in a repository containing an attacker-controlled publishing script.
Attack Path
User-input injection path:
- An attacker requests publication of a Skill whose supplied directory name contains shell substitution syntax or other shell-significant content.
- The agent replaces the directory-name placeholder with that input.
- The agent submits the resulting command string to a shell.
- The shell evaluates the embedded syntax before or while invoking the publishing script.
- The attacker's command executes with the same ...[truncated 1360 chars]
- Remediation
View remediation
Remediation Suggestions
- Validate the requested Skill directory name against a strict allowlist, such as
^[A-Za-z0-9._-]+$, and reject path separators, traversal components, whitespace, control characters, and shell metacharacters. - Resolve the requested directory beneath a trusted Skills root and verify that the canonical path remains inside that root.
- Invoke the publishing script with an argument-array API rather than constructing a shell command string. Do not use
sh -c,bash -c,eval, or equivalent shell interpretation. - Resolve
publish-skills.shfrom a trusted absolute repository root instead of the current working directory. - Before execution, verify that the publishing script is a regular file, is not a symbolic link, has trusted ownership and permissions, and matches an approved version or integrity hash.
- Review the publishing script before execution and run it with the minimum filesystem, credential, and network permissions required.
- Avoid exposing
CLAWHUB_TOKENto unrelated subprocesses. Pass credentials only to the validated publishing process and redact them from command output and error logs. - Require explicit confirmation before batch publication or publication to a non-default registry.
- Validate the requested Skill directory name against a strict allowlist, such as
