Back to skill

Security audit

feishu-weekly-report-merger

Security checks for vulnerabilities and agentic risk

Overview

This skill appears intended to merge Feishu weekly reports, but it handles sensitive document contents through predictable shared temporary files and does not fully disclose how it rewrites the merged output.

Review before installing. The skill is not clearly malicious, but it processes potentially sensitive Feishu report contents, writes them to predictable plaintext files in /tmp, and can create a new Feishu document. It should be changed to use a private per-run temporary directory or in-memory processing, delete only files it created, require explicit weekly-report intent, and accurately disclose that it reformats section structure.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • 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 (1)

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:28
Finding

Predictable Shared Temporary Files Expose Sensitive Feishu Documents

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 28–38
Vulnerability Type: Predictable and insecure temporary-file handling
Risk Level: Medium

Vulnerable Code

markdown
### Step 2:保存原文到临时文件

将每份文档的 `markdown` 字段原始内容写入独立临时文件:

/tmp/merge_doc_0.md ← 文档1原文 /tmp/merge_doc_1.md ← 文档2原文 /tmp/merge_doc_2.md ← 文档3原文 ...

text

**重要:写入时不做任何修改、不压缩、不总结,原文是什么就写什么。**

Related cleanup instructions in references/chapter_parsing.md, lines 54–59:

markdown
## 临时文件清理

合并完成后,AI 应清理临时文件:
```bash
rm -f /tmp/merge_doc_*.md
text

The script reads these caller-supplied paths in `scripts/merge.py`, lines 36–49:

```python
def merge(name_path_pairs: list[tuple[str, str]]) -> str:
    doc_parts_list: list[tuple[str, dict[int, str]]] = []
    for name, path in name_path_pairs:
        try:
            with open(path, encoding="utf-8") as f:
                text = f.read()
            parts = extract_parts(text)
            doc_parts_list.append((name, parts))
        except FileNotFoundError:
            print(f"警告:未找到文件 '{path}' (对应姓名: {name}),已跳过该文件。", file=sys.stderr)
            continue
        except Exception as e:
            print(f"警告:读取文件 '{path}' 时发生错误:{e},已跳过该文件。", file=sys.stderr)
            continue

Technical Analysis

The Skill directs the Agent to store the complete contents of potentially confidential weekly reports under deterministic names in the shared /tmp directory. It does not require a private per-run directory, atomic exclusive creation, restrictive permissions, symlink protection, ownership verification, or secure lifecycle management.

Predictable shared paths introduce several weaknesses:

  • A local attacker can anticipate the filenames and monitor or read them if their permissions allow it.
  • An attacker can pre-create a path as a symbolic link, potentially redirecting a naïve writer to another filesystem target.
  • A local process can replace or modify a temporary document before merge.py reads it ...[truncated 2608 chars]
Remediation
View remediation

Remediation Suggestions

  1. Create a unique private temporary directory for every run, for example with Python's tempfile.TemporaryDirectory(), and ensure its permissions are 0700.
  2. Create each temporary file atomically with exclusive creation and permissions no broader than 0600.
  3. Do not use deterministic names directly under the shared /tmp directory.
  4. Keep secure file handles open where practical rather than closing and reopening files by predictable paths.
  5. Reject symbolic links and non-regular files. Where supported, use O_NOFOLLOW, then verify file type, ownership, and permissions with fstat.
  6. Perform cleanup in a finally block or use a temporary-directory context manager so cleanup occurs after success, errors, and exceptions.
  7. Delete only the private per-run directory. Do not use rm -f /tmp/merge_doc_*.md, which can affect unrelated or concurrent runs.
  8. Avoid writing source documents to disk when possible. Pass content through protected standard input or perform parsing and merging in memory.
  9. Document the sensitivity and retention policy for fetched Feishu contents and ensure logs and error messages never include document bodies.
  10. Make the secure cleanup and file-creation requirements part of the primary workflow in SKILL.md, rather than relying on an optional reference document.
Vulnerability Patterns
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The skill description promises a tightly scoped Feishu document merger, but the documented behavior introduces broader local file handling and content transformation that are not clearly disclosed. This mismatch is dangerous because users and orchestrators may grant trust and permissions based on the declared purpose, while the implementation can process unintended inputs and alter document structure, increasing the risk of unauthorized data handling or misleading output.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
87% confidence
Finding

The skill instructs execution of a shell deletion command using a wildcard in a shared temporary directory. Even though the pattern appears intended for cleanup, shell-based file deletion can remove unintended files if naming collisions occur, if another process can create matching paths, or if the cleanup logic is reused unsafely in automation.

Content

Scanner excerpt · references/chapter_parsing.md (reported line 58)May include surrounding context.

合并完成后,AI 应清理临时文件:

bash
rm -f /tmp/merge_doc_*.md

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger phrases are generic enough to activate on routine document-editing requests outside the intended weekly-report use case. Over-broad activation can cause the skill to run in the wrong context, potentially pulling, merging, or exposing sensitive document contents when the user did not intend to invoke this specific workflow.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The module docstring states that multiple weekly reports are concatenated '原地拼接' and that all format tags are preserved without modification. In practice, the script rebuilds the output document, replaces source Part headers, trims some separators/newlines, and inserts new headings and dividers, contradicting the stated behavior.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The manifest says the skill should concatenate original report content without modification, summarization, and while preserving original formatting. However, the code normalizes every Part header to a fixed canonical form, strips original Part headers from each source section, and adds new ## 【name】 headings plus --- separators, which changes the document structure and formatting.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The skill reference content is written entirely in Chinese and includes operational guidance, naming rules, and error handling without indicating that the skill is China/Chinese-specific or offering any language opt-in. Under the stated policy, forcing a specific language without user choice can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

This markdown file explicitly tells the AI to remove files with rm -f /tmp/merge_doc_*.md, which is a destructive file operation. The section does not include any warning, confirmation step, or user-facing disclosure that temporary files will be deleted after processing.

Content

No source excerpt is available for this finding.