T09 · Insecure Skill Coding Practices
- Location
scripts/trendproof.py:59- Finding
API Credentials Can Be Forwarded to an Arbitrary Environment-Controlled Endpoint
- Content
View full analysis
str: return os.environ.get("TRENDPROOF_BASE_URL", DEFAULT_BASE_URL).rstrip("/") # ── HTTP ──────────────────────────────────────────────────────────────────── def _post(endpoint: str, body: dict, api_key: str | None) -> dict: base = _get_base_url() url = f"{base}{endpoint}" data = json.dumps(body).encode() headers = {"Content-Type": "application/json", "Accept": "application/json"} if api_key: headers["Authorization"] = f"Bearer {api_key}" req = urllib.request.Request(url, data=data, headers=headers, method="POST") try: with urllib.request.urlopen(req, timeout=30) as resp: return json.loads(resp.read()) ``` ### Technical Analysis The request destination is obtained from the `TRENDPROOF_BASE_URL` environment variable without validating its scheme, hostname, port, or origin. The `_post` function subsequently adds the user's TrendProof API key to the `Authorization` header for requests sent to that destination. Consequently, an environment override can cause the script to disclose both the API credential and submitted keyword data to a server other than the documented `https://trendproof.dev` service. Because the base URL can include an arbitrary scheme and host accepted by `urllib`, the code does not preserve the intended trust boundary around the credential. An endpoint override may be useful during development, but unrestricted overrides are not required for the Skill's declared production functionality. Production credentials should not be attached to requests sent to untrusted origins. ### Attack Path 1. An attacker influences the environment used to launch the Skill, such as through a compromised wrapper, automation configuration, shell profil ...[truncated 1129 chars]- Remediation
View remediation
