Back to skill

Security audit

Image Compression

Security checks for vulnerabilities and agentic risk

Overview

This image-compression skill is mostly purpose-aligned, but it can immediately send local images to messaging services and can overwrite certain input images despite saying originals are preserved.

Install only if you are comfortable with the agent running shell scripts that can send chosen images to WeChat or Telegram. Prefer using the compression-only script unless you have verified the destination, and avoid running it on the only copy of important images, especially files already named with _compressed.

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/compress_image.sh:43
Finding

Destructive In-Place Compression of Files Already Marked as Compressed

Content
View full analysis

Vulnerability Details

File Location: scripts/compress_image.sh, lines 43–66
Vulnerability Type: Unsafe output-path handling and unintended file overwrite
Risk Level: Medium

Vulnerable Code:

bash
# 生成压缩后的文件名
if [[ "$FILE_NAME" =~ .*_compressed\..* ]]; then
    OUTPUT_PATH="$IMAGE_PATH"
else
    OUTPUT_NAME="${FILE_NAME%.*}_compressed.${FILE_EXT}"
    OUTPUT_PATH="${FILE_DIR}/${OUTPUT_NAME}"
fi

# 压缩图片
if [ "$FILE_EXT" = "png" ]; then
    # PNG 压缩
    sips -Z "$MAX_WIDTH" "$IMAGE_PATH" --out "$OUTPUT_PATH"
    # PNG 优化(使用 optipng)
    if command -v optipng >/dev/null 2>&1; then
        optipng -o2 -q "$OUTPUT_PATH"
    fi
elif [ "$FILE_EXT" = "gif" ]; then
    # GIF 压缩
    sips -Z "$MAX_WIDTH" "$IMAGE_PATH" --out "$OUTPUT_PATH"
else
    # 其他格式(JPEG)
    sips -Z "$MAX_WIDTH" -s formatOptions "${QUALITY}%" "$IMAGE_PATH" --out "$OUTPUT_PATH"
fi

Technical Analysis

When the input filename contains _compressed. anywhere in its name, the script sets OUTPUT_PATH to the same path as IMAGE_PATH. It then supplies that path to sips as both the input file and the --out destination.

This creates a destructive in-place processing condition rather than generating a separate output file. It also contradicts the documented behavior that the original file is preserved. Because no source/destination equality check, temporary output file, backup, or atomic replacement mechanism is used, an existing image may be overwritten, degraded, or left unusable if processing fails partway through.

The filename test is also broad: it matches any filename containing _compressed. rather than reliably identifying and safely handling an output generated during the current operation.

Attack Path

  1. An attacker supplies, creates, or persuades a user to process an image larger than the configured compression threshold.
  2. The image is named with the matching pattern, such as ` ...[truncated 1032 chars]
Remediation
View remediation

Remediation Suggestions

  • Always create an output path that differs from the input path, regardless of whether the filename already contains _compressed.
  • Explicitly compare canonical source and destination paths and abort if they are identical.
  • Generate a collision-resistant output name when the intended destination already exists, or require explicit user confirmation before replacing it.
  • Write compressed data to a securely created temporary file in the destination directory.
  • Verify that the compression command succeeds and that the temporary output is a valid, nonempty image before moving it into place.
  • Use an atomic rename only after successful validation.
  • Reject symbolic links where they are not required, or resolve and validate them before writing.
  • Check the exit status of sips and optipng instead of treating the mere existence of the output path as proof of success.
  • Preserve the original file by default and document any optional overwrite behavior explicitly.

A safe implementation should follow this sequence: derive a distinct destination, create a secure temporary file, compress into that file, validate the command result and output, and atomically rename it to the final destination without modifying the source.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (6)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill includes example commands that send compressed images to external messaging services (WeChat and Telegram) but does not clearly warn users that running them will transmit local files off-device. This creates a meaningful risk of unintended data disclosure, especially because screenshots and images often contain sensitive personal or corporate information.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script transmits a file to WeChat immediately after compression without any explicit confirmation, preview, or warning to the user. In an agent-skill context, this can cause unintentional exfiltration of sensitive images to an external messaging platform, especially because the default recipient is preselected and the send action is automated.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script transmits a user-supplied image to an external Telegram target without any confirmation, warning, or visibility about the network transfer. In an agent or automation context, this can lead to unintended data exfiltration or privacy leakage if the image path or target ID is influenced by untrusted input or used on sensitive files.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The natural-language content in the manifest description and README body is exclusively Chinese, which can force a specific language on users without opt-in. The file does not indicate that the skill is intentionally limited to Chinese-speaking users or provide an alternative language option.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

The script's natural-language comments and default recipient name are entirely Chinese-specific, including a localized default target of '文件传输助手'. This imposes a specific language/locale context without any opt-in or explanation that the skill is intended only for Chinese/WeChat users.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The natural-language comments and usage context are written only in Chinese, which can reflect a fixed language assumption without user opt-in. The file does not indicate that the skill is region-specific or that alternative language support is intentionally limited.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.