Back to skill

Security audit

文件快速扫描 - 减少token消耗

Security checks for vulnerabilities and agentic risk

Overview

This skill mostly behaves like a local project indexer, but it needs Review because it can automatically scan and write project indexes for future agent context and can include untrusted file text there.

Review before installing. Use this only on projects you are comfortable indexing locally, avoid startup auto-refresh on untrusted repositories, inspect generated `.anatomy.md` before letting an agent rely on it, and do not use `--scan-downloads` unless you want recent personal Downloads metadata included. I found no evidence of network exfiltration, credential harvesting, destructive actions, or OS-level persistence.

Vulnerability Patterns
  • 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
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (1)

T01 · Skill Instruction Hijacking

Warning
Location
scripts/anatomy_scan.py:45
Finding
Untrusted Project Content Is Injected into Agent Session Context<![CDATA[ ## Vulnerability Details **File Location**: `scripts/anatomy_scan.py:45-99, 170-172`; `scripts/anatomy_inject.py:63-65`; `SKILL.md:61-69` **Vulnerability Type**: T01: Skill Instruction Hijacking **Risk Level**: Medium ### Vulnerable Code From `scripts/anatomy_scan.py:45-99`, descriptions are extracted directly from project-controlled file contents: ```python def extract_description(filepath: Path, max_chars: int = DEFAULT_DESC_CHARS) -> str: """Extract a one-line description from file content.""" try: with open(filepath, 'r', encoding='utf-8', errors='ignore') as f: lines = [] for i, line in enumerate(f): if i >= 30: # only scan first 30 lines break lines.append(line) except (OSError, UnicodeDecodeError): return '' text = ''.join(lines) desc = '' # Python docstring if filepath.suffix == '.py': for marker in ('"""', "'''"): idx = text.find(marker) if idx != -1: end = text.find(marker, idx + 3) if end != -1: desc = text[idx+3:end].strip().split('\n')[0] break # JS/TS first comment or export elif filepath.suffix in ('.js', '.ts', '.jsx', '.tsx', '.mjs'): for line in lines: stripped = line.strip() if stripped.startswith('//'): desc = stripped.lstrip('/ ').strip() break elif stripped.startswith('/**'): desc = stripped.lstrip('/* ').rstrip('* /').strip() break elif stripped.startswith('export'): desc = stripped[:max_chars] break # Markdown heading elif filepath.suffix in ('.md', '.mdx'): for line in lines: if line.startswith('#'): desc = line.lstrip('# ').strip() break # Shell script comment elif filepath. ...[truncated 3985 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Treat all extracted repository content as untrusted data and explicitly label the generated section accordingly, including a directive that descriptions must never be interpreted as instructions. 2. Prefer deterministic descriptions derived from file paths, extensions, syntax metadata, or locally defined templates rather than copying arbitrary prose from source files. 3. If content extraction remains necessary, detect and reject instruction-like phrases, tool requests, role declarations, and attempts to override previous instructions. Filtering should be defense in depth rather than the sole control. 4. Place extracted descriptions inside a strongly delimited data structure, such as JSON with explicit fields, and ensure the consuming Agent is instructed to parse those fields only as repository metadata. 5. Escape Markdown metacharacters, control characters, bidirectional Unicode controls, and formatting constructs before writing descriptions. This reduces presentation-layer manipulation, although it does not by itself prevent semantic prompt injection. 6. Separate index generation from automatic context injection. Require an explicit trust decision before adding an index generated from an unfamiliar repository to Agent context. 7. Update the startup instructions to state that `.anatomy.md` is attacker-controllable when generated from an untrusted project and must not override system, developer, user, or safety instructions. 8. Add security tests using malicious first-line comments, headings, and docstrings to verify that instruction-like content is rejected, neutralized, or clearly represented only as untrusted data. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (12)

Tp2

High
Category
MCP Tool Poisoning
Confidence
85% confidence
Finding
Mixing characters from multiple Unicode scripts in a single identifier is a common technique to create visually ambiguous tool names.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the static finding is accurate, the documented purpose materially understates behavior by omitting unrelated scanning, structured data extraction, and report writing outside a simple project anatomy use case. Behavior-description mismatch is dangerous because users may authorize the skill for low-risk indexing while it actually processes unrelated files (including `~/Downloads`) and extracts potentially sensitive business data.

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill advertises shell, file-read, and file-write behavior but does not declare any explicit tool scope or permissions boundaries. In practice, this makes a startup-integrated skill more dangerous because it can read project files and write `.anatomy.md` automatically without clear least-privilege constraints or user visibility.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill explicitly describes automatic session-startup scanning and writing `.anatomy.md`, but does not prominently warn that this modifies the filesystem. Automatic writes at startup are risky because they can change repositories, create noisy diffs, overwrite expected state, or expose indexed file metadata without the user's informed consent.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
'--format', args.format,
            '--incremental',
        ]
        result = subprocess.run(cmd, capture_output=True, text=True)
        if not args.quiet and result.stdout:
            print(result.stdout, file=sys.stderr)
        if result.returncode != 0:
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Description-Behavior Mismatch

Medium
Confidence
96% confidence
Finding
The script's actual behavior is narrowly tailored to reimbursement artifacts and extracts sensitive expense metadata from filenames, which materially differs from the declared 'general file quick scan/project anatomy' purpose. This kind of scope mismatch is dangerous because users may grant or run it expecting a generic indexer while it instead performs domain-specific processing of financial records, increasing the chance of unanticipated access to private data.

Context-Inappropriate Capability

Medium
Confidence
97% confidence
Finding
The optional Downloads scan reaches outside the user-supplied expense directory into ~/Downloads, which is unrelated to the stated project/file-scan function and broadens data access to a common location for sensitive personal files. Even though it is gated by a flag, it can expose filenames, timestamps, and sizes for unrelated documents, creating an unnecessary privacy and scope-expansion risk.

Vague Triggers

Medium
Confidence
88% confidence
Finding
The trigger phrase at line 23 uses common project-scanning terminology that is likely to overlap with normal user requests. Overly broad triggers can cause unintentional activation, pulling the agent into this skill in contexts where the user did not explicitly intend it, which can lead to unnecessary file enumeration or disclosure of project structure.

Vague Triggers

Medium
Confidence
83% confidence
Finding
The trigger phrase at line 25 is ambiguous and not sufficiently specific to this skill's function. Ambiguous activation increases the chance the skill will run unexpectedly, which is especially risky here because the skill is designed to inspect project files and summarize their contents without opening them explicitly in the main flow.

Description-Behavior Mismatch

Low
Confidence
79% confidence
Finding
The manifest emphasizes quickly scanning files so the AI can know contents without repeated reads, which suggests read-oriented indexing behavior. This implementation persists a new '.anatomy.md' report (or arbitrary output path), adding a file-creation side effect not conveyed in the manifest description.

Missing User Warnings

Low
Confidence
88% confidence
Finding
The script writes to either a user-specified path or a default .anatomy.md without checking for existing files or warning before overwrite. This can lead to accidental loss of local data or clobbering of prior reports, especially when run repeatedly or pointed at an existing output path.

Natural-Language Policy Violations

Low
Confidence
75% confidence
Finding
The summary and description are presented in Chinese, and the metadata includes a Chinese-specific display name, without indicating that language choice is optional or user-selectable. This can constitute a language/locale policy concern when the skill is exposed to users who may not have opted into Chinese-language content.

Static analysis

No suspicious patterns detected.