T09 · Insecure Skill Coding Practices
- Location
scripts/upload-cover.js:8- Finding
Hardcoded WeChat Application Credentials
- Content
View full analysis
{ const req = https.get(`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${SECRET}`, res => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => { try { const result = JSON.parse(data); resolve(result.access_token); } catch (e) { reject(e); } }); }); req.on('error', reject); }); } ``` ### Technical Analysis The script embeds a WeChat AppID and application secret directly in source code. Anyone with access to the package can recover these values without needing access to the intended deployment environment. The script uses the credential to request an access token from the official WeChat API. If the embedded credential remains valid and the calling IP is authorized by the account configuration, the resulting token can be used to invoke API operations allowed to that WeChat application. Because the script executes `main()` automatically, invoking the file attempts to authenticate using the embedded account rather than requiring an explicitly configured user account. The script also prints the first 20 characters of the returned token at lines 86-87, unnecessarily exposing part of a bearer credential in terminal logs. ### Attack Path 1. An attacker obtains a copy of the Skill package or source repository. 2. The attacker extracts the embedded AppID and secret from `scripts/upload-cover.js`. 3. The attacker submits them to the WeChat token endpoint from an authorized network location. 4. If the credentials are valid, WeChat returns an access token. 5. The ...[truncated 610 chars]- Remediation
View remediation
