T09 · Insecure Skill Coding Practices
- Location
SKILL.md:39- Finding
Shell Command Injection Through an Untrusted Image URL
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 39–42
Vulnerability Type: Shell command injection through unsafe placeholder substitution
Risk Level: HighVulnerable Code
bash curl -s -X POST https://api.searchthisimage.com/api/v1/search/url \ -H "Content-Type: application/json" \ -H "X-API-Key: $SEARCHTHISIMAGE_API_KEY" \ -d '{"image_url": "IMAGE_URL_HERE"}'Technical Analysis
The skill instructs the agent to replace
IMAGE_URL_HEREwith a user-provided image URL inside a single-quoted shell argument. If this replacement is performed by constructing shell source text, an attacker can supply an image URL containing an apostrophe followed by shell operators. The apostrophe terminates the quoted JSON argument, allowing the remaining content to be interpreted by the shell rather than treated exclusively as URL data.The vulnerability is conditional on the agent performing literal textual substitution and then executing the resulting command through a shell. The project does not provide a safe serializer, argument-array implementation, or input validation that would prevent this interpretation.
Attack Path
- An attacker submits a purported image URL containing shell quoting characters, command separators, and an attacker-selected command.
- The agent replaces
IMAGE_URL_HEREwith the supplied value in the documented command. - The injected apostrophe terminates the single-quoted
curldata argument. - The shell parses the following metacharacters and text as a separate command.
- The injected command executes with the operating-system privileges and environment available to the agent process.
Impact Assessment
Successful exploitation permits arbitrary command execution under the agent process account. The attacker could read or modify files accessible to that account, access environment variables such as
SEARCHTHISIMAGE_API_KEY, invoke network utilities, t ...[truncated 197 chars]- Remediation
View remediation
Remediation Suggestions
-
Do not construct executable shell source by replacing placeholders with user-controlled values.
-
Use an HTTP client API that accepts arguments and request bodies as structured values without invoking a shell.
-
If
curlmust be used, construct the JSON body with a safe serializer such asjq:bash payload="$(jq -n --arg image_url "$IMAGE_URL" '{image_url: $image_url}')" curl -sS -X POST 'https://api.searchthisimage.com/api/v1/search/url' \ -H 'Content-Type: application/json' \ -H "X-API-Key: $SEARCHTHISIMAGE_API_KEY" \ --data-binary "$payload" -
Pass the URL through a variable as a distinct argument rather than inserting it into command text.
-
Validate that the supplied URL uses an explicitly permitted scheme such as
https. -
Reject control characters and enforce reasonable URL length limits.
-
Run the skill with least privilege, a restricted environment, and outbound network controls to reduce the consequences of any future injection flaw.
-
