T09 · Insecure Skill Coding Practices
- Location
scripts/get_access_token.sh:33- Finding
WeChat AppSecret Exposed in Process Command-Line Arguments
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is mostly a straightforward WeChat draft helper, but it handles powerful account credentials and access tokens in ways that can expose them locally.
Review this before installing if the WeChat account matters. Use it only in a trusted local environment, avoid shell history or process telemetry that records command lines, restrict any credential file permissions, rotate secrets if exposed, and confirm article content and image paths before running the upload or draft scripts.
scripts/get_access_token.sh:33WeChat AppSecret Exposed in Process Command-Line Arguments
scripts/upload_image.sh:8WeChat Access Token Exposed During Image Upload
scripts/add_draft.sh:7WeChat Access Token Exposed During Draft Creation
声明的核心用途是撰写微信公众号文章并保存到草稿箱,但提供的代码片段仅是一个配置模板与操作说明,作用是让用户配置微信公众号 API 凭证(AppID、AppSecret)和 IP 白名单。该代码没有展示任何与文章内容生成、素材组装、调用微信草稿接口、上传草稿或发布相关的实现,因此其实际行为与声明用途存在明显不一致,属于实质性目的不匹配。
声明描述的是内容创作并保存到微信公众号草稿箱的能力,但代码片段实际只实现了认证准备步骤:读取配置中的 AppID/AppSecret,向微信 token 接口请求 access_token,并处理错误情况。这属于微信公众号 API 鉴权/凭证获取功能,而不是文章代写或草稿保存功能。虽然获取 token 可能是后续发布草稿的支持步骤,但当前代码块本身没有任何文章内容处理、草稿箱接口调用、媒体上传或草稿创建逻辑,因此与声明的主要用途存在明显不匹配。
The declared description says the skill writes公众号 articles and saves them to the WeChat draft box. The supplied code does neither article generation nor draft creation. Its sole function is uploading an image file to WeChat's permanent material store and obtaining a media_id. While image upload could be a supporting step for article publishing, this chunk's primary purpose is materially different from the declared end-user function, and the described capability is not accurately represented by this code.
The skill explicitly handles sensitive WeChat credentials and access tokens, which are high-value secrets that can enable content publication and API access if exposed through logs, command output, shell history, or insecure script handling. In an agent setting, token retrieval via shell scripts materially increases the risk of credential leakage or misuse.
./scripts/get_access_token.sh
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
| 接口 | 路径 | 说明 |
|------|------|------|
| 获取 Access Token | `/cgi-bin/token` | 获取接口调用凭证 |
| 上传永久素材 | `/cgi-bin/material/add_material` | 上传封面图片等素材 |
| 新增草稿 | `/cgi-bin/draft/add` | 保存文章到草稿箱 |
| 获取草稿列表 | `/cgi-bin/draft/batchget` | 获取草稿列表 |
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
| 接口 | 路径 | 说明 |
|------|------|------|
| 获取 Access Token | `/cgi-bin/token` | 获取接口调用凭证 |
| 上传永久素材 | `/cgi-bin/material/add_material` | 上传封面图片等素材 |
| 新增草稿 | `/cgi-bin/draft/add` | 保存文章到草稿箱 |
| 获取草稿列表 | `/cgi-bin/draft/batchget` | 获取草稿列表 |
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
#!/bin/bash
# 获取微信公众号 Access Token
# 使用方法:./get_access_token.sh
set -e
The skill documents shell-based execution (./scripts/...) but does not declare any tool scope such as permissions or allowed-tools. This creates an authorization gap where an agent may execute shell commands without explicit user-visible restriction, increasing the chance of unintended command execution or unsafe script use.
The trigger phrases are broad enough to activate on ordinary requests about WeChat articles, increasing the chance that the skill engages shell/API actions in contexts where the user only wanted advice or editing help. In an agent environment, overbroad invocation can lead to unintended external operations with configured credentials.
This markdown file documents a request that includes appid and secret in the query string, which involves sensitive credentials. The surrounding documentation does not warn users not to expose, log, or commit these values, so the description omits a privacy/security warning for credential-handling behavior.
This hardcoded external endpoint causes the skill to send content outside the local environment to the WeChat API. In the context of a skill that drafts and uploads public account articles, this is expected behavior, but it remains security-relevant because any sensitive or regulated content passed to the script will leave the system and be stored by a third party.
}')
# 调用 API
RESPONSE=$(curl -s -X POST "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d "$JSON")
This hardcoded external endpoint causes the skill to send content outside the local environment to the WeChat API. In the context of a skill that drafts and uploads public account articles, this is expected behavior, but it remains security-relevant because any sensitive or regulated content passed to the script will leave the system and be stored by a third party.
}')
# 调用 API
RESPONSE=$(curl -s -X POST "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d "$JSON")
This shell script contains user-facing comments and runtime messages exclusively in Chinese, including usage instructions and error guidance. That forces a specific language/locale without any opt-in or indication that the skill is intentionally limited to Chinese-speaking users, which matches the policy-violation criteria.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
fi
# 调用微信 API
RESPONSE=$(curl -s "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${APPSECRET}")
# 检查是否成功
if echo "$RESPONSE" | grep -q '"access_token"'; then
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
fi
# 调用微信 API
RESPONSE=$(curl -s "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${APPSECRET}")
# 检查是否成功
if echo "$RESPONSE" | grep -q '"access_token"'; then
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
fi
# 调用微信 API
RESPONSE=$(curl -s "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${APPSECRET}")
# 检查是否成功
if echo "$RESPONSE" | grep -q '"access_token"'; then
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
fi
# 调用微信 API
RESPONSE=$(curl -s "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${APPSECRET}")
# 检查是否成功
if echo "$RESPONSE" | grep -q '"access_token"'; then
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
fi
# 调用微信 API
RESPONSE=$(curl -s "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${APPSECRET}")
# 检查是否成功
if echo "$RESPONSE" | grep -q '"access_token"'; then
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
fi
# 调用微信 API
RESPONSE=$(curl -s "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${APPSECRET}")
# 检查是否成功
if echo "$RESPONSE" | grep -q '"access_token"'; then
This template forces a single language for all instructions and warnings, which may violate language or locale policy when users are not given an opt-in or alternative. No text indicates that the skill is region-specific or intentionally limited to Chinese-speaking users.
The comments and runtime output strings are written in Chinese throughout the script, which effectively forces a single language for user interaction. There is no indication that the tool is intentionally limited to Chinese-speaking users or that an alternate language is available.
This shell script performs an HTTP upload of a user-supplied file to the WeChat API and includes the access token in the request URL. Although the script logs that an upload is happening, it does not warn the user that local file contents and credentials will be transmitted to an external service.
No suspicious patterns detected.