T09 · Insecure Skill Coding Practices
- Location
scripts/poll-login-status.py:19- Finding
Authentication Credential Disclosed Through Standard Output
- Content
View full analysis
Vulnerability Details
File Location:
scripts/poll-login-status.py:19
Vulnerability Type: Sensitive authentication token exposure
Risk Level: HighVulnerable Code
python for i in range(max_polls): req = urllib.request.Request(url, headers=headers) with urllib.request.urlopen(req, timeout=40) as resp: data = json.loads(resp.read().decode()) print(time.strftime('%H:%M:%S'), json.dumps(data, ensure_ascii=False)) status = data.get('status') if status in ('confirmed', 'expired') or data.get('bot_token'): breakTechnical Analysis
The polling endpoint can return a
bot_tokencontaining an account identifier and secret after the user confirms the QR login. The script serializes and prints the complete response before testing whetherbot_tokenis present.Sending the QR session token to Tencent's documented status endpoint is necessary for the declared login workflow. Printing the returned authentication credential is not necessary. Standard output may be retained by agent transcripts, CI/CD logs, terminal capture systems, subprocess callers, or centralized monitoring. This creates a secondary disclosure channel for a reusable secret.
Attack Path
- A user invokes the polling script with a valid QR session token.
- The user scans and confirms the Weixin login request.
- Tencent's endpoint returns a response containing
bot_token. - The script prints the complete JSON response, including the token.
- An agent transcript, log collector, subprocess caller, or another party with output access captures the credential.
- An unauthorized party uses the exposed token wherever it is accepted to impersonate or operate the connected bot account.
Impact Assessment
Successful exploitation discloses an authentication secret associated with the connected Weixin bot. Depending on the token's server-side permissions and lifetime, an attacker may ...[truncated 292 chars]
- Remediation
View remediation
Remediation Suggestions
- Never print the complete status response when it may contain authentication material.
- Construct an explicit output object containing only non-sensitive fields, such as the status and a boolean indicating whether authentication succeeded.
- Redact
bot_token, account identifiers, and other sensitive response fields before logging. - Ensure exception handlers and debugging modes do not serialize the unredacted response.
- Document that users must not paste raw login responses or local account files into chats, tickets, or logs.
- Consider returning sensitive credentials only through a protected in-memory interface if downstream processing genuinely requires them.
Example hardening approach:
python safe_output = { 'status': data.get('status'), 'authenticated': bool(data.get('bot_token')), } print(time.strftime('%H:%M:%S'), json.dumps(safe_output))
