T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/generate.sh:38
- Finding
- Hardcoded SerpAPI Credential Embedded in Source Code<![CDATA[ ## Vulnerability Details **File Location**: `scripts/generate.sh`, line 38 **Vulnerability Type**: Hardcoded secret / credential exposure **Risk Level**: High ### Vulnerable Code ```bash SERPAPI_API_KEY="<redacted exposed API key>" python3 "$SERPAPI_SCRIPT" google "$KEYWORD" --num "$NUM_RESULTS" > "$TEMP_JSON" 2>&1 ``` The source contains a complete SerpAPI API key in place of the redacted value above. ### Technical Analysis A live-looking SerpAPI credential is embedded directly in a distributed shell script. Anyone who can read the skill package, a source repository containing it, a backup, or an installed copy can recover the credential without needing access to the intended secret-management system. The inline assignment also overrides any `SERPAPI_API_KEY` value configured by the user for that command. This conflicts with the documented configuration model and prevents operators from controlling which credential is used. Removing the credential from the current version is insufficient if it has already been published or committed, because it may remain available in package archives, caches, logs, or version-control history. ### Attack Path 1. An attacker downloads or otherwise obtains a copy of the skill package. 2. The attacker opens `scripts/generate.sh`. 3. The attacker extracts the hardcoded value assigned to `SERPAPI_API_KEY`. 4. The attacker submits requests to SerpAPI using the exposed credential. 5. Requests consume the associated account's quota and may cause financial or operational impact until the credential is revoked. ### Impact Assessment The attacker gains the ability to authenticate to SerpAPI with the exposed account credential. The scope is limited to the permissions and quota assigned to that key, but may include: - Unauthorized consumption of paid API quota. - Exhaustion of quota needed by legitimate workflows. - Charges against the credential owner's account. - Access to any SerpAPI capabilities authorized for the ...[truncated 184 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke and rotate the exposed API key immediately. Treat it as compromised. 2. Remove the key from the script and read it exclusively from the environment: ```bash if [ -z "${SERPAPI_API_KEY:-}" ]; then echo "Error: SERPAPI_API_KEY is not configured" >&2 exit 1 fi SERPAPI_API_KEY="$SERPAPI_API_KEY" \ python3 "$SERPAPI_SCRIPT" google "$KEYWORD" --num "$NUM_RESULTS" \ > "$TEMP_JSON" 2>&1 ``` 3. Prefer a platform secret store or credential manager over plaintext configuration files. 4. Purge the exposed value from version-control history, release archives, package registries, build artifacts, and logs where feasible. 5. Add automated secret scanning to commits and release pipelines. 6. Restrict the replacement key's permissions and quota to the minimum required by this skill. 7. Monitor the affected account for unauthorized historical usage. ]]>
