T09 · Insecure Skill Coding Practices
- Location
src/tools/token.py:9- Finding
Live WeChat Bearer Token Exposed Through an MCP Tool
- Content
View full analysis
dict: """Get WeChat Access Token. Access token is required for all other API calls. It is automatically cached and refreshed when expired. Args: force_refresh: Force refresh token even if current one is valid. Returns: dict: Contains access_token and expires_in seconds. """ api = get_api() token = api.get_access_token(force_refresh=force_refresh) return { "access_token": token, "expires_in": 7200, "message": "Token retrieved successfully. Valid for 2 hours.", } ``` The documentation also instructs users to print the complete token at `SKILL.md:72`: ```bash python -c "from src.wechat_api import WeChatAPI; api = WeChatAPI(); print(api.get_access_token())" ``` ### Technical Analysis The `get_access_token` MCP tool returns a live WeChat bearer token directly to its caller. This exceeds the minimum privileges required by the Skill because all other tools obtain and cache the token internally through `get_api()` and do not require callers to possess it. Returning the credential through MCP can place it in model context, conversation transcripts, client telemetry, tool-call logs, debugging output, or other storage outside the credential boundary. The instruction in `SKILL.md` further increases exposure by printing the complete token to standard output. The token is valid for approximately two hours and grants the bearer the WeChat API permissions associated with the configured Official Account. ### Attack Path 1. An MCP client, Agent, or user invokes `get_access_token`. 2. The Skill retrieves the account token using the configured AppID and AppSecret. 3. The complete bearer token is returned in the MCP response ...[truncated 802 chars]- Remediation
View remediation
