T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/broadcast_signed_tx.py:321
- Finding
- OKX Credentials Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/broadcast_signed_tx.py`, lines 321-326 **Vulnerability Type**: Sensitive credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```python parser.add_argument("--api-key", default="", help="OKX API Key(默认读 OKX_ACCESS_KEY 环境变量)") parser.add_argument("--secret-key", default="", dest="secret_key", help="OKX Secret Key(默认读 OKX_SECRET_KEY 环境变量)") parser.add_argument("--passphrase", default="", help="OKX Passphrase(默认读 OKX_PASSPHRASE 环境变量)") ``` ### Technical Analysis The command-line interface permits the OKX API key, secret key, and passphrase to be supplied directly as process arguments. Command-line arguments are not an appropriate secret-transport mechanism because they can be: - Recorded in shell history. - Captured by terminal logging or command telemetry. - Exposed through process inspection facilities while the script is running. - Retained in automation logs, job definitions, diagnostic reports, or monitoring systems. The script already supports loading the same credentials from specifically named environment variables, so exposing additional secret-bearing command-line options is not necessary for its declared transaction-broadcasting functionality. The API secret is used locally to generate an HMAC-SHA256 signature and is not itself sent to the OKX endpoint. The vulnerability concerns local disclosure caused by the CLI interface, not the legitimate authenticated HTTPS request. ### Attack Path 1. A user invokes the Skill with `--api-key`, `--secret-key`, or `--passphrase`. 2. The plaintext credential becomes part of the command line. 3. The command is retained in shell history, automation logs, process metadata, or terminal telemetry. 4. A local user, support operator, monitoring service, or compromised process with access to that data retrieves the credential. 5. The exposed credential is r ...[truncated 846 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `--api-key`, `--secret-key`, and `--passphrase` command-line options. 2. Load credentials from protected environment variables, an operating-system credential store, or a configuration file with restrictive filesystem permissions. 3. If interactive credential entry is required, use `getpass.getpass()` so secrets are not echoed. 4. Ensure application logs and exception messages never include credentials or complete authentication headers. 5. Recommend narrowly scoped, short-lived API credentials with only the permissions required to broadcast transactions. 6. Apply OKX-supported IP restrictions or equivalent account controls where available. 7. If command-line compatibility must temporarily be retained, display a prominent deprecation warning and document that command-line secret submission is unsafe. ]]>
