T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:147
- Finding
- Unrestricted API Endpoint Override Can Exfiltrate Bearer Credentials<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:147-159` **Vulnerability Type**: Credential disclosure through an attacker-controlled API endpoint **Risk Level**: High ### Vulnerable Code ```python API_BASE = os.environ.get("GREENHELIX_API_URL", "https://sandbox.greenhelix.net") session = requests.Session() api_key = os.environ.get("GREENHELIX_API_KEY", "") if api_key: session.headers["Authorization"] = f"Bearer {api_key}" session.headers["Content-Type"] = "application/json" def api_call(tool: str, input_data: dict) -> dict: """Call a GreenHelix REST endpoint for the given tool.""" response = session.post(f"{API_BASE}/v1/tools/{tool}", json=input_data) response.raise_for_status() return response.json() ``` ### Technical Analysis The destination of every authenticated request is controlled by the `GREENHELIX_API_URL` environment variable. The same reusable session automatically includes `GREENHELIX_API_KEY` as a bearer credential. The code does not validate the URL scheme or hostname, enforce an allowlist, reject embedded credentials or local network addresses, restrict redirects, or specify a timeout. Consequently, anyone able to modify the process environment can redirect both the API credential and sensitive migration payloads to an arbitrary server. Because the key is described as granting read/write access to purchased API tools, this network behavior can exceed minimum privilege when the same broadly scoped token is used for identity, financial, webhook, and key-management operations. ### Attack Path 1. An attacker compromises a CI/CD variable, deployment environment, shell profile, or orchestration configuration. 2. The attacker sets `GREENHELIX_API_URL` to an attacker-controlled URL. 3. An operator runs one of the guide's examples with a real `GREENHELIX_API_KEY`. 4. The session sends the bearer credential and agent migration data to the malicious endpoint. 5. The malicious server records the credential and ...[truncated 569 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not accept an unrestricted API origin through an environment variable. - Parse the configured URL and require HTTPS. - Allow only explicitly approved GreenHelix hostnames. - Reject embedded URL credentials, IP literals, private addresses, loopback addresses, and link-local destinations. - Disable redirects or verify that every redirect remains on the approved origin. - Add explicit connection and response timeouts. - Use separate, narrowly scoped credentials for read-only checks, financial changes, webhook management, and key rotation. - Avoid attaching an authorization header to a global session when the request destination has not been independently validated. - Fail closed if endpoint validation fails. ]]>
