Back to skill

Security audit

我的二维码生成技能

Security checks for vulnerabilities and agentic risk

Overview

The skill is a QR-code generator, but it automatically runs unpinned pip installs during import, which can change the user's Python environment without direct control.

Review this skill before installing. Its QR generation behavior is straightforward, but loading the Python module may run pip installs automatically. Prefer a version that declares pinned dependencies in a manifest or requires an explicit setup step, and avoid using it in an environment with broad filesystem, credential, or network access.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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)

T08 · Insecure Dependencies

Warning
Location
agent.py:7
Finding
Unpinned Dependency Installation During Module Import<![CDATA[ ## Vulnerability Details **File Location**: `agent.py:7-17` **Vulnerability Type**: Uncontrolled runtime dependency installation **Risk Level**: Medium ### Vulnerable Code ```python # 自动安装依赖库(若用户未安装) def install_dependencies(): required_packages = ["qrcode", "pillow"] for package in required_packages: try: __import__(package) # 检查库是否已安装 except ImportError: # 自动安装缺失的库 subprocess.check_call([sys.executable, "-m", "pip", "install", package]) # 初始化:安装依赖库 install_dependencies() ``` ### Technical Analysis The module automatically invokes `pip install` while being imported. The package names have no pinned versions, integrity hashes, or explicitly approved package index. Package resolution therefore depends on the runtime environment's pip configuration and currently available repository contents. This creates a supply-chain execution path: Python packages can run installation or build logic, and their modules execute code when imported. If an attacker compromises a configured package repository, manipulates pip configuration, controls a higher-priority package index, or compromises a future package release, loading this skill can result in attacker-controlled code running with the privileges of the agent process. There is also a package/import-name mismatch. The distribution is named `pillow`, but its Python import name is `PIL`. Consequently, `__import__("pillow")` normally raises `ImportError` even when Pillow is installed, causing an unnecessary `pip install pillow` attempt each time this module is loaded. The top-level imports of `qrcode` and `PIL` occur before this function is reached. Therefore, the installer cannot recover when either initial import is genuinely missing. This does not remove the supply-chain risk from the repeated Pillow installation path, but it demonstrates that runtime installation is both unsafe and unreliable. ### Attack Path 1. The agent loads or imports `a ...[truncated 1345 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove dependency installation from module initialization. Importing a skill must not mutate the Python environment or initiate package downloads. 2. Declare dependencies in a reviewed dependency manifest and install them during a controlled deployment step. 3. Pin exact reviewed versions, for example: ```text qrcode==<reviewed-version> Pillow==<reviewed-version> ``` 4. Use a lockfile or hash-verified requirements file with `pip install --require-hashes` so altered artifacts are rejected. 5. Configure an explicitly trusted package index and prevent fallback to untrusted or user-controlled indexes. 6. Install dependencies in an isolated virtual environment with the minimum required privileges. 7. If dependency validation is retained, use the correct import names and fail safely without installing anything: ```python def check_dependencies(): try: import qrcode from PIL import Image except ImportError as exc: raise RuntimeError( "Required dependencies are unavailable. Install the reviewed, " "pinned dependency set before loading this skill." ) from exc ``` 8. Perform dependency vulnerability and provenance scanning as part of the build or deployment process rather than at runtime. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (7)

Context-Inappropriate Capability

Medium
Confidence
99% confidence
Finding
The skill auto-installs Python packages at import time, which is unsafe for an untrusted skill because loading the file immediately triggers environment modification and potential execution of third-party package code. In an agent setting, this increases supply-chain risk and violates least surprise: analysis or registration of the skill can unexpectedly perform networked installation actions.

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Content
required_packages = ["qrcode", "pillow"]
    for package in required_packages:
        try:
            __import__(package)  # 检查库是否已安装
        except ImportError:
            # 自动安装缺失的库
            subprocess.check_call([sys.executable, "-m", "pip", "install", package])
Confidence
75% confidence
Finding
Dynamic __import__() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
__import__(package)  # 检查库是否已安装
        except ImportError:
            # 自动安装缺失的库
            subprocess.check_call([sys.executable, "-m", "pip", "install", package])

# 初始化:安装依赖库
install_dependencies()
Confidence
96% confidence
Finding
This code invokes pip via subprocess during module initialization, causing code execution and network/package management side effects merely by importing the skill. Even though arguments are hardcoded and shell injection is not present, automatic package installation can pull unreviewed code from package indexes and changes the host environment without operator approval.

Missing User Warnings

Medium
Confidence
98% confidence
Finding
Installing packages without warning or user confirmation is dangerous because it silently changes the execution environment and may retrieve code from external sources. In a skill ecosystem, users may only expect QR-code generation, not package management actions triggered automatically on load.

Missing User Warnings

Low
Confidence
95% confidence
Finding
The skill performs file writes and defaults to saving the generated QR image to the user's desktop, but the description does not clearly warn the user that local disk modification will occur. This can lead to unexpected persistence of potentially sensitive QR content such as WiFi credentials, URLs, or personal data in a predictable location, reducing informed consent and increasing privacy risk.

Intent-Code Divergence

Low
Confidence
76% confidence
Finding
The comments describe a safe fallback that installs libraries if the user has not installed them, but the module imports qrcode and PIL before reaching that logic. In practice, missing dependencies can raise ImportError before the documented auto-install mechanism runs, so the documented intent contradicts the actual execution flow.

Natural-Language Policy Violations

Low
Confidence
87% confidence
Finding
Comments, docstrings, and user-facing return messages are all in Chinese, and the file provides no indication that this locale is optional or region-specific. This can violate language-choice policy when users are not given an opt-in or alternative language.

Static analysis

No suspicious patterns detected.