Back to skill

Security audit

CAD批量处理

Security checks for vulnerabilities and agentic risk

Overview

This CAD automation skill appears purpose-built, but it can modify or rename many design files in place without enough safeguards or warnings.

Review this skill before installing if you would use it on valuable CAD projects. Run it only on copied project folders or backups, verify target folders carefully, avoid backup destinations inside the source folder, and consider pinning dependencies in a virtual environment.

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 (3)

T08 · Insecure Dependencies

Warning
Location
SKILL.md:36
Finding
Unpinned Third-Party Dependencies Permit Supply-Chain Substitution## Vulnerability Details **File Location**: `SKILL.md`, lines 36-38 **Vulnerability Type**: Unpinned and integrity-unverified dependencies **Risk Level**: Medium **Vulnerable Code**: ```bash pip install ezdxf # Additional dependencies for PDF watermarking: pip install PyPDF2 reportlab ``` ### Technical Analysis The installation instructions retrieve mutable versions of `ezdxf`, `PyPDF2`, and `reportlab` from the package index configured in the user's environment. No exact versions, lock file, trusted index, or package hashes are specified. Consequently, the installed code may differ between installations. Compromise of a package release, dependency account, package index, or local pip index configuration could cause an altered package to be installed. Python packages may execute code during installation and are subsequently imported directly by the project. This finding does not establish that the named dependencies are currently malicious. The weakness is the absence of controls that ensure users install the versions reviewed and expected by the project. ### Attack Path 1. An attacker compromises a dependency release channel or controls an index selected by the user's pip configuration. 2. The attacker publishes or serves a modified version of one of the documented dependencies. 3. A user follows the documented unpinned `pip install` command. 4. Pip resolves the attacker-controlled or compromised release because no version or hash is enforced. 5. Malicious code executes during installation or when the project imports the package. ### Impact Assessment A compromised dependency could execute arbitrary code with the privileges of the user installing or running the project. This could expose or modify accessible CAD documents, credentials, configuration files, and other user data. The scope is generally limited to the installing user's permissions unless installation is performed with elevated privileges.
Remediation
## Remediation Suggestions - Define exact, reviewed dependency versions in a requirements or lock file. - Generate and verify cryptographic hashes for every package and transitive dependency. - Install with hash enforcement, such as `pip install --require-hashes -r requirements.txt`. - Document the trusted package index explicitly and prevent unintended fallback to untrusted indexes. - Regularly scan locked dependencies for known vulnerabilities and update them through a controlled review process. - Recommend installation in an isolated virtual environment without elevated privileges.

T09 · Insecure Skill Coding Practices

Warning
Location
batch_export.py:15
Finding
Unchecked Rename Destinations Can Overwrite Existing CAD Files## Vulnerability Details **File Location**: `batch_export.py`, lines 15-20 **Vulnerability Type**: Unsafe filesystem destination handling **Risk Level**: Medium **Vulnerable Code**: ```python for f in files: ext = os.path.splitext(f)[1] new_name = f"{prefix}_{start_num + count:03d}{ext}" old_path = os.path.join(folder_path, f) new_path = os.path.join(folder_path, new_name) os.rename(old_path, new_path) ``` ### Technical Analysis `batch_rename` constructs destination names and immediately calls `os.rename` without first validating the complete rename plan. It does not reject duplicate destinations or destinations already occupied by unrelated files. On systems where `os.rename` replaces an existing destination, a generated filename can overwrite an existing CAD file. Incremental renaming also permits generated destinations to collide with files that have not yet been processed, producing data loss or inconsistent results. ### Attack Path 1. A user or caller selects a folder containing CAD files whose names overlap with the generated naming pattern. 2. The caller supplies a prefix and starting number that generate an existing destination filename. 3. The script processes files sequentially without collision validation. 4. `os.rename` replaces an existing destination on platforms that permit replacement, or the operation fails partway through on other platforms. 5. The directory is left with an overwritten file or a partially completed and inconsistent rename operation. ### Impact Assessment The issue can destroy or misidentify CAD files within the selected directory. It does not provide additional system privileges, but it affects the integrity and availability of user data accessible to the process. If the tool runs with access to shared or valuable project directories, the impact can include loss of production drawings and disruption of downstream workflows.
Remediation
## Remediation Suggestions - Precompute the entire source-to-destination mapping before changing any files. - Reject duplicate destinations and destinations occupied by files that are not part of the validated rename plan. - Use unique temporary filenames for a two-phase rename, followed by final destination names. - Prefer non-overwriting operations and fail closed if a destination exists. - Provide a dry-run mode that displays and validates the complete rename plan. - If any operation fails, implement rollback logic or preserve a journal that allows recovery.

T09 · Insecure Skill Coding Practices

Warning
Location
batch_export.py:30
Finding
Backup Directory Inside Source Tree Can Cause Recursive Storage Growth## Vulnerability Details **File Location**: `batch_export.py`, lines 30-49 **Vulnerability Type**: Unsafe recursive backup path handling **Risk Level**: Medium **Vulnerable Code**: ```python def auto_backup(folder_path: str, backup_folder: str = None): """Automatically back up the entire folder.""" if backup_folder is None: backup_folder = os.path.join(os.path.dirname(folder_path), f"{os.path.basename(folder_path)}_backup") os.makedirs(backup_folder, exist_ok=True) count = 0 for root, dirs, files in os.walk(folder_path): for f in files: if f.lower().endswith(('.dwg', '.dxf', '.pdf')): src = os.path.join(root, f) rel_path = os.path.relpath(src, folder_path) dst = os.path.join(backup_folder, rel_path) os.makedirs(os.path.dirname(dst), exist_ok=True) shutil.copy2(src, dst) count += 1 print(f"✅ Backup: {rel_path}") ``` ### Technical Analysis The function accepts an arbitrary backup destination and creates it before traversing the source. It does not verify that the resolved backup directory lies outside the resolved source directory, nor does it prune the backup directory from `os.walk`. If the backup destination is inside the source tree, the traversal can treat copied backup files as new source files and copy them into increasingly nested backup paths. Even when traversal behavior or execution timing prevents indefinite recursion, existing backup content can still be copied again, causing unnecessary and potentially substantial storage growth. ### Attack Path 1. A caller supplies a source directory and chooses a backup directory located beneath that source. 2. The function creates the nested backup directory. 3. `os.walk` traverses the source without excluding the backup subtree. 4. Eligible CAD or PDF files copied into the backup subtree ...[truncated 579 chars]
Remediation
## Remediation Suggestions - Resolve source and destination with `os.path.realpath` before beginning the backup. - Reject any backup destination equal to or located beneath the source directory. - Reject using the source directory itself as the backup destination. - Explicitly remove the resolved backup directory from `dirs` during top-down traversal as defense in depth. - Consider rejecting unsafe symlink-resolved layouts so path aliases cannot bypass containment checks. - Add file-count or total-size limits and abort cleanly when configured thresholds are exceeded. - Write backups to a temporary sibling directory and atomically finalize them after successful completion.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (12)

Missing User Warnings

Medium
Confidence
95% confidence
Finding
This markdown file documents bulk text replacement and layer renaming over project files, which can alter many CAD files at once. There is no accompanying warning about reviewing scope, making backups first, or the risk of unintended mass changes.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
The default watermark text is a fixed Chinese phrase, which imposes a specific language/locale choice in the skill's behavior. The file does not document that this is a region-specific tool or obtain user opt-in before applying that locale-specific text by default.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
When running the watermark mode, the script silently defaults to a fixed Chinese phrase instead of asking the user to choose language or text. This is a natural-language policy issue because it enforces a locale-specific output without explicit user opt-in.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
This code performs direct in-place writes to user files after text replacement, which is a safety-critical operation because it can alter many CAD files irreversibly if the replacement parameters are wrong. Although success is printed after saving, there is no pre-action confirmation, backup step, or explicit warning in the CLI usage that files will be overwritten.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
Renaming a layer and immediately saving to the same path changes the source CAD file in place. The function logs success only after the write, but there is no prior disclosure in code flow or CLI help that this operation overwrites the original file.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
This function updates block attributes and then saves directly to the same file path, which can permanently alter design data. The code lacks any confirmation prompt or pre-execution warning that the source file will be overwritten.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
Changing a layer color and saving to the same file is a direct modification to user data. The command-line help describes the feature but does not warn that it overwrites the original DXF, and the function provides only post-save status output.

Natural-Language Policy Violations

Low
Confidence
89% confidence
Finding
All user-facing instructions and examples in this file are in Chinese, which can amount to a forced language choice if the organization expects neutral or user-selectable language behavior. The document does not indicate that the skill is region-specific or provide an opt-in or alternative language.

Missing User Warnings

Low
Confidence
86% confidence
Finding
The batch-processing section includes automatic backup and PDF processing features that can create or overwrite many output files, but the description provides no caution about output locations, storage impact, or overwrite behavior. For markdown files, omission of such warnings is relevant when behavior affects user data or filesystem state.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
This code file contains natural-language documentation entirely in Chinese, and later user-facing status/error messages are also emitted only in Chinese. Under the policy rule, forcing a specific language without opt-in or justification is a locale/language policy concern.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
This code file includes user-facing documentation and runtime messages only in Chinese, which imposes a specific language on users without opt-in or alternative locale handling. The policy explicitly calls for flagging language or locale constraints when they are forced rather than offered as a choice.

Natural-Language Policy Violations

Low
Confidence
97% confidence
Finding
The script prints usage/help and descriptive messages in Chinese, and later prints a completion message in Chinese as well, without any mechanism for user language preference. This is a natural-language policy issue because it forces a language choice on all users.

Static analysis

No suspicious patterns detected.