T09 · Insecure Skill Coding Practices
- Location
SKILL.md:59- Finding
Unvalidated Remote Response Used in Shell Command Construction
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 59
Vulnerability Type: Shell argument injection through unquoted command substitution
Risk Level: MediumVulnerable Code:
bash curl -s https://ipinfo.io/$(curl -s https://api.ipify.org)/jsonTechnical Analysis
The output returned by
https://api.ipify.orgis inserted into the outercurlcommand through an unquoted command substitution. Because the substitution is not enclosed in double quotes, the shell can apply word splitting and pathname expansion to the remote response.If the API response is compromised or modified, whitespace-delimited content can introduce additional arguments to the outer
curlprocess. In particular, attacker-supplied strings resembling curl options could change request behavior or cause response data to be written to a path accessible to the current user.Exploitation requires control over the API response or a compromise of the HTTPS endpoint, its infrastructure, DNS resolution combined with a trusted certificate, or the local TLS trust environment. This reduces exploitability but does not remove the unsafe shell construction.
Attack Path
- A user or agent follows the full geolocation workflow in
SKILL.md. - The shell requests the public IP from
https://api.ipify.org. - An attacker controlling the service response returns whitespace-separated content rather than a valid IP address.
- The unquoted command substitution undergoes shell word splitting.
- Portions of the response are interpreted as additional arguments to the outer
curlcommand. - The injected curl arguments alter network behavior or write downloaded content to a location writable by the invoking user.
Impact Assessment
Successful exploitation executes curl with attacker-influenced arguments under the privileges of the user running the Skill. It does not directly provide privilege escalation or arbitrary shell command ...[truncated 354 chars]
- A user or agent follows the full geolocation workflow in
- Remediation
View remediation
Remediation Suggestions
Retrieve the address separately, validate it as an IPv4 or IPv6 address, and pass it as a quoted argument:
bash IP="$(curl --fail --silent --show-error --max-time 5 https://api.ipify.org)" || exit 1 python3 -c 'import ipaddress, sys; ipaddress.ip_address(sys.argv[1])' "$IP" || { printf '%s\n' "Invalid IP response" >&2 exit 1 } curl --fail --silent --show-error --max-time 5 \ "https://ipinfo.io/${IP}/json"Additional hardening should include:
- Apply connection and total request timeouts.
- Reject responses containing whitespace, control characters, or unexpected lengths.
- Use
--proto '=https'to restrict curl to HTTPS. - Prefer an API that returns structured JSON and validate its schema before using any field.
- Avoid constructing shell commands directly from remote response data.
