T09 · Insecure Skill Coding Practices
Error
- Location
- apex-ia-trader.mjs:14
- Finding
- Plaintext Binance API credentials embedded in multiple executable files<![CDATA[ ## Vulnerability Details **File Location**: `apex-ia-trader.mjs:14-19`; repeated in `apex-ia-aggressive.mjs:13-16`, `apex-ia-final.mjs:13-16`, `apex-ia-final-20x.mjs:53-56`, `apex-ia-robot.mjs:13-16`, and `apex-ia-smc.mjs:53-56` **Vulnerability Type**: Hardcoded exchange credentials **Risk Level**: High ### Vulnerable Code ```js const API_KEY = 'Dq0vl5xeDxwQKMBwoJT5A9yxsJiW8hbXyVO7831c4xbI0N1tfiQjsTf1ZKsSVIXL'; const API_SECRET = '1kVF6XZuV5rVnKyIiAjbLTNcN50tQZEI8M5p90piOblTOl4W19rpgIeZMRzDlBBb'; const USE_DEMO = true; // true = conta demo, false = conta real // URLs const BASE_URL = USE_DEMO ? 'https://testnet.binancefuture.com' : 'https://fapi.binance.com'; ``` The credentials are subsequently used to create authenticated Binance request signatures: ```js function generateSignature(queryString, secret) { return crypto.createHmac('sha256', secret).update(queryString).digest('hex'); } ``` ### Technical Analysis The package distributes a Binance API key and secret in plaintext. The same credential pair is duplicated across several executable trading programs. Anyone who can obtain the package can extract and reuse the credentials without needing access to the original deployment environment. The reviewed defaults direct these credentials to Binance Futures testnet. This limits the currently demonstrated exposure, but it does not make plaintext credential distribution safe. The credentials permit signed account and order requests according to whatever permissions Binance has assigned to the key. Moreover, the source pattern encourages users to replace the constants with their own credentials, which could then be accidentally redistributed. ### Attack Path 1. An attacker downloads or otherwise obtains the package. 2. The attacker extracts `API_KEY` and `API_SECRET` from one of the executable files. 3. The attacker constructs Binance API query strings and signs them using HMAC-SHA256. 4. The attacker submits authenticated requests using th ...[truncated 622 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke and rotate the exposed API key and secret immediately. 2. Remove all credentials from source files, compiled artifacts, examples, and repository history. 3. Load user-specific credentials from a protected secret manager or environment variables. 4. Refuse to start authenticated components when required secrets are absent. 5. Use separate, read-only API keys for scanning and narrowly scoped trading keys for execution. 6. Enable Binance IP allowlisting and disable withdrawal permissions. 7. Add automated secret scanning to CI and pre-commit checks. 8. Ensure logs and error messages never print API keys, signatures, or complete signed URLs. ]]>
