T09 · Insecure Skill Coding Practices
- Location
scripts/config_json.py:17- Finding
API Credentials Stored in a Plaintext Configuration File
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This image-generation skill mostly does what it says, but it should be reviewed because it stores API keys in plaintext and downloads provider-returned image URLs without validation.
Review before installing. Use provider keys with limited quota, avoid committing or sharing scripts/config.json, consider environment variables or a secure secret store instead, and be aware that prompts are sent to NVIDIA or SiliconFlow and generated files remain on disk. The SiliconFlow downloader should ideally validate HTTPS image hosts, set timeouts and size limits, and verify downloaded content before saving.
scripts/config_json.py:17API Credentials Stored in a Plaintext Configuration File
scripts/siliconflow_main.py:69Unvalidated Image URL Retrieved from an External API Response
The declared purpose centers on AI image generation through specific external APIs, but the actual code only performs local setup by requesting and storing API keys. This is a materially different primary purpose from the declared image-generation functionality. While configuration may support such a tool, this code chunk itself does not implement the described behavior at all.
The core purpose mostly aligns: the code does generate an image from a text prompt using the NVIDIA API and returns a local image path. However, the description materially overstates supported backends and models. This chunk implements only NVIDIA access, not SiliconFlow, and the main entrypoint uses only flux.2-klein-4b rather than demonstrating the broader model support claimed. The phrase-based invocation trigger is also absent here, though that may belong to a higher-level dispatcher. There is no evidence of unrelated or dangerous hidden behavior beyond saving debug output locally. Overall this is a partial mismatch due to overstated supported APIs/models versus actual implemented behavior in the supplied code.
代码的核心功能与声明的大方向一致,都是根据提示词调用图像生成服务并返回本地图片路径。但声明描述了同时支持 NVIDIA NIM API 和 SiliconFlow API,而该代码块只实现了 SiliconFlow 的 /v1/images/generations 调用,没有任何 NVIDIA NIM 相关逻辑。此外,声明列出 flux.2-klein-4b 等模型支持,但代码中只明确提到和默认支持 Kwai-Kolors/Kolors 与 Qwen/Qwen-Image,没有看到对 flux.2-klein-4b 的专门支持说明。未发现与图像生成无关的额外高风险能力;不匹配主要在于声明的支持范围大于实际实现。
The skill documentation describes network access, local file writes, and configuration file handling, but the manifest shown in SKILL.md does not declare any explicit tool scope or permissions boundary. In an agent environment, missing scope declarations can cause overbroad execution or make reviewers unaware that the skill will access the filesystem and external APIs.
The trigger language includes broad catch-all phrasing like similar expressions, which can cause the skill to activate on vague user requests and send prompts to external image APIs unexpectedly. In an agent setting, overbroad invocation increases the chance of unintended network use, cost incurrence, and local file creation.
The parameter descriptions specify base_str as a Chinese prompt for both backends, which imposes a language requirement in the skill documentation. This is a natural-language policy concern because it forces a specific language without user opt-in or a documented, justified locale limitation.
The README states that generated images are written to a local path but does not warn users that invoking the skill creates persistent files on disk. In shared or sensitive environments, silent file creation can leak prompts, consume storage, or leave artifacts that users did not expect.
The documentation instructs users to store API keys in a local config.json file without any warning about credential exposure, file permissions, or safer alternatives. Plain local secret storage is risky because keys may be read by other processes, accidentally committed, or exfiltrated through unrelated file access.
The script collects API keys and stores them directly in a local config.json file in plaintext, without warning the user about sensitivity or applying any access controls. If the file is read by other local users, accidentally committed to source control, or exposed through backups/logging, the credentials can be reused to access paid external image-generation APIs.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"steps": 4
}
try:
response = requests.post(invoke_url, headers=headers, json=payload)
response.raise_for_status()
except requests.exceptions.HTTPError as e:
print(f"进行尝试重启中...HTTP错误: {e}")
This code sends the user-provided prompt to an external NVIDIA API using an Authorization bearer token, which is a network operation involving user data and credentials. While the script prints status messages after failures and file saves, it does not provide any prior user-facing warning, confirmation, or explanatory comment/docstring about transmitting prompts to a third-party service.
The file’s user-facing errors, docstrings, status messages, and command-line usage are written only in Chinese, such as the configuration errors and usage/help text. This imposes a specific language on users and calling agents without any opt-in or documented locale constraint, which matches the language/locale policy violation criteria.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
raise ValueError("配置文件 config.json 至少应该存在SiliconFlow API Key配置,请运行 config_json.py 创建配置文件")
def post_gui(payload,key):
url = "https://api.siliconflow.cn/v1/images/generations"
try:
headers = {
"Authorization": key,
The natural-language comments, prompts, and status messages are all fixed to Chinese, which imposes a specific language on users without opt-in. Under the policy, locale or language constraints should be optional or clearly documented and justified.
The script reads an API key from config.json and uses it for authenticated external requests. Although this is functionally necessary, there is no visible warning or explanatory comment/docstring informing users that the skill accesses stored credentials.