T09 · Insecure Skill Coding Practices
- Location
scripts/common.py:59- Finding
API Key Can Be Transmitted to an Arbitrary Configured Endpoint
- Content
View full analysis
dict[str, str]: headers = {"Accept": "application/json"} if auth_mode == "auth": headers["Authorization"] = f"Bearer {self.api_key}" return headers ``` ```python def json_request( self, method: str, url: str, auth_mode: str, *, query: dict[str, Any] | None = None, body: dict[str, Any] | None = None, ) -> dict[str, Any]: try: response = self._http.request( method, url, headers=self._headers(auth_mode), params=query, json=body, ) ``` ### Technical Analysis The API destination is taken directly from `GOAI_BASE_URL` without validating its scheme or hostname. Authenticated requests then include `GOAI_API_KEY` as a bearer token. Although endpoint overriding is documented, the implementation does not ensure that the override uses HTTPS or belongs to a trusted GoAI domain. A malicious or accidentally unsafe environment configuration can consequently redirect authenticated requests to an attacker-controlled server. An `http://` override could additionally expose credentials and request data to a network observer. This behavior exceeds least privilege because a production credential should only be disclosed to the service origin for which it was issued. ### Attack Path 1. An attacker, compromised launcher, or unsafe configuration modifies `GOAI_BASE_URL`. 2. The user invokes the Skill with a valid `GOAI_API_KEY`. 3. `GoAIClient` builds conversion and signing URLs from the attacker-controlled base URL. 4. `_headers(" ...[truncated 663 chars]- Remediation
View remediation
