T09 · Insecure Skill Coding Practices
- Location
scripts/recon.sh:98- Finding
User-Controlled Target Can Be Interpreted as curl Command-Line Options
- Content
View full analysis
Vulnerability Details
File Location:
scripts/recon.sh:98-103
Vulnerability Type: curl argument injection caused by missing input validation and option termination
Risk Level: MediumVulnerable Code
bash # 2. Crawler simulation test echo "[*] Testing crawler permissions..." NORMAL_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$TARGET") BOT_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -A "Googlebot/2.1" "$TARGET") echo " Normal User-Agent: $NORMAL_RESPONSE" echo " Googlebot User-Agent: $BOT_RESPONSE"The same unsafe pattern is also used for target-derived values at
scripts/recon.sh:59,70,73, and90.Technical Analysis
TARGETis taken directly from the first command-line argument and is not validated as an HTTP or HTTPS URL. Although the variable is quoted, quoting only prevents shell word splitting and glob expansion; it does not preventcurlfrom interpreting an argument beginning with-as a command-line option.The calls on lines 101-102 pass
"$TARGET"directly tocurlwithout an option terminator. A value such as-K/tmp/attacker.confcan therefore be interpreted as curl's-Kconfiguration-file option rather than as a URL. A curl configuration file can specify URLs, uploads, output files, proxies, headers, and other behavior.The vulnerable code does not constitute shell command injection because the value is quoted and is not evaluated by the shell. It is nevertheless command-line argument injection into
curl.Attack Path
- An attacker obtains control of the target argument supplied to an automated or privileged invocation of the script.
- The attacker creates or identifies a curl configuration file accessible to the account running the script.
- The configuration file contains attacker-selected curl directives, potentially including an external URL and an
upload-filedirective referencing a file readable by the script account.
...[truncated 1481 chars]
- Remediation
View remediation
Remediation Suggestions
-
Require a fully qualified
http://orhttps://URL and reject all other schemes. -
Reject input beginning with
-, control characters, embedded credentials, or malformed hostnames. -
Place curl's
--option terminator immediately before every user-derived URL:bash NORMAL_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -- "$TARGET") BOT_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -A "Googlebot/2.1" -- "$TARGET") -
Parse and normalize the target once rather than constructing URLs through direct string concatenation.
-
If untrusted users can submit targets, resolve the hostname and block loopback, link-local, private, multicast, and cloud metadata addresses to reduce SSRF exposure.
-
Apply the same validation and
--termination to every curl invocation usingTARGETor a target-derived URL. -
Run reconnaissance under a dedicated, unprivileged account with restricted filesystem access and outbound network controls.
-
