T09 · Insecure Skill Coding Practices
Error
- Location
- valuation.py:16
- Finding
- Hard-Coded Tavily API Credential## Vulnerability Details **File Location**: `valuation.py`, line 16 **Vulnerability Type**: Hard-coded API credential **Risk Level**: High **Vulnerable Code**: ```python os.environ["TAVILY_API_KEY"] = "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" ``` ### Technical Analysis A Tavily API credential is embedded directly in the distributed source code. Anyone with read access to the project can recover the plaintext token without executing the skill. The assignment also overwrites any `TAVILY_API_KEY` already supplied through a secure runtime configuration, forcing all executions to use the exposed credential. The token can be copied from the source and submitted directly to Tavily from a separate system. No local privilege escalation or command execution is required. ### Attack Path 1. An attacker obtains read access to the skill package or a repository containing `valuation.py`. 2. The attacker reads line 16 and extracts the Tavily API token. 3. The attacker configures the extracted token in an independent API client. 4. The attacker submits Tavily requests under the credential owner's account until the credential is revoked, expires, or reaches its service limits. ### Impact Assessment Successful exploitation permits unauthorized use of the Tavily account within the permissions assigned to the exposed token. This may consume API quota, disrupt legitimate requests through rate-limit exhaustion, expose account usage metadata, and create financial impact if usage-based billing is enabled. The code does not establish that this token grants local system privileges or access to unrelated services.
- Remediation
- ## Remediation Suggestions 1. Revoke and rotate the exposed Tavily token immediately; deleting it from the current source alone does not invalidate copies in repository history or distributed packages. 2. Remove the hard-coded assignment and read the credential from runtime configuration: ```python tavily_api_key = os.environ.get("TAVILY_API_KEY") if not tavily_api_key: raise RuntimeError("TAVILY_API_KEY is not configured") ``` 3. Supply the token through a secret manager or a protected environment variable with access limited to the service account running the skill. 4. Do not overwrite an existing securely configured environment variable. 5. Purge the credential from version-control history and previously published artifacts where feasible. 6. Add automated secret scanning and pre-commit checks to prevent credentials from being committed again. 7. Review Tavily access and usage logs for unauthorized requests, and restrict the replacement token's permissions and quotas to the minimum required.
