T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/auth-manager.js:193
- Finding
- Reusable Authentication Token Disclosed Through Standard Output<![CDATA[ ## Vulnerability Details **File Location**: `scripts/auth-manager.js:193-208` **Vulnerability Type**: Authentication credential exposure through process output **Risk Level**: Medium ### Vulnerable Code ```javascript if (command === 'clear') { manager.clearToken() } else if (command === 'check') { const token = manager.getSavedToken() if (token) { console.error('✅ 已授权') console.log(token) } else { console.error('❌ 未授权') process.exit(1) } } else { manager.authorize() .then(token => { console.log(token) ``` Both the authorization-status command and the normal authorization flow write the complete token to standard output. ### Technical Analysis The authentication token is a reusable credential sent as the `X-Auth-Token` header by the API client. Printing it to standard output exposes it outside the intended credential-storage boundary. Standard output is commonly captured by: - AI Agent execution transcripts - Parent processes and automation wrappers - CI/CD and diagnostic logs - Terminal recording and monitoring systems - Shell redirection - Centralized log collection services The `check` command only needs to report whether authorization exists, but it returns the credential itself. The normal authorization command also prints the token after retrieving and saving it. This unnecessarily expands the number of locations in which the secret may persist. ### Attack Path 1. A user or Agent invokes `node scripts/auth-manager.js check` or starts the default authorization workflow. 2. The script reads or retrieves the complete authentication token. 3. The token is printed to standard output. 4. An Agent transcript, process wrapper, terminal recorder, or logging service captures the output. 5. An attacker with access to that captured output obtains the token. 6. The attacker supplies the token as `X-Auth-Token` in requests to the Wangxiaobao API. 7. The attacker can access data and operations permitted by the com ...[truncated 897 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove all default output of the complete authentication token. 2. Change the `check` command to return only a status message and an appropriate exit code. 3. Do not print the token after normal authorization; pass it directly between trusted modules in memory. 4. If machine-readable token export is genuinely required, place it behind an explicit opt-in flag such as `--print-token`. 5. Display a security warning before any explicit token export and write it only to a caller-controlled secure channel. 6. Review logs and Agent transcripts created by previous executions and remove exposed credentials. 7. Revoke or rotate tokens that may already have been captured. A safer status implementation would be: ```javascript } else if (command === 'check') { if (manager.getSavedToken()) { console.log('authorized') process.exit(0) } console.log('unauthorized') process.exit(1) } ``` The normal authorization path should confirm success without returning the secret: ```javascript manager.authorize() .then(() => { console.log('Authorization completed successfully.') }) ``` ]]>
