T09 · Insecure Skill Coding Practices
- Location
SKILL.md:108- Finding
Access Token Exposed Through URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 108-124
Vulnerability Type: Sensitive credential exposure through URL query parameters
Risk Level: MediumVulnerable Code
python # 配置 API_BASE = "https://api.weixin.qq.com" ACCESS_TOKEN = "xxx" # 发布视频 def publish_video(title, video_url, cover_url): response = requests.post( f"{API_BASE}/channel/post", params={"access_token": ACCESS_TOKEN}, json={ "title": title, "media_video_url": video_url, "cover_url": cover_url } ) return response.json()Technical Analysis
The documented implementation transmits the WeChat access token as a URL query parameter. HTTPS protects the request while it is in transit, but URL query strings are commonly retained by application logs, reverse proxies, gateways, monitoring systems, debugging tools, and exception reports.
Authentication is necessary for the declared publishing functionality. However, exposing the credential in a URL exceeds the minimum safe disclosure necessary when the service supports an authorization header or another protected authentication mechanism. The example also provides no log-redaction, token-scoping, or rotation controls.
This finding applies to implementations that adopt the documented code. Whether an authorization header can replace the query parameter depends on the requirements of the specific official API endpoint.
Attack Path
- The Skill sends a publishing request containing
access_tokenin the query string. - An HTTP client, API gateway, proxy, monitoring service, or server records the complete request URL.
- An attacker or unauthorized operator obtains read access to those logs or diagnostic records.
- The attacker extracts the bearer token from the recorded URL.
- Before the token expires or is revoked, the attacker submits authenticated API requests usin ...[truncated 458 chars]
- The Skill sends a publishing request containing
- Remediation
View remediation
Remediation Suggestions
- Use an
Authorizationheader when supported by the official API:python headers = {"Authorization": f"Bearer {access_token}"} requests.post(endpoint, headers=headers, json=payload, timeout=30) - If the API requires a query-string token, configure all application, proxy, gateway, and monitoring layers to redact the
access_tokenparameter. - Never record complete request URLs, headers, or response bodies when they may contain credentials.
- Retrieve tokens from an encrypted credential store rather than source code or ordinary configuration files.
- Assign the narrowest available API scopes and use short-lived tokens where supported.
- Implement automatic expiration handling, rotation, and immediate revocation procedures.
- Add explicit network timeouts and validate that requests are sent only to an allowlisted official API hostname.
- Use an
