T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/auth.js:57
- Finding
- DingTalk Access Token Exposed Through Standard Output## Vulnerability Details **File Location**: `scripts/auth.js`, lines 57-61 **Vulnerability Type**: Plaintext sensitive token disclosure **Risk Level**: Medium **Vulnerable Code:** ```javascript if (require.main === module) { getAccessToken() .then(token => { console.log(JSON.stringify({ success: true, access_token: token })); ``` ### Technical Analysis When `auth.js` is executed directly, the script obtains a live DingTalk bearer token and writes the complete token to standard output. This disclosure is unnecessary for the normal operation of the other scripts, which import `getAccessToken()` and use the returned token internally. Standard output may be retained in AI Agent transcripts, CI/CD logs, process-management logs, terminal recordings, or diagnostic output. Because the token authenticates API requests, anyone who can read such retained output may be able to reuse it until it expires. No additional vulnerability is required once the token has been captured. ### Attack Path 1. An operator, Agent workflow, troubleshooting process, or automated task directly executes `node scripts/auth.js`. 2. The script reads the configured AppKey and AppSecret and requests a valid access token from DingTalk. 3. The complete access token is printed to standard output. 4. An attacker or unauthorized user with access to the transcript or log extracts the token. 5. The attacker submits the token to DingTalk API endpoints before it expires. 6. DingTalk authorizes operations according to the permissions granted to the associated internal application. ### Impact Assessment Successful exploitation permits temporary use of the DingTalk application's delegated API privileges. Depending on the application's configured scopes, the exposed token may enable access to employee information and reports, or permit report creation and related operations. The precise scope is constrained by the permissions assigned to the Ding ...[truncated 139 chars]
- Remediation
- ## Remediation Suggestions - Remove the direct-execution behavior that prints the token, or replace it with a message that only confirms successful authentication. - Keep access tokens exclusively in process memory and pass them directly to the API client. - If diagnostic output is necessary, redact the entire token rather than printing a partial reusable value. - Configure orchestration and CI systems to prevent secret-bearing output from being retained. - Review existing logs and Agent transcripts for previously exposed tokens, restrict access to those records, and rotate the associated application secret if exposure is suspected. - Grant the DingTalk application only the API scopes required for report management and user search.
