Back to skill

Security audit

Case Extraction

Security checks for vulnerabilities and agentic risk

Overview

This skill appears aimed at legitimate Chinese SPAS case-document creation, but its optional parser can silently leave cleaned chat contents in a predictable local text file.

Install only if you are comfortable giving the skill access to the chat or business materials you provide. Avoid running the parser on confidential chats in shared or untrusted folders, and remove '_cleaned_temp.txt' after use; ideally the publisher should make that file output explicit and opt-in.

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
scripts/parse_chat.py:172
Finding

Predictable Plaintext Output Enables Sensitive Data Disclosure and Symlink-Based File Overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/parse_chat.py, lines 172–175
Vulnerability Type: Predictable unsafe output file and plaintext retention
Risk Level: Medium

Vulnerable Code

python
# Save cleaned content to a temporary file
temp_path = os.path.join(os.path.dirname(file_path), '_cleaned_temp.txt')
with open(temp_path, 'w', encoding='utf-8') as f:
    f.write(cleaned)
print(f"\nCleaned content saved to: {temp_path}")

Technical Analysis

The parser unconditionally stores the complete cleaned conversation in a predictably named file, _cleaned_temp.txt, in the source file's directory. The file is not temporary despite its name: it is not automatically deleted, and no restrictive permissions are explicitly applied.

Opening the path in w mode silently truncates an existing file and follows symbolic links. No validation checks whether the destination already exists, is a symbolic link, or points outside the intended directory. This creates two related risks:

  1. Plaintext disclosure and retention: potentially sensitive personal or business conversations remain on disk after parsing.
  2. Symlink-based overwrite: if an attacker can prepare the input directory, the predictable destination can be created as a symbolic link to another file writable by the parser's user. The parser will then truncate and replace that target with cleaned conversation content.

The script's top-level output description states that it outputs parsed plaintext, but it does not disclose this persistent side effect.

Attack Path

  1. An attacker obtains write access to a directory from which a victim will parse a chat file, such as a shared extraction directory.
  2. The attacker creates _cleaned_temp.txt as a symbolic link to another file writable by the victim.
  3. The victim invokes parse_chat.py on a TXT or DOCX file in that directory.
  4. The parser derives the fixed _cleaned_temp.txt destination and opens it in w mode.
  5. The op ...[truncated 1204 chars]
Remediation
View remediation

Remediation Suggestions

  1. Do not persist parsed conversations by default. Return or print the cleaned data unless the user explicitly requests an output file.
  2. Require an explicit destination path through a command-line option and clearly document that sensitive plaintext will be written.
  3. Prevent silent replacement by opening new output files in exclusive creation mode (x) or requiring explicit overwrite confirmation.
  4. Reject symbolic links and non-regular files. Validate the destination with os.lstat() and, where supported, open it using low-level flags such as O_NOFOLLOW, O_CREAT, and O_EXCL.
  5. Use restrictive permissions, such as mode 0o600, so only the owning user can access the output.
  6. Use secure temporary storage when persistence is transient. Create files with Python's tempfile module in a trusted directory and delete them promptly.
  7. Avoid elevated execution. Run the parser with only the minimum user permissions required.
  8. Add tests covering pre-existing destinations, symbolic links, shared directories, permission handling, and cleanup behavior.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明的核心能力是将聊天记录或口述经验加工为结构化 Word 案例文档,这意味着应包含案例组织、文档生成,以及与 SPAS 方法论相关的结构化输出逻辑。但代码仅实现了文件读取、文本清洗、简单正则匹配的信息提取和保存清洗文本到临时 txt 文件,没有生成 Word 案例文档,也没有体现 SPAS 方法论步骤或完整案例编写能力。此外,声明提到支持口述经验输入,而该脚本只接受命令行文件路径作为输入。因此该代码与声明相比存在明显的主目的和能力缺口,属于描述与行为不匹配。

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill describes reading user files and writing output documents, but it does not declare any explicit tool scope or permission boundary. That creates a capability/authorization gap: an agent may perform filesystem actions without clear user-visible constraints, increasing the risk of unintended file access or writes beyond the expected task.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The description lists activation phrases such as “整理最佳实践” and “把这个经验结构化,” which are broad natural-language requests that could match everyday assistance rather than a narrowly scoped skill invocation. The file does not provide exclusion conditions or negative examples to clarify when the skill should not activate.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Several listed triggers, including “帮我萃取案例,” “整理一个最佳实践,” and “把这个经验结构化,” are semantically broad and could describe many generic writing or summarization tasks. The section specifies examples but does not define non-matching cases, required context, or constraints that would prevent unintended invocation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill states that output will be written to a fixed local path, but it does not warn the user near that operation that their extracted content will be stored locally. Because the input may contain chat logs or orally provided business experience, this can expose sensitive or personal data through unexpected local persistence.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The final output step instructs the agent to generate a Word document containing extracted user content and save it to a fixed directory, but it omits explicit notice about storage, retention, and privacy implications. In the context of chat-record processing, this increases the risk of sensitive information being stored on disk without informed consent or proper handling.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The title and instructions are written as a prescriptive output template in Chinese, including guidance on what the final output should look like. There is no indication that users may choose another language or that the Chinese-only requirement is optional or context-limited, which creates a language policy concern.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script’s stated behavior is to parse and output chat text, but it also persists the cleaned chat content to disk as '_cleaned_temp.txt'. Because chat logs may contain sensitive personal or business data, this undocumented write creates an unnecessary data-at-rest exposure and can surprise users or downstream callers that expected in-memory/stdout-only processing.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script writes cleaned chat content to a local file without clear prior warning or consent, which is a privacy and data-handling risk. In the context of case extraction from user chats, the data is likely to include sensitive internal discussions, personal information, or confidential business details, making unintended local persistence more dangerous.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

SQP-3 applies to all file types and covers natural-language policy violations such as forcing a specific language without user opt-in. This markdown file presents all guidance exclusively in Chinese and does not indicate that the language is optional or justified by a region-specific purpose.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The module docstring and all visible user messages are written only in Chinese, which imposes a fixed language choice on users. Under the stated policy, forcing a specific language without offering a choice or documenting the locale constraint is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
99% confidence
Finding

The file-level documentation says the parser supports only '.txt' and '.docx' chat logs, but the code also accepts '.doc' extensions in the dispatch logic. This is an active inconsistency between documentation and behavior, not merely an omitted implementation detail.

Content

No source excerpt is available for this finding.