Back to skill

Security audit

document-management

Security checks for vulnerabilities and agentic risk

Overview

This skill is for organizing PDFs, but it can move files and leave full extracted document text on disk without clear confirmation.

Review before installing if you plan to use it on sensitive or important folders. Run it only on a copied test folder or after backups, and make sure you are comfortable with PDFs being moved into new subfolders and full extracted text being written to a local JSON file.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/analyze_pdf_folder.py:92
Finding
Extracted PDF contents are persisted in plaintext through an unsafe predictable output path## Vulnerability Details **File Location**: `scripts/analyze_pdf_folder.py:92-117` **Vulnerability Type**: Plaintext sensitive-data storage and unsafe predictable-file overwrite **Risk Level**: Medium ### Vulnerable Code ```python documents.append({ "file_name": file_name, "file_path": pdf_path, "text": text }) return { "success": True, "folder_path": folder_path, "document_count": len(documents), "documents": documents, "errors": errors } def main(): if len(sys.argv) < 2: print("❌ 使用方法:python extract_pdf_folder.py <本地PDF目录路径>") sys.exit(1) folder_path = sys.argv[1] result = analyze_pdf_folder(folder_path) # Write to file instead of stdout to avoid encoding issues output_file = os.path.join(folder_path, "_extracted_texts.json") with open(output_file, "w", encoding="utf-8") as f: json.dump(result, f, ensure_ascii=False, indent=2) ``` ### Technical Analysis The script collects each PDF's filename, absolute path, and complete extracted text, then serializes that information to a fixed file named `_extracted_texts.json` inside the user-supplied directory. This creates a persistent plaintext copy of potentially confidential document contents. The fixed output path is opened in `w` mode, which truncates an existing destination. Python's ordinary `open()` also follows symbolic links. The implementation does not check whether the destination already exists, whether it is a symbolic link, or whether its ownership and permissions are safe. It also does not use exclusive creation, restrictive permissions, or atomic replacement. Although the Skill documentation describes the extraction stage as returning structured results, it does not clearly disclose that all extracted document text will be retained in a plaintext sidecar file. ### Attack Path 1. A victim selects a PDF directory ...[truncated 1583 chars]
Remediation
## Remediation Suggestions 1. Return the structured JSON through standard output instead of retaining extracted document contents on disk. 2. If persistent output is required, obtain explicit user consent and clearly document the destination, retained fields, retention period, and deletion procedure. 3. Reject symbolic-link destinations using `os.path.islink()` and perform race-resistant opening with platform-appropriate flags such as `O_NOFOLLOW`. 4. Avoid silent truncation. Use exclusive creation (`O_CREAT | O_EXCL`) or obtain explicit confirmation before replacing an existing file. 5. Create the output with restrictive permissions, such as owner read/write only, and verify directory ownership and permissions. 6. Write to a securely created temporary file and atomically replace the intended destination after successful serialization. 7. Minimize retained information by omitting absolute paths and full document text when they are not necessary. 8. Provide automatic cleanup or deletion after the classification and reporting stages complete.

T08 · Insecure Dependencies

Note
Location
scripts/analyze_pdf_folder.py:5
Finding
Unpinned third-party dependency installation guidance creates supply-chain risk## Vulnerability Details **File Location**: `scripts/analyze_pdf_folder.py:5-11` **Vulnerability Type**: Unpinned and unverifiable third-party dependency installation **Risk Level**: Low ### Vulnerable Code ```python def safe_import_pypdf(): try: from pypdf import PdfReader return PdfReader except ImportError: print("❌ 缺少依赖:pypdf,请先安装:pip install pypdf") sys.exit(1) ``` ### Technical Analysis When `pypdf` is unavailable, the script instructs the user to execute `pip install pypdf`. The recommendation does not identify an audited version, require package hashes, specify a trusted package index, or direct installation into an isolated environment. Consequently, installations are not reproducible and can resolve to different package or transitive dependency versions over time. The command also uses the user's configured package index and pip configuration. If that configuration points to an untrusted or compromised repository, a malicious artifact under the expected package name could be selected. The code does not itself download or install the dependency automatically. Exploitation therefore depends on the user following the displayed instruction and on compromise or manipulation of the package source or dependency resolution environment. ### Attack Path 1. The script is run in an environment where `pypdf` is not installed. 2. The import fails and the script displays `pip install pypdf`. 3. The user follows the recommendation without a lockfile, version constraint, or hash verification. 4. Pip resolves the package using the user's configured indexes and current dependency metadata. 5. A compromised package release, malicious repository mirror, or manipulated package index supplies an unsafe artifact. 6. Malicious package code may execute during installation or when the script subsequently imports `pypdf`. ### Impact Assessment If dependency resolution is compromi ...[truncated 505 chars]
Remediation
## Remediation Suggestions 1. Declare `pypdf` in a project dependency manifest rather than providing an ad hoc installation command at runtime. 2. Pin an audited exact version and lock all transitive dependencies. 3. Use hash verification, such as pip requirements containing `--require-hashes`. 4. Install dependencies in a dedicated virtual environment with least-privilege permissions. 5. Configure an explicitly trusted package index and avoid dependency resolution from untrusted public or internal mirrors. 6. Add a documented dependency-update process that includes security review, testing, and lockfile regeneration. 7. Replace the runtime message with instructions that reference the project's verified dependency file and supported installation procedure.
Vulnerability Patterns
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (9)

Missing User Warnings

High
Confidence
98% confidence
Finding
The skill explicitly instructs automatic movement of documents into classified folders without a clear prior warning or explicit user confirmation that local files will be modified. This is dangerous because classification can be wrong, moves are state-changing operations on the user’s filesystem, and accidental activation or misclassification may disrupt file organization or workflows.

Vague Triggers

Medium
Confidence
96% confidence
Finding
The trigger phrases are broad enough to match many ordinary document-related requests, increasing the chance the skill activates when the user did not intend to invoke a workflow that reads, classifies, moves, and writes files. In this skill’s context, overbroad activation is more dangerous because the skill performs filesystem modifications, so accidental invocation can lead to unintended local file processing and reorganization.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill requires the final report to be saved but does not warn the user that it will create or overwrite a file on disk. Silent write operations are risky in a local-file skill because they can create artifacts in unexpected locations, overwrite existing reports, or expose sensitive extracted content in a persistent file.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The script writes full extracted PDF text to a predictable JSON file in the source directory without explicit consent, warning, or controls. If the PDFs contain sensitive information, this creates unintended local data persistence and increases the risk of later disclosure through shared folders, backups, or other processes reading the file.

Natural-Language Policy Violations

Low
Confidence
90% confidence
Finding
The instructions recommend using Chinese names for classification folders, which is a locale-specific preference embedded in the skill behavior. There is no opt-in, language choice, or documented regional requirement that would justify enforcing or steering output toward a specific language.

Natural-Language Policy Violations

Low
Confidence
94% confidence
Finding
The template uses Chinese throughout and instructs the model to "严格按照以下结构生成", which effectively mandates a specific language/locale for the report. The policy allows locale constraints only when user choice or explicit justification is provided, neither of which appears here.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
The script's natural-language output strings are written in Chinese, and there is no indication that this is a region-specific tool or that users can opt into another language. This can violate language/locale policy when a skill forces a specific language without user choice.

Natural-Language Policy Violations

Low
Confidence
92% confidence
Finding
Several status, error, and usage messages in the script are presented only in Chinese. Because the file does not document a justified locale restriction or offer localization options, this constitutes a natural-language locale policy concern.

Intent-Code Divergence

Low
Confidence
94% confidence
Finding
The inline user-facing documentation in the usage message names a different script than the actual file being analyzed. This is a direct documentation/code mismatch that can mislead operators about what is being run and what output behavior to expect.

Static analysis

No suspicious patterns detected.