T09 · Insecure Skill Coding Practices
- Location
scripts/excel_api_client.py:520- Finding
API Key Disclosure Through Unrestricted Backend URL Override
- Content
View full analysis
env var if api_key is not None: self.api_key = api_key else: self.api_key = _get_api_key_auto() self.timeout = timeout if not self.api_key: raise ValueError("SKYWORK_API_KEY is required (set env or pass api_key=)") self._headers = {"Authorization": f"Bearer {self.api_key}"} ``` ```python def _build_request( self, url: str, method: str = "GET", headers: Optional[dict] = None, data: Optional[bytes] = None ) -> urllib.request.Request: """Build a urllib request with merged headers.""" request_headers = {**self._headers} if headers: request_headers.update(headers) return urllib.request.Request(url=url, data=data, headers=request_headers, method=method) def _urlopen( self, request: urllib.request.Request, timeout: Optional[int] = None ): """Open a URL request with configured timeout.""" return urllib.request.urlopen(request, timeout=timeout or self.timeout) ``` ```python parser.add_argument("--base-url", default=SKYWORK_GATEWAY_URL, help="Backend service URL") ``` ### Technical Analysis The client accepts an unrestricted `--base-url` value while `_build_request()` automatically attaches the Skywork Bearer credential to every request. There is no scheme validation, hostname allowlist, origin validation, or redirect-target validation before transmitting the credential. Although sending the API key to the declared Skywork service is necessary for the Skill, allowing the same credential to be sent to an arbitrary caller-selected destination exceeds minimum privilege. The initial health-check request is sufficient to disclose the credential; successful ...[truncated 1053 chars]- Remediation
View remediation
