Back to skill

Security audit

图片处理小工具

Security checks for vulnerabilities and agentic risk

Overview

This image-processing skill is generally purpose-aligned, but it needs review because some operations can overwrite original images despite documentation saying originals are safe.

Install only if you are comfortable with local image files being read and new image outputs being written. Keep backups before batch jobs, always choose a separate output folder, avoid same-format convert without an explicit output filename, and consider pinning dependencies or using an isolated 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 (2)

T08 · Insecure Dependencies

Warning
Location
SKILL.md:25
Finding
Unpinned Third-Party Dependencies Create Supply-Chain Risk<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:25-39`; `manifest.yaml:33-36` **Vulnerability Type**: Unpinned and integrity-unverified third-party dependencies **Risk Level**: Medium ### Vulnerable Code Snippet `SKILL.md:25-39`: ```bash pip install Pillow ``` ```bash pip install rembg ``` `manifest.yaml:33-36`: ```yaml dependencies: pip: - Pillow - rembg ``` ### Technical Analysis The project installs `Pillow` and `rembg` without fixed versions, package hashes, or a lock file. Consequently, installation resolves whichever package release the configured Python package index currently serves. The reviewed source therefore does not fully determine the code that will execute in the user's environment. The `rembg` functionality additionally downloads a machine-learning model during its first execution. Although this behavior is disclosed in the documentation, the project does not pin or verify the model artifact itself. This expands the externally controlled supply-chain surface beyond the Python dependencies. There is no evidence in the audited project that either dependency is currently malicious. The risk arises because future package releases, a compromised package index or maintainer account, an unsafe alternate index, or an unverified model artifact could introduce code or data that was not part of this audit. ### Attack Path 1. An attacker compromises a dependency maintainer account, package distribution channel, configured package index, or model distribution source. 2. The attacker publishes or serves a malicious release or artifact under the expected dependency name. 3. A user follows the documented unpinned `pip install` instructions, or an automated installer resolves the dependencies from `manifest.yaml`. 4. The malicious dependency executes with the privileges of the user running Python, either during installation, import, or skill execution. 5. For background removal, invoking `remove-bg` imports `rembg` and may ...[truncated 740 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin each dependency to a reviewed exact version, for example: ```text Pillow==<reviewed-version> rembg==<reviewed-version> ``` 2. Generate a lock file containing cryptographic hashes and install with hash verification, such as: ```bash pip install --require-hashes -r requirements.txt ``` 3. Specify and document the trusted package index rather than inheriting an arbitrary environment-level index configuration. 4. Separate the optional `rembg` dependency from the mandatory Pillow dependency so background-removal components are installed only when explicitly needed. 5. Pin the `rembg` model version and expected download location. Verify its cryptographic digest before loading it. 6. Perform dependency vulnerability scanning and periodically review pinned versions before updating them. 7. Prefer installation in an isolated virtual environment with only the filesystem and network permissions required for image processing. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/img_process.py:140
Finding
Source Images Can Be Overwritten Despite the Documented Safety Guarantee<![CDATA[ ## Vulnerability Details **File Location**: `scripts/img_process.py:140-144`; related batch behavior at `scripts/img_process.py:197-205` **Vulnerability Type**: Unsafe output-path handling leading to destructive file overwrite **Risk Level**: Medium ### Vulnerable Code Snippet `scripts/img_process.py:140-144`: ```python def cmd_convert(args): img = open_img(args.input) out = args.output or default_out(args.input, "", "." + args.format) src = file_size(args.input) save_img(img, out, quality=args.quality) ``` Related batch processing at `scripts/img_process.py:197-205`: ```python def cmd_batch(args): if not os.path.isdir(args.input): sys.exit(f"找不到文件夹:{args.input}") os.makedirs(args.output, exist_ok=True) count = 0 for name in os.listdir(args.input): if not name.lower().endswith((".png", ".jpg", ".jpeg", ".webp", ".bmp", ".tiff", ".gif")): continue src_path = os.path.join(args.input, name) dst_path = os.path.join(args.output, name) ``` ### Technical Analysis For single-image conversion, the default output is derived by retaining the original stem and replacing the extension: ```python default_out(args.input, "", "." + args.format) ``` If the requested format matches the input extension, the output path is identical to the source path. For example: ```bash python img_process.py convert photo.jpg --format jpg ``` resolves both input and output to `photo.jpg`. The subsequent call to `img.save()` rewrites the source image. Re-encoding can cause irreversible quality degradation and loss of metadata even when the operation appears to be a same-format conversion. The same underlying weakness exists in batch mode because the program does not reject an output directory that resolves to the input directory. For resize, trim, and thumbnail actions, each destination retains the source filename. Selecting the source directory as the output directory therefore causes processed im ...[truncated 1818 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Canonicalize and compare source and destination paths before saving: ```python def same_path(a, b): return os.path.normcase(os.path.realpath(a)) == os.path.normcase(os.path.realpath(b)) if same_path(args.input, out): sys.exit("The output path must differ from the input path.") ``` 2. Always add a nonempty suffix to default conversion output names, including same-format conversions: ```python out = args.output or default_out( args.input, "_converted", "." + args.format ) ``` 3. In batch mode, reject input and output directories that resolve to the same canonical directory: ```python if same_path(args.input, args.output): sys.exit("The batch output directory must differ from the input directory.") ``` 4. Before processing, also detect whether an output file aliases an input through symbolic links, path normalization, or case-insensitive filesystem behavior. 5. Refuse to overwrite existing output files by default. Require an explicit `--overwrite` option when replacement is intentional. 6. Use atomic output handling: save to a temporary file in the destination directory, validate the result, and then rename it into place. 7. Add regression tests for same-extension conversion, identical batch directories, symbolic-link aliases, pre-existing outputs, and case-insensitive path collisions. 8. Update the documentation so its no-overwrite guarantee accurately describes the behavior enforced by the code. ]]>
Vulnerability Patterns
  • 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
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (11)

Vague Triggers

High
Confidence
97% confidence
Finding
The skill explicitly instructs '不要 undertrigger' and says essentially any image-processing request should activate this skill instead of letting the agent reason more narrowly. Overbroad triggering can cause the agent to invoke local file-processing workflows in contexts where a simpler or safer response was appropriate, increasing unintended file access, unnecessary package installation, or accidental batch operations.

Lp3

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding
The skill provides operational instructions to run a local Python script over user-supplied image and folder paths, which implies filesystem read capability, but it declares no explicit tool scope or permission boundaries. In an agent environment, missing scope metadata can cause the agent to invoke the skill without clearly constrained file access, increasing the risk of overbroad access to local files.

Natural-Language Policy Violations

Medium
Confidence
84% confidence
Finding
The markdown states the adapted version is for WorkBuddy and specifically provides "全中文说明", while the skill content and invocation guidance are entirely in Chinese with no opt-in or alternative language path. This can be a language/locale policy issue when the skill is expected to serve general users without forcing a specific language.

Vague Triggers

Medium
Confidence
88% confidence
Finding
The manifest defines many generic image-editing triggers and explicitly instructs the system to "不要 undertrigger", which increases the chance of activating on loosely related requests. In an agent setting, overly permissive routing can lead to unintended tool use, unnecessary access to local image folders, or modification of user files without sufficient intent verification.

Vague Triggers

Medium
Confidence
96% confidence
Finding
The trigger phrase "图片太大了" is broad and matches a common user complaint rather than a clear request to invoke this specific skill. This can cause over-triggering, where the agent activates image-processing behavior in ambiguous contexts and performs unintended file operations or steers the conversation away from safer/manual clarification.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
This code file contains natural-language documentation and CLI/help text in a single language, which can violate language/locale policy when no user opt-in or alternative is provided. The file does not indicate that the tool is intended only for a Chinese-speaking or region-specific audience.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The skill advertises that it runs purely locally and does not upload images, but the remove-background feature explicitly states that first use downloads a model from the network. Even if no image contents are uploaded, this is still a security-relevant mismatch because operators may rely on the 'purely local' claim in restricted or offline environments and unintentionally permit outbound network activity.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The argparse descriptions, help strings, and printed user messages are all written in Chinese, and the tool offers no locale selection or opt-in. For a general-purpose skill, this is a natural-language policy concern because it imposes one language on all users.

Description-Behavior Mismatch

Low
Confidence
93% confidence
Finding
L004 将整个技能描述为“基于 Pillow,纯本地运行,不上传任何图片”,给人的整体印象是无需网络。后文 L042 明确说明 remove-bg 首次使用会联网下载模型,虽然不是上传图片,但仍与“纯本地运行”的绝对表述不一致。

Intent-Code Divergence

Low
Confidence
88% confidence
Finding
L017 写明“这个技能只需要一个叫 Pillow 的 Python 图片库”,属于对技能依赖的明确说明。但 L034-L042 又说明 remove-bg 需要额外安装 rembg,且首次会联网下载模型,这与前述笼统表述形成直接冲突。

Description-Behavior Mismatch

Low
Confidence
85% confidence
Finding
The parser description lists resize, format conversion, trimming, thumbnailing, compression, sharing image generation, and batch processing, but not background removal. Since the code exposes a dedicated 'remove-bg' command, the documentation shown to users understates actual behavior and creates a manifest/code-description mismatch.

Static analysis

No suspicious patterns detected.