T09 · Insecure Skill Coding Practices
Warning
- Location
- runtime/route_referee/client.py:16
- Finding
- Configurable API endpoint can receive OnchainOS authentication credentials<![CDATA[ ## Vulnerability Details **File Location**: `runtime/route_referee/client.py:16, 65-81` **Vulnerability Type**: Authentication credential disclosure through an unvalidated destination override **Risk Level**: Medium ### Vulnerable Code ```python API_BASE_URL = os.getenv("ONCHAINOS_API_BASE", "https://web3.okx.com").rstrip("/") ``` ```python return { "OK-ACCESS-KEY": self.api_key, "OK-ACCESS-SIGN": self._sign(timestamp, method, request_path, body), "OK-ACCESS-TIMESTAMP": timestamp, "OK-ACCESS-PASSPHRASE": self.passphrase, "Content-Type": "application/json", "User-Agent": "xlayer-route-referee/1.0", } ``` ```python response = self.session.request( method=method.upper(), url=f"{self.base_url}{path}", params=params or None, headers=headers, timeout=self.timeout, ) ``` ### Technical Analysis The destination for authenticated API requests is taken directly from the `ONCHAINOS_API_BASE` environment variable. The client does not enforce HTTPS, validate the hostname, or restrict overrides to the documented OKX endpoint. Regardless of the selected destination, the request includes the OnchainOS API key, API passphrase, timestamp, and valid HMAC request signature. Although the signature is generated correctly, sending these headers to an arbitrary endpoint breaks the trust boundary expected for authentication material. The Base64 operation at `runtime/route_referee/client.py:58` is standard encoding of an HMAC-SHA256 digest. It is not, by itself, a covert exfiltration mechanism. The actual exposure arises from attaching authentication headers to an unvalidated, configurable destination. ### Attack Path 1. An attacker or compromised execution environment sets `ONCHAINOS_API_BASE` to an attacker-controlled URL. 2. The user runs any real route check with valid OnchainOS credentials. 3. The client constructs authentication headers for the request. 4. The request is sent to the substituted endpoint. 5. The attacker ...[truncated 718 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Hardcode or allowlist the production endpoint `https://web3.okx.com`. - Enforce HTTPS and reject URLs containing unexpected schemes, hosts, ports, user information, or path prefixes. - Validate the final request hostname immediately before attaching authentication headers. - If custom endpoints are required for development, require an explicit unsafe-development flag and do not use production credentials with them. - Separate request construction from credential attachment so authentication headers are only added after destination validation. - Document and apply least-privilege scopes to all OnchainOS credentials. - Rotate affected credentials if they may have been used while `ONCHAINOS_API_BASE` pointed to an untrusted endpoint. ]]>
