T09 · Insecure Skill Coding Practices
- Location
SKILL.md:24- Finding
Shell Command Injection Through Unsafe User-Controlled Placeholder Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:24-38,SKILL.md:53-57,SKILL.md:62-66,SKILL.md:71-83, andSKILL.md:100-112
Vulnerability Type: Shell command injection
Risk Level: HighThe documented commands interpolate user-controlled values directly into shell command text. Representative vulnerable code from
SKILL.md:24-38:bash curl -s -X POST https://api.unkey.dev/v1/keys.createKey \ -H "Authorization: Bearer $UNKEY_ROOT_KEY" \ -H "Content-Type: application/json" \ -d '{ "apiId": "'"$UNKEY_API_ID"'", "name": "{{name}}", "prefix": "edith", "meta": { "purpose": "{{purpose}}" }, "expires": {{expires_unix_ms_or_null}}, "ratelimit": { "async": true, "limit": {{rate_limit_per_second_or_10}}, "duration": 1000 } }'Additional affected commands include:
bash curl -s -X POST https://api.unkey.dev/v1/keys.deleteKey \ -H "Authorization: Bearer $UNKEY_ROOT_KEY" \ -H "Content-Type: application/json" \ -d '{"keyId": "{{keyId}}"}'bash curl -s -X POST https://api.unkey.dev/v1/keys.verifyKey \ -H "Content-Type: application/json" \ -d '{"apiId": "'"$UNKEY_API_ID"'", "key": "{{key}}"}'bash curl -s -X POST https://api.unkey.dev/v1/keys.updateKey \ -H "Authorization: Bearer $UNKEY_ROOT_KEY" \ -H "Content-Type: application/json" \ -d '{ "keyId": "{{keyId}}", "name": "{{new_name}}", "ratelimit": { "async": true, "limit": {{new_limit}}, "duration": 1000 } }'Technical Analysis
Values such as
name,purpose,keyId,key, expiration, and rate-limit fields are inserted directly into commands containing single-quoted JSON. If the Skill implementation performs textual placeholder substitution, an attacker-controlled single quote can terminate the quoted JSON argument. The attacker can then append shell metacharact ...[truncated 1343 chars]- Remediation
View remediation
Remediation Suggestions
- Do not construct shell commands through textual interpolation of user-controlled data.
- Prefer a dedicated HTTP client or structured API tool that sets headers and serializes JSON in-process.
- If shell execution is unavoidable, build request bodies with a JSON serializer such as
jq, passing strings through--argand validated numeric values through--argjson. - Pass values through environment variables or positional parameters rather than inserting them into executable command text.
- Validate key IDs against an explicit expected character set and length.
- Parse expiration and rate-limit values as integers and enforce minimum and maximum bounds.
- Treat names and purposes as untrusted text and impose reasonable length limits.
- Add adversarial tests containing quotes, command substitutions, semicolons, newlines, and other shell metacharacters.
- Run the Skill under a minimally privileged operating-system identity with restricted file and network access to limit the consequences of any remaining injection flaw.
