T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/broadcast_sign_transfer.py:237
- Finding
- Sensitive API authorization and signed transaction material exposed through debug logging<![CDATA[ ## Vulnerability Details **File Location**: `scripts/broadcast_sign_transfer.py`, lines 237–251, 384, and 436 **Vulnerability Type**: Sensitive data exposure through application logs **Risk Level**: High ### Vulnerable Code ```python def _okx_headers(self, method: str, path: str, body: str = "") -> dict: timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z" sign = self._okx_sign(timestamp, method, path, body) print(f" [DEBUG] timestamp: {timestamp}") print(f" [DEBUG] method: {method}") print(f" [DEBUG] path: {path}") print(f" [DEBUG] body: {body}") print(f" [DEBUG] sign: {sign}") return { "OK-ACCESS-KEY": str(self.api_key), "OK-ACCESS-SIGN": str(sign), "OK-ACCESS-PASSPHRASE": str(self.passphrase), "OK-ACCESS-TIMESTAMP": str(timestamp), "Content-Type": "application/json", } ``` The signed transactions are also printed by both transfer operations: ```python signed_tx = self._sign_native_tx(to_address, amount_wei) print(f" signed_tx: {signed_tx}") return self._broadcast(signed_tx, enable_mev_protection) ``` ```python signed_tx = self._sign_token_tx(token_address, to_address, amount_raw) print(f" signed_tx: {signed_tx}") return self._broadcast(signed_tx, enable_mev_protection) ``` ### Technical Analysis The Skill writes the complete OKX request body, timestamp, request path, request method, HMAC authorization signature, and raw signed transaction to standard output. The Base64 operation used to produce the OKX signature is ordinary encoding of an HMAC-SHA256 digest and is not, by itself, a covert exfiltration mechanism. The security problem is that the encoded signature and every input needed to reproduce the authenticated request are printed together. The request body includes the wallet address and signed transaction. The raw signed transaction does not expose the wallet private key and cannot be modified ...[truncated 1672 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove all production logging of: - Raw signed transactions - HMAC signatures - Authentication headers - Complete request bodies - API credentials or passphrases 2. If troubleshooting output is required, make it explicitly opt-in through a debug flag that defaults to disabled. 3. Apply structured redaction before logging. Log only non-sensitive operational fields such as chain name, transaction hash after acceptance, and a generated local correlation ID. 4. Ensure CI, agent, and application logs have restricted access and short retention periods. 5. Rotate the OKX API credentials if these logs may already have been exposed. 6. Add automated tests that capture stdout and verify that signatures, signed transactions, API keys, and passphrases never appear. ]]>
