Back to skill

Security audit

Img Compress

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it claims, but it tells users to run broad, in-place image overwrites as root, including against web server assets.

Review before installing. Use only on backed-up copies or a staging directory, run as an unprivileged user, avoid pointing it at production or system-owned paths, and pin/install Pillow in an isolated environment. Do not follow the documented sudo examples unless you have separately constrained the directory and understand the overwrite risk.

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

T05 · Unauthorized Access and Privilege Escalation

Error
Location
SKILL.md:12
Finding

Unnecessary privileged execution enables root-level file modification through symbolic links

Content
View full analysis
target_size: files.append((f, size)) ``` ```python new_size = compress_image(path, target_size) ``` ### Technical Analysis The documented usage instructs users to execute the image-processing script with `sudo`, even though ordinary image compression does not inherently require root privileges. The script recursively processes files and overwrites each selected path in place. The traversal does not reject symbolic links or verify that each resolved file remains under the resolved input directory. `Path.is_file()` follows symbolic links, and Pillow subsequently opens and saves through the supplied path. When the process runs as root, a symbolic link with a supported suffix can therefore reference an image file that the invoking user could not ordinarily modify. Successful exploitation requires an attacker to create or influence content in the scanned directory and identify a root-owned image file suitable for modification. This issue does not provide arbitrary code execution by itself, but it breaks the least-privilege boundary and enables unauthorized modification of reachable image files. ### Attack Path 1. An attacker gains write access to a directory that will be scanned by the Skill. 2. The attacker creates a symbolic link with a `.jpg`, `.jpeg`, or `.png` suffix that points to a ...[truncated 976 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Note
Location
SKILL.md:22
Finding

Unpinned Pillow installation creates dependency supply-chain exposure

Content
View full analysis
Remediation
View remediation
``` - Generate and verify cryptographic hashes for all accepted distribution artifacts, such as with `pip-compile --generate-hashes`. - Install with hash enforcement: ```bash python3 -m pip install --require-hashes -r requirements.txt ``` - Use a dedicated virtual environment rather than the system Python environment. - Avoid running `pip` as root. - Regularly review and update the pinned version in response to published security advisories. - Use a trusted package index and secure index configuration. For high-assurance deployments, mirror approved artifacts internally. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/compress_img.py:17
Finding

Destructive non-atomic overwrite can corrupt files and encode JPEG data under PNG filenames

Content
View full analysis
target_size_kb and quality > min_quality: quality -= 5 img.save(src_path, 'JPEG', quality=quality, optimize=True) return get_file_size_kb(src_path) ``` ### Technical Analysis Output format selection is based on image mode rather than the source file format. Only `RGBA` images are written as PNG. Consequently, an RGB, grayscale, or palette-based PNG enters the `else` branch and is encoded as JPEG while retaining its original `.png` path. This creates a mismatch between the filename extension and actual file contents. It can also discard PNG-specific properties and introduce lossy JPEG artifacts. Some consumers inspect file signatures and may continue to display the image, while software that relies on extensions or declared MIME types may reject or mishandle it. The script also saves directly over the source file. It does not write to a temporary file, validate the completed result, preserve a backup, or atomically replace the source. Process interruption, disk exhaustion, encoder failure, or an unexpected image error during a save can therefore leave the original asset corrupted or partially written. ### Attack Path 1. A user supplies a directory containing an RGB, grayscale, or palette-based PNG larger than the configured threshold. 2. The recursive scanner selects the `.png` file for c ...[truncated 1140 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (6)

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
93% confidence
Finding

The documentation instructs users to run the image compression script with sudo even though image processing normally does not require elevated privileges. Running a batch file-manipulation script as root increases the blast radius of mistakes, such as overwriting system-owned files or damaging unintended directories if the path is wrong.

Content

Scanner excerpt · SKILL.md (reported line 14)May include surrounding context.

bash
# Compress images over 100KB to 80KB
sudo python3 skills/img-compress/scripts/compress_img.py /path/to/images

# Custom target size (KB)
sudo python3 skills/img-compress/scripts/compress_img.py /path/to/images 150

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
93% confidence
Finding

This second usage example repeats the recommendation to execute the script with sudo, normalizing unnecessary root execution for routine image compression. If the script or its dependencies behave unexpectedly, elevated privileges can turn an ordinary operational error into system-wide file damage.

Content

Scanner excerpt · SKILL.md (reported line 17)May include surrounding context.

sudo python3 skills/img-compress/scripts/compress_img.py /path/to/images

Custom target size (KB)

sudo python3 skills/img-compress/scripts/compress_img.py /path/to/images 150

text

## Compression Rules

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill explicitly states that it overwrites original image files in place, but it does not provide a clear warning about irreversible data loss or recommend backups. In a batch-processing context, this can cause widespread accidental destruction of originals if the compression result is poor or the wrong directory is supplied.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
95% confidence
Finding

The example targets a web server asset directory under /var/www and recommends sudo, combining privileged execution with in-place modification of production-facing files. In this context, a mistaken path, buggy compression, or malformed image handling could corrupt live assets or broader server content with elevated permissions.

Content

Scanner excerpt · SKILL.md (reported line 36)May include surrounding context.

bash
# Compress website static assets
sudo python3 skills/img-compress/scripts/compress_img.py /var/www/static/img 100

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script overwrites source images in place during compression without creating backups, using a temporary file, or requiring confirmation. This is a destructive behavior that can permanently corrupt or degrade assets if compression fails midway, changes format/quality unexpectedly, or is run on the wrong directory; the skill context increases risk because it recursively processes many files in bulk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The module docstring presents usage and behavior only in Chinese, and the runtime print messages are also Chinese-only. This imposes a language choice on users without opt-in or explanation, which matches the language/locale policy concern for natural-language content.

Content

No source excerpt is available for this finding.