T09 · Insecure Skill Coding Practices
- Location
scripts/search.sh:65- Finding
SerpAPI Credential Exposure Through Command-Line Arguments and Request URL
- Content
View full analysis
&2; exit 1 ;; esac [[ -n "$LOCATION" ]] && PARAMS="${PARAMS}&location=$(urlencode "$LOCATION")" # Fetch TMPFILE=$(mktemp) trap "rm -f $TMPFILE" EXIT curl -s "https://serpapi.com/search.json?${PARAMS}" > "$TMPFILE" ``` ### Technical Analysis The script permits the SerpAPI key to be supplied with the `--api-key` command-line option. Command-line secrets can be retained in shell history and may be visible to local process-inspection or monitoring mechanisms. Regardless of whether the key originates from the command line, an environment variable, or a configuration file, it is subsequently embedded in the URL passed as a `curl` argument. While HTTPS protects the request in transit, it does not prevent local disclosure through process arguments, diagnostic traces, process-monitoring agents, or command-execution logs. The key grants access to the associated SerpAPI account and quota. It should therefore be treated as sensitive authentication material rather than ordinary request metadata. ### Attack Path 1. A user invokes the script with `--api-key`, or the script obtains a key from the environment or a configuration file. 2. The script places the credential into the `api_key` query parameter. 3. The complete URL containing the credential is supplied as a command-line argument to `curl`. 4. A local user, monitoring ser ...[truncated 619 chars]- Remediation
View remediation
