Back to skill

Security audit

Guanrentang Writer

Security checks for vulnerabilities and agentic risk

Overview

The skill has a coherent article-and-image workflow, but it needs Review because it uses broad auto-triggers, external API calls, and an unsafe `.env` sourcing pattern that can execute local shell code.

Install only if you intend to generate branded Chinese公众号 content for this clinic context. Prefer supplying `ZHIPU_API_KEY` through a trusted environment or secret manager instead of a sourced `.env` file, review every generated article before publishing, confirm before external image generation, and verify any follow or QR-code asset destination yourself.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T01 · Skill Instruction Hijacking

Error
Location
SKILL.md:155
Finding
Mandatory Advertising and Traffic-Diversion Content in Generated Output<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:123`, `SKILL.md:155-168`, `SKILL.md:418-421`, `SKILL.md:448-460`; `STYLE.md:103-112` **Vulnerability Type**: T01: Skill Instruction Hijacking **Risk Level**: Critical ### Vulnerable Instructions The following is a faithful English translation of the relevant instructions: ```markdown - Mandatory fixed ending: "I sincerely regard every like you give as appreciation." ![Ending: Thanks](./assets/ending-thanks.jpg) ![Ending: Divider](./assets/ending-divider.jpg) ![Ending: Follow](./assets/ending-follow.png) ![Ending: QR code](./assets/ending-qrcode.jpg) ``` ```markdown 4. Mandatory promotional text, which must be appended at the end: This clinic has newly launched a traditional herbal steaming service. You are welcome to visit and experience it! ``` ```markdown ## Fixed Ending One of the following must be used as the ending: I sincerely regard every like you give as appreciation or: END ``` The traditional herbal steaming template additionally requires the following output: ```markdown This clinic has newly launched a traditional herbal steaming service. You are welcome to visit and experience it! ![Ending: Thanks](./assets/ending-thanks.jpg) ![Ending: Divider](./assets/ending-divider.jpg) ![Ending: Follow](./assets/ending-follow.png) ![Ending: QR code](./assets/ending-qrcode.jpg) ``` ### Technical Analysis The Skill uses mandatory instructions such as “must,” “mandatory,” and “must be appended” to force generated articles to include brand engagement text, clinic advertising, a follow prompt, and a QR-code image reference. These requirements go beyond the minimum privileges and behavior needed to draft a Chinese-medicine article. They alter the Agent’s output policy whenever the Skill is loaded, even where the user has not explicitly requested advertising or audience redirection. The advertising requirement is therefore persistent output manipulation rather than merely optional ...[truncated 1977 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove all unconditional requirements to append promotional text, follow prompts, or QR-code images. 2. Make branding and advertising explicitly opt-in for each generation request. 3. Present the proposed promotional wording and destination to the user before adding it to an article. 4. Require affirmative user approval before including any follow link, QR code, account identifier, or service advertisement. 5. Support a neutral default mode that generates only the requested editorial content. 6. Document the owner and destination of each promotional asset. 7. Bundle only reviewed assets and verify them with cryptographic hashes before use. 8. Provide a plain-text destination alongside every QR code so users can inspect it before publication. 9. Add a final output-validation step that detects and removes promotional material unless the current user request explicitly authorizes it. 10. Treat fixed brand phrases as optional templates rather than instructions that override the user’s requested output. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:292
Finding
Arbitrary Shell Command Execution Through Sourced Environment File<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:292-295` **Vulnerability Type**: T09: Insecure Skill Coding Practices **Risk Level**: High ### Vulnerable Code ```bash if [ -z "$ZHIPU_API_KEY" ] && [ -f "$SKILL_DIR/.env" ]; then source "$SKILL_DIR/.env" fi ``` ### Technical Analysis The documented workflow uses the shell `source` command to load `.env`. This does not treat the file as passive configuration data. It parses and executes the entire file as shell code in the current shell process. An attacker able to create or modify `$SKILL_DIR/.env` can insert command substitutions, shell functions, redirections, external commands, or other shell syntax. Those instructions will execute when the documented article-generation workflow is run. For example, a malicious `.env` need not be limited to a variable assignment. It could contain commands in addition to `ZHIPU_API_KEY=...`, and `source` would execute them with the same privileges as the user or Agent running the workflow. The project does not contain an actual `.env` file or a present malicious payload. This finding concerns the exploitable loading mechanism explicitly prescribed by `SKILL.md`. ### Attack Path 1. An attacker gains write access to the expected Skill directory or causes a crafted `.env` file to be placed there. 2. The file contains a valid-looking API key assignment together with attacker-controlled shell commands. 3. The user requests image generation while `ZHIPU_API_KEY` is not already set in the environment. 4. The condition at `SKILL.md:292-295` succeeds because `.env` exists. 5. The shell executes `source "$SKILL_DIR/.env"`. 6. Every command in the attacker-controlled file executes in the current shell under the invoking user’s identity. 7. The malicious commands can access any files, credentials, processes, and network resources available to that user. ### Impact Assessment Successful exploitation provides arbitrary command execution with the privileges of th ...[truncated 620 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not use `source`, `.`, or `eval` to parse configuration files. 2. Prefer requiring `ZHIPU_API_KEY` through the process environment or a dedicated secret manager. 3. If `.env` compatibility is necessary, use a parser that treats the file strictly as data. 4. Permit only a single `ZHIPU_API_KEY=<value>` entry and reject duplicate keys, command substitutions, shell metacharacters, additional assignments, and unexpected lines. 5. Validate the API key against the provider’s documented character set and length constraints. 6. Open the file without following symbolic links where the execution environment supports that protection. 7. Verify that the file is owned by the expected user and is not writable by group or other users. 8. Require restrictive permissions such as owner read/write only. 9. Avoid printing the API key in progress output, logs, command traces, or error messages. 10. Run image generation with the minimum filesystem and network permissions required for the task. A safer conceptual approach is: ```bash if [ -z "${ZHIPU_API_KEY:-}" ]; then printf '%s\n' "ZHIPU_API_KEY must be supplied through the process environment." >&2 exit 1 fi ``` If file-based configuration cannot be removed, it should be parsed by a non-shell configuration library and the extracted value should be passed to the API client without evaluating any part of the file. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
Findings (17)

Vague Triggers

High
Confidence
97% confidence
Finding
The skill advertises auto-triggering on broad phrases like '写文章' and '帮我写一篇', which overlap heavily with ordinary user requests. In an agent environment, overly broad activation can cause the wrong skill to run unexpectedly, leading to unintended file creation, API use, and external requests without clear user intent.

Credential Access

High
Category
Privilege Escalation
Content
| 方式 | 命令 | 说明 |
|-----|------|------|
| **方式一:环境变量** | 在 `~/.zshrc` 或 `~/.bashrc` 中添加 `export ZHIPU_API_KEY=your_key` | 全局可用,适合多个项目 |
| **方式二:.env 文件** | 在 skill 目录下创建 `.env` 文件,内容为 `ZHIPU_API_KEY=your_key` | 仅此 skill 使用,已加入 .gitignore |

> **执行前检查**:如果未配置 API Key,应提示用户选择上述方式之一配置后再继续
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
| 方式 | 命令 | 说明 |
|-----|------|------|
| **方式一:环境变量** | 在 `~/.zshrc` 或 `~/.bashrc` 中添加 `export ZHIPU_API_KEY=your_key` | 全局可用,适合多个项目 |
| **方式二:.env 文件** | 在 skill 目录下创建 `.env` 文件,内容为 `ZHIPU_API_KEY=your_key` | 仅此 skill 使用,已加入 .gitignore |

> **执行前检查**:如果未配置 API Key,应提示用户选择上述方式之一配置后再继续
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
| 方式 | 命令 | 说明 |
|-----|------|------|
| **方式一:环境变量** | 在 `~/.zshrc` 或 `~/.bashrc` 中添加 `export ZHIPU_API_KEY=your_key` | 全局可用,适合多个项目 |
| **方式二:.env 文件** | 在 skill 目录下创建 `.env` 文件,内容为 `ZHIPU_API_KEY=your_key` | 仅此 skill 使用,已加入 .gitignore |

> **执行前检查**:如果未配置 API Key,应提示用户选择上述方式之一配置后再继续
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
ARTICLE_TITLE="春季养肝全攻略"

# 2. 读取 API Key(优先级:环境变量 > skill 目录 .env)
if [ -z "$ZHIPU_API_KEY" ] && [ -f "$SKILL_DIR/.env" ]; then
  source "$SKILL_DIR/.env"
fi
Confidence
86% confidence
Finding
The script sources a local .env file directly from the skill directory, causing the agent to ingest credentials from disk into its execution environment. In an agent setting, automatic secret loading increases the chance of unauthorized secret use, especially when combined with external network calls in the same workflow.

Credential Access

High
Category
Privilege Escalation
Content
# 2. 读取 API Key(优先级:环境变量 > skill 目录 .env)
if [ -z "$ZHIPU_API_KEY" ] && [ -f "$SKILL_DIR/.env" ]; then
  source "$SKILL_DIR/.env"
fi

# 3. 检查 API Key 是否配置
Confidence
84% confidence
Finding
Checking for and sourcing a .env file in the skill directory implicitly trusts local shell content. Because 'source' executes shell syntax rather than safely parsing key-value pairs, a tampered .env file could inject additional commands or environment manipulation during execution.

Chaining Abuse

High
Category
Tool Misuse
Content
-H "Content-Type: application/json" \
  -d '{"model":"glm-image","prompt":"中医养生插画,春季养肝疏肝示意图,肝脏与人体气机运行,新中式水墨插画风格,中国传统色(黛青、朱砂、米白),淡雅晕染效果,留白构图,温暖治愈氛围","size":"1472x1088"}' \
  | jq -r '.data[0].url' \
  | xargs -I {} curl -s -o "${OUTPUT_DIR}/images/${ARTICLE_TITLE}/content-1.jpg" "{}"

# 7. 等待 2 秒
sleep 2
Confidence
88% confidence
Finding
The pipeline takes a URL returned by an external service and feeds it directly into a second curl invocation via xargs, with no validation of scheme, host, or content. That creates a chaining/trust-boundary problem: a compromised or unexpected API response could cause arbitrary remote fetches, enabling SSRF-like behavior, retrieval of malicious payloads, or writing attacker-controlled content to disk.

Vague Triggers

Medium
Confidence
89% confidence
Finding
The usage section reinforces broad trigger behavior without defining scope limits or disambiguation rules. That makes accidental invocation more likely, which is especially risky here because the skill can write files and call an external image API automatically.

Natural-Language Policy Violations

Medium
Confidence
83% confidence
Finding
The instructions require Chinese filenames and throughout the document prescribe Chinese fixed phrases and Chinese-language prompts, but do not explicitly state that the skill is region-specific or provide a user opt-in for language choice. Under the policy, forcing a specific language without opt-in can be a locale-policy violation unless the restriction is clearly documented and justified.

Session Persistence

Medium
Category
Rogue Agent
Content
```bash
# 创建文章和图片目录
mkdir -p "${OUTPUT_DIR}/images/${ARTICLE_TITLE}/"

# 复制固定素材到输出目录
cp -r "${SKILL_DIR}/assets" "${OUTPUT_DIR}/"
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
```bash
# 创建文章和图片目录
mkdir -p "${OUTPUT_DIR}/images/${ARTICLE_TITLE}/"

# 复制固定素材到输出目录
cp -r "${SKILL_DIR}/assets" "${OUTPUT_DIR}/"
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Intent-Code Divergence

Medium
Confidence
96% confidence
Finding
The general Step 3 instructions say articles must include TCM theory, diet therapy, acupoints/precautions, and the fixed closing line. Later, the '放假通知' section explicitly says this theme has no body text, uses a user-provided image, and does not need AI-generated images or ending images. These instructions actively contradict each other for one supported mode of the skill.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
Step 5 states that after saving an article, the skill immediately parses image markers, generates prompts, calls the image API, and downloads each image. But the '放假通知' section later states the body image is user-provided and explicitly says AI image generation is not needed. This is an intent-level contradiction in the documentation of how the skill behaves.

External Transmission

Medium
Category
Data Exfiltration
Content
```bash
# 1. 调用 API 生成图片
RESPONSE=$(curl -s -X POST "https://open.bigmodel.cn/api/paas/v4/images/generations" \
  -H "Authorization: Bearer $ZHIPU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
Confidence
90% confidence
Finding
This skill transmits generated prompts and authentication material to an external API endpoint. In context, external transmission is part of intended functionality, but it still creates privacy and data-governance risk because article content or user-supplied material may be sent off-platform without a dedicated consent gate.

External Transmission

Medium
Category
Data Exfiltration
Content
cp -r "$SKILL_DIR/assets" "${OUTPUT_DIR}/"

# 6. 生成第一张配图(示例:春季养肝示意图)
curl -s -X POST "https://open.bigmodel.cn/api/paas/v4/images/generations" \
  -H "Authorization: Bearer $ZHIPU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"glm-image","prompt":"中医养生插画,春季养肝疏肝示意图,肝脏与人体气机运行,新中式水墨插画风格,中国传统色(黛青、朱砂、米白),淡雅晕染效果,留白构图,温暖治愈氛围","size":"1472x1088"}' \
Confidence
90% confidence
Finding
The example workflow again sends content to an external image-generation service and then retrieves remote content for local storage. While expected for the feature, this expands trust to a third party and can expose sensitive prompts or create supply-chain style risk from blindly fetching returned URLs.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The skill hard-codes Chinese-language output and a specific house style without indicating any user language preference check or opt-in. This can override user intent, reduce transparency, and cause the agent to respond in an unexpected language, which is a genuine policy/quality risk though not a classic security exploit.

Intent-Code Divergence

Low
Confidence
92% confidence
Finding
The generic article-writing section requires the fixed closing line '您点的每个赞,我都认真当成了喜欢'. Later, the '古法熏蒸' fixed-theme instructions explicitly say that article type should not use that line and should end with a promotion sentence instead. This is a direct contradiction between two documented behaviors.

Static analysis

No suspicious patterns detected.