Back to skill

Security audit

Image Resizer图片大小调整裁剪缩放技能

Security checks for vulnerabilities and agentic risk

Overview

This is a straightforward local image resize/compression skill, with some dependency and validation hardening issues but no evidence of hidden, deceptive, exfiltrating, or destructive behavior.

Install and run this like a normal local CLI utility, preferably in a project or sandbox without unnecessary credentials. Be aware that npm install will fetch sharp without a lockfile, and avoid processing untrusted images or extreme resize values until the package pins dependencies and adds explicit dimension/resource limits.

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
scripts/package.json:9
Finding
Unpinned Dependency Installation Without a Lockfile<![CDATA[ ## Vulnerability Details **File Location**: `scripts/package.json:9-11`; installation instructions at `SKILL.md:26-29` **Vulnerability Type**: Supply-chain exposure caused by mutable dependency resolution **Risk Level**: Medium ### Vulnerable Code ```json "dependencies": { "sharp": "^0.32.6" } ``` The documented installation procedure is: ```bash cd scripts npm install ``` The audited project contains no `package-lock.json` or other dependency lockfile. ### Technical Analysis The caret constraint `^0.32.6` allows npm to resolve a compatible version other than the specific version reviewed by the project author. The absence of a lockfile also leaves the complete transitive dependency graph unresolved until installation time. Consequently, separate installations can retrieve different package artifacts and transitive dependency versions. If an allowed dependency release or one of its transitive dependencies is compromised, the project may install unreviewed code. npm package installation can also run dependency lifecycle scripts unless scripts are explicitly disabled. No malicious dependency or currently exploited package behavior was identified in the audited files. The vulnerability is the non-reproducible and mutable trust boundary created by the dependency configuration and documented installation process. ### Attack Path 1. An attacker compromises an allowed release of `sharp`, a transitive package, or the relevant package-distribution channel. 2. The attacker publishes malicious package content within a version accepted by the declared range or alters a transitively resolved artifact. 3. A user follows `SKILL.md` and runs `npm install`. 4. npm resolves the dependency graph at installation time because no lockfile fixes the reviewed artifacts. 5. Malicious package code or an installation lifecycle script executes with the privileges of the account running npm. 6. The compromised dependency may subsequently execute again when `resize_ima ...[truncated 566 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin `sharp` to an exact, reviewed version rather than a mutable caret range: ```json "dependencies": { "sharp": "0.32.6" } ``` 2. Generate and commit `package-lock.json` so direct and transitive dependency versions and integrity hashes are reproducible. 3. In deployment and automated build environments, replace `npm install` with: ```bash npm ci ``` 4. Where compatible with the dependency's native installation requirements, disable lifecycle scripts: ```bash npm ci --ignore-scripts ``` 5. If lifecycle scripts are necessary, review them and perform installation in a sandboxed environment with minimal filesystem access, no unnecessary credentials, and no privileged account. 6. Add automated dependency vulnerability and integrity scanning to the release process. 7. Review and deliberately update the lockfile instead of permitting dependency versions to change implicitly during installation. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/resize_image.js:116
Finding
Unbounded Image Dimensions Permit Local Resource Exhaustion<![CDATA[ ## Vulnerability Details **File Location**: `scripts/resize_image.js:116-145`, `scripts/resize_image.js:178-226`, and `scripts/resize_image.js:323-325` **Vulnerability Type**: Missing numeric validation and image-processing resource limits **Risk Level**: Medium ### Vulnerable Code User-provided numeric arguments are parsed without finite-value, positivity, or upper-bound validation: ```js case '-w': case '--width': args.width = parseInt(next, 10); i++; break; case '-h': case '--height': args.height = parseInt(next, 10); i++; break; case '-s': case '--scale': args.scale = parseFloat(next); i++; break; case '--max-width': args.maxWidth = parseInt(next, 10); i++; break; case '--max-height': args.maxHeight = parseInt(next, 10); i++; break; case '-q': case '--quality': args.quality = parseInt(next, 10); i++; break; case '-S': case '--size': args.targetSize = parseInt(next, 10); i++; break; ``` The scale can be used directly to derive output dimensions: ```js if (args.scale) { targetWidth = Math.round(imgWidth * args.scale); targetHeight = Math.round(imgHeight * args.scale); } ``` The resulting dimensions are passed to the image-processing library: ```js if (args.width || args.height || args.scale || args.aspectRatio || args.maxWidth || args.maxHeight) { pipeline = pipeline.resize(width, height, { fit: args.fit }); } ``` ### Technical Analysis The command-line parser accepts arbitrary width, height, scale, maximum-dimension, quality, and target-size values. It does not verify that values are present, finite, positive, supported by `sharp`, or within a safe resource budget. An attacker or untrusted caller can request extremely large dimensions directly or provide a very large scale factor. Image processing generally requires memory proportional to the decoded and output pixel counts, while encoding also consumes CPU and may produce substantial output. A request with a sufficiently large width and heig ...[truncated 1724 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate every numeric option immediately after parsing: - Require a supplied value. - Require `Number.isFinite(value)`. - Reject zero and negative dimensions or scales. - Reject fractional values where integer pixels are required. - Restrict quality to `1-100`. - Require a positive and bounded target size. 2. Establish explicit processing limits, such as: - Maximum width and height. - Maximum total output pixel count calculated with safe arithmetic. - Maximum scale factor. - Maximum input file size. - Maximum decoded source pixel count. - Maximum permitted output-file size. 3. Check the computed dimensions before calling `sharp`: ```js const MAX_DIMENSION = 10000; const MAX_PIXELS = 40_000_000; function validateDimensions(width, height) { if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height)) { throw new Error('Width and height must be finite integers.'); } if (width <= 0 || height <= 0) { throw new Error('Width and height must be positive.'); } if ( width > MAX_DIMENSION || height > MAX_DIMENSION || width * height > MAX_PIXELS ) { throw new Error('Requested image dimensions exceed processing limits.'); } } ``` 4. Call this validation after `calculateDimensions` and before constructing the resize pipeline. 5. Configure `sharp` input pixel limits where appropriate and reject oversized source images before full processing. 6. Run image processing in a worker or isolated container with memory, CPU, execution-time, and disk quotas. 7. Limit compression iterations and terminate processing when a defined CPU-time or attempt budget is exceeded. 8. Return a clear validation error instead of passing malformed or excessive parameters to the image library. ]]>
Vulnerability Patterns
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • 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)

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
This markdown file contains user-facing natural-language instructions entirely in Chinese, which can impose a specific language on users without an explicit opt-in or alternative. The policy scope includes language or locale constraints in markdown content, and no language choice or justification is provided here.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
该代码文件中的主要用户可见说明、帮助文本和错误提示均为中文,属于自然语言层面的语言/locale 约束。文件中没有提供语言切换、用户选择机制,亦未说明该工具仅面向特定中文环境或区域,因此符合语言策略违规条件。

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
showHelp 中所有面向用户的使用说明均固定为中文,命令行用户无法选择其他语言。根据规则,强制单一语言且没有 opt-in 或合理、已记录的区域性限制,属于自然语言政策问题。

Intent-Code Divergence

Medium
Confidence
98% confidence
Finding
L097-L099 的帮助示例明确宣称可用通配符进行批量处理,但实际参数解析只保存一个 input 值,主流程在 L466-L471 也仅对单一路径做 existsSync 检查并调用一次 processImage。该文档会让调用方误以为脚本具备批量处理能力,属于注释/帮助文本与实际行为相矛盾。

Natural-Language Policy Violations

Medium
Confidence
88% confidence
Finding
运行状态输出如压缩提示、保存结果、错误信息等均为中文,属于用户可见自然语言内容。文件未提供任何语言切换或区域限定说明,因此存在单一语言强制的问题。

Natural-Language Policy Violations

Low
Confidence
84% confidence
Finding
The package description is written only in Chinese, which signals a language-specific skill description without offering users a language choice or documenting that the skill is intentionally region-specific. Under the stated policy, forcing a specific language without opt-in can be a natural-language policy violation.

Unpinned Dependencies

Low
Category
Supply Chain
Content
"resize": "node resize_image.js"
  },
  "dependencies": {
    "sharp": "^0.32.6"
  },
  "keywords": [
    "image",
Confidence
89% confidence
Finding
The dependency on sharp uses a caret range (^0.32.6), which allows different patch releases to be installed over time. In a security-sensitive supply chain, this reduces build reproducibility and can result in unexpectedly pulling a vulnerable or maliciously compromised release, especially for a package with native components and install-time behavior.

Unverifiable Dependency: sharp has 4 known advisory(ies) (GHSA-54xq-cgqr-rpm3 (sharp vulnerability in libwebp dependency CVE-2023-4863); GHSA-f88m-g3jw-g9cj (sharp inherited vulnerabilities in libvips: CVE-2026-33327, CVE-2026-33328, CVE-); CVE-2022-29256 (sharp vulnerable to Command Injection in post-installation over build environmen) +1 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
94% confidence
Finding
The manifest references sharp without pinning an exact version, while the package family has multiple known advisories, including issues in transitive native libraries and historical install-time risks. Because sharp processes untrusted image data and bundles/depends on complex native code, unresolved version ambiguity materially increases the chance of shipping a build exposed to memory corruption, denial of service, or supply-chain compromise.

Intent-Code Divergence

Low
Confidence
96% confidence
Finding
文档在 L017 将 -h 标记为高度参数,但参数解析的 switch 中 L128-L132 已先匹配 '-h' 为 height,导致后面的 L175-L178 帮助分支中的 '-h' 实际不可达。帮助文本和代码共同给出了互相冲突的意图说明,容易误导使用者。

Static analysis

No suspicious patterns detected.