T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/test-local.js:3
- Finding
- Hard-Coded Xiaomi Device Authentication Token## Vulnerability Details **File Location**: `scripts/test-local.js:3-5` **Vulnerability Type**: Hard-coded credential **Risk Level**: High ```javascript const DEVICE_IP = '192.168.1.4'; const DEVICE_TOKEN = '3a8e11ebfb306f9d87e941c6b0f0e910'; const DEVICE_DID = '875218925'; ``` ### Technical Analysis The test script embeds a complete Xiaomi device token together with the corresponding device identifier and local IP address. The token is subsequently passed to `miHome.getDevice()` as an authentication credential. A real credential is not required for a reusable local connection test and should never be distributed in source code. Because the token is stored directly in the project, anyone who can read a copy of the repository, a source archive, a backup, or an Agent workspace can recover it without needing access to the Xiaomi account. Although exploitation generally requires network reachability to the purifier, the token eliminates the device authentication barrier once such reachability exists. ### Attack Path 1. An attacker obtains a copy of the project or reads `scripts/test-local.js`. 2. The attacker extracts the device IP, DID, and full authentication token. 3. The attacker gains access to the same LAN or otherwise obtains network reachability to the device. 4. The attacker creates a compatible MIIO/MIOT client using the disclosed values. 5. The attacker authenticates to the purifier and issues supported property-read or property-write operations. ### Impact Assessment An attacker with network reachability may authenticate as an authorized local client and monitor or control the identified purifier. Potential actions include reading environmental data and changing power, operating mode, fan level, brightness, buzzer, or child-lock settings. The direct scope is the device associated with the exposed token; the finding does not by itself establish Xiaomi account compromise or host-level code execution.
- Remediation
- ## Remediation Suggestions - Immediately revoke or rotate the exposed device token. - Remove the token, IP address, and DID from the source and repository history. - Replace them with clearly nonfunctional example values or accept them through protected runtime configuration. - Store runtime credentials in an operating-system credential manager or a user-private file with mode `0600`. - Ensure credential-bearing files are excluded from version control and build artifacts. - Add automated secret scanning to development and release workflows. - Avoid printing even partial tokens unless diagnostic output is explicitly enabled.
