T09 · Insecure Skill Coding Practices
Warning
- Location
- monitor.js:21
- Finding
- Hard-Coded Feishu Recipient and Ignored Runtime Configuration<![CDATA[ ## Vulnerability Details **File Location**: `monitor.js:21-27`, `x-monitor.js:31-37`, `config.json:1-5`, `config.example.json:1-6` **Vulnerability Type**: Hard-coded destination and ineffective configuration **Risk Level**: Medium ### Vulnerable Code `monitor.js:21-27`: ```javascript targetUser: 'ou_c1bac9d5fa30ac354a3705a9c87993dd', // Notification channel channel: 'feishu' ``` `x-monitor.js:31-37`: ```javascript targetUser: 'ou_c1bac9d5fa30ac354a3705a9c87993dd', // Notification channel channel: 'feishu' ``` `config.json:1-5`: ```json { "checkIntervalSeconds": 30, "targetUser": "ou_c1bac9d5fa30ac354a3705a9c87993dd", "channel": "feishu" } ``` The queue destinations are constructed directly from the hard-coded values: ```javascript target: `user:${CONFIG.targetUser}`, ``` ### Technical Analysis Both monitoring scripts define a fixed Feishu open ID in source code. Neither script reads `config.json`, despite the documentation representing that file as the mechanism for selecting the recipient, channel, and polling interval. Consequently, changing `config.json` has no effect. Every announcement notification generated by `monitor.js` and every X notification generated by `x-monitor.js` contains the embedded recipient. The example configuration also contains the same real-looking identifier instead of a neutral placeholder, increasing the chance that users will deploy the Skill without noticing the fixed routing. This does not expose system credentials or grant operating-system privileges. However, it violates destination integrity and can cause notifications to be routed to an account that the deploying user did not authorize. ### Attack Path 1. A user installs the Skill and follows the documentation. 2. The user either leaves the example configuration unchanged or changes `targetUser` in `config.json`. 3. The monitoring scripts ignore that configuration and use the recipient embedded in source code. 4. `monitor.js` writes the fixed t ...[truncated 1286 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove all concrete recipient identifiers from source code and example files. 2. Replace the example value with an unmistakable placeholder such as `ou_xxxxxxxxxxxxxx`. 3. Load configuration once at startup and validate it before initiating network activity: ```javascript const configPath = path.join(__dirname, 'config.json'); const userConfig = JSON.parse(fs.readFileSync(configPath, 'utf8')); if ( typeof userConfig.targetUser !== 'string' || !/^ou_[A-Za-z0-9]+$/.test(userConfig.targetUser) ) { throw new Error('A valid Feishu targetUser must be configured explicitly'); } const CONFIG = { checkIntervalMs: Math.max( Number(userConfig.checkIntervalSeconds || 30) * 1000, 10000 ), targetUser: userConfig.targetUser, channel: userConfig.channel || 'feishu' }; ``` 4. Fail closed if the recipient is absent instead of silently using a built-in account. 5. Show the resolved recipient and request confirmation during first-time setup where practical. 6. Add automated tests proving that changes to `config.json` alter the generated queue target. 7. Keep deployment-specific `config.json` excluded from version control, as the existing `.gitignore` intends. ]]>
