T09 · Insecure Skill Coding Practices
- Location
config.json:1- Finding
Hardcoded Tavily API Credential Stored in Plaintext
- Content
View full analysis
Vulnerability Details
File Location:
config.json:1-3
Vulnerability Type: Hardcoded secret and plaintext credential storage
Risk Level: Highjson { "api_key": "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" }Technical Analysis
The project contains a Tavily API credential directly in a distributed configuration file. Anyone with access to the project package, source repository, backup, build artifact, or repository history can retrieve the credential without authentication.
The application loads this value from
config.jsonand includes it in requests to the Tavily API. In addition,tavily.py:13-16persists user-supplied credentials to the same repository-local file without explicitly applying owner-only file permissions:python def save_config(api_key): with open(CONFIG_PATH, "w", encoding="utf-8") as f: json.dump({"api_key": api_key}, f, ensure_ascii=False, indent=2) print(f"[成功] API密钥已保存到: {CONFIG_PATH}")This design exposes credentials both through source distribution and through potentially permissive filesystem permissions. The audit did not validate whether the embedded credential remains active; however, its format and direct use by the application require it to be treated as compromised.
Attack Path
- An attacker obtains the project archive, checks out the repository, accesses a deployment artifact, or reads a backup containing the project.
- The attacker opens
config.jsonand extracts the plaintext Tavily API key. - The attacker submits requests directly to the Tavily API using the extracted key.
- If the key is active, the requests are attributed to the credential owner and consume the associated quota or account resources.
- The attacker may automate requests to exhaust available quota, interfere with legitimate use, or cause usage-based charges where applicable.
- Merely deleting the current file may not end expos ...[truncated 681 chars]
- Remediation
View remediation
Remediation Suggestions
- Revoke the exposed Tavily API key immediately and issue a replacement. Rotation is required even if the current key appears unused.
- Remove the credential from the current project and purge it from version-control history, release archives, build artifacts, backups, and cached packages where feasible.
- Obtain the API key at runtime from an environment variable or an operating-system secret manager rather than shipping it in the Skill package.
- Add
config.jsonand equivalent local secret files to.gitignoreand packaging exclusion rules. Distribute a credential-free template such asconfig.example.json. - If local file persistence must be supported, store secrets outside the project directory and create the file with owner-only permissions, such as mode
0600on POSIX systems. - Validate configuration structure without printing or logging the key. Error messages should not include credential values.
- Enable provider-side usage monitoring, restrictive quotas, and alerts for abnormal request volume.
- Review Tavily account activity for unauthorized use of the exposed credential.
