T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/debug_news.sh:6
- Finding
- Hardcoded Tavily API credential exposed in executable scripts and documentation<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/debug_news.sh:6-10` - `scripts/simple_news_test.sh:6-11` - `SKILL.md:27-31` - `config/config.sh:7-13` - `references/workflow.md:72-80` **Vulnerability Type**: Hardcoded secret and plaintext credential exposure **Risk Level**: High ### Vulnerable Code From `scripts/debug_news.sh`: ```bash # Set the API key export TAVILY_API_KEY="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" # Retrieve news news_result=$(node ~/.openclaw/workspace/skills/tavily-search/scripts/search.mjs "site:news.cn 今日国际 OR site:xinhuanet.com 今日要闻 OR site:people.com.cn 国际新闻 $(date +%Y-%m-%d)" -n 6 --topic news --days 1) ``` The same credential is assigned in `scripts/simple_news_test.sh`: ```bash export TAVILY_API_KEY="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" ``` It is also disclosed through configuration examples in `SKILL.md`, `config/config.sh`, and `references/workflow.md`. ### Technical Analysis A credential-shaped Tavily API key is embedded directly in the distributed project. The two test scripts do not merely show it as an example: they export it into the process environment and use it when invoking the Tavily search implementation. Secrets committed to project files must be considered compromised because they can be recovered from distributed packages, backups, caches, logs, repository history, and forks. Removing the current visible copies alone would not invalidate copies already obtained by third parties. Environment variables are appropriate only when they are populated at deployment or execution time. Hardcoding the value before exporting it does not provide secret isolation. ### Attack Path 1. An attacker downloads the Skill package or obtains access to any repository copy, artifact, backup, or fork. 2. The attacker searches the files for `TAVILY_API_KEY` or strings beginning with `tvly-`. 3. The attacker extracts the embedded credential. 4. The attacker submits Tavily req ...[truncated 969 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke the exposed Tavily key immediately and create a replacement. Rotation is required even if the current key appears unused. 2. Remove the real key from every executable script, configuration example, and documentation file. 3. Purge the credential from version-control history, release artifacts, caches, and published packages where feasible. 4. Require runtime secret injection: ```bash : "${TAVILY_API_KEY:?TAVILY_API_KEY must be supplied through the runtime environment}" export TAVILY_API_KEY ``` 5. Store the replacement in a secret manager or another access-controlled runtime facility rather than `.bashrc`, source files, or project-local configuration. 6. Replace documentation values with an unambiguously nonfunctional placeholder such as: ```bash export TAVILY_API_KEY="<set-through-secret-manager>" ``` 7. Add secret scanning to pre-commit and CI pipelines, including detection rules for Tavily key prefixes. 8. Restrict and monitor the replacement credential where the provider supports quotas, usage alerts, expiration, or scope controls. 9. Review Tavily usage logs for unauthorized requests made with the exposed credential. ]]>
