Back to skill

Security audit

pyautogui

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent desktop automation tool, but it can capture screens, type and click in other apps, use the clipboard, and delete files with safeguards that are too thin for that level of authority.

Install only if you are comfortable giving the agent desktop-control authority. Use it for explicit UI automation tasks, avoid screenshots/OCR over sensitive windows, avoid real passwords in examples or prompts, verify the active window and target coordinates before clicks or typing, avoid --click on OCR/template matches unless you have reviewed the target, and run cleanup only in directories that contain disposable generated images.

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)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/image_finder.py:126
Finding
Predictable Temporary Screenshot Permits Symlink Attacks and Cross-Process Interference<![CDATA[ ## Vulnerability Details **File Location**: `scripts/image_finder.py`, lines 126–137; additional affected paths at lines 151–158, 179–190, 467–474, and 503–512 **Vulnerability Type**: Predictable temporary file and unsafe file replacement **Risk Level**: Medium ### Vulnerable Code ```python screenshot = pyautogui.screenshot() temp_path = ".temp_screenshot.png" screenshot.save(temp_path) print("正在初始化OCR引擎...") ocr = RapidOCR() result, elapse = ocr(temp_path) if os.path.exists(temp_path): os.remove(temp_path) ``` The same predictable path is also used by other OCR and image-marking operations: ```python screenshot = pyautogui.screenshot() temp_path = ".temp_screenshot.png" screenshot.save(temp_path) draw_matches_on_image(temp_path, args.mark_on_image, result) os.remove(temp_path) ``` ### Technical Analysis The script creates a screenshot under the fixed name `.temp_screenshot.png` in the current working directory. It does not create the file atomically, verify that the destination is a regular file, reject symbolic links, or assign a name unique to the running process. If the program is launched in a directory writable by another local user or untrusted process, an attacker can create `.temp_screenshot.png` as a symbolic link to another file. `screenshot.save()` may then follow that link and overwrite the linked target using the privileges of the process running the Skill. Concurrent invocations also share the same filename. One process may replace or delete another process's screenshot, causing incorrect OCR results, disclosure of captured screen data, failed operations, or deletion of an unexpected temporary entry. Cleanup is performed manually rather than through a `finally` block. An interruption or exception before deletion can therefore leave a screenshot containing potentially sensitive on-screen information in the working directory. ### Attack Path 1. The attacker identifies a working directory in which the victim will run `imag ...[truncated 1431 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace the fixed filename with a securely generated temporary file: ```python import os import tempfile temp_path = None try: with tempfile.NamedTemporaryFile( prefix="image_finder_", suffix=".png", delete=False ) as temp_file: temp_path = temp_file.name screenshot.save(temp_path) result, elapse = ocr(temp_path) finally: if temp_path: try: os.unlink(temp_path) except FileNotFoundError: pass ``` 2. Prefer a private `tempfile.TemporaryDirectory()` when several intermediate files are required. 3. Ensure temporary files are created with permissions that prevent access by other users. 4. Do not create temporary files in the caller-controlled current working directory. 5. Keep cleanup in a `finally` block so it runs after both successful and failed processing. 6. Apply the same remediation to every `.temp_screenshot.png` occurrence. 7. Where supported, verify with `os.lstat()` that paths are not symbolic links before processing. Secure atomic creation should remain the primary defense. 8. Avoid running GUI automation with administrative or root privileges. ]]>

T08 · Insecure Dependencies

Note
Location
references/requirements.txt:1
Finding
Unpinned and Incomplete Dependency Declaration Creates Supply-Chain Exposure<![CDATA[ ## Vulnerability Details **File Location**: `references/requirements.txt`, lines 1–11; related installation guidance in `SKILL.md`, line 414 **Vulnerability Type**: Non-reproducible dependency resolution **Risk Level**: Low ### Vulnerable Code ```text # PyAutoGUI 键鼠控制技能依赖 # 安装命令: pip3 install -r requirements.txt # 核心依赖 - 跨平台键鼠控制 pyautogui>=0.9.54 # 可选依赖 - 用于图像识别定位 # opencv-python>=4.8.0 # 可选依赖 - 提升截图质量 # pillow>=10.0.0 ``` The Skill separately instructs users to install additional mutable packages: ```bash pip install opencv-python numpy rapidocr_onnxruntime ``` ### Technical Analysis The active requirement uses an open-ended lower bound, while other runtime dependencies are commented out or only listed in documentation without version constraints. No lock file or package hashes are supplied. Consequently, installations performed at different times can resolve different package versions. A future compromised release, dependency takeover, or incompatible transitive dependency could be installed without any change to the audited Skill package. The project does not show direct use of an untrusted package index, typosquatted package, or currently known malicious dependency. The risk arises from mutable, unverified dependency resolution rather than evidence that the listed packages are malicious. ### Attack Path 1. A user follows the documented `pip install` commands or installs from `references/requirements.txt`. 2. The package resolver selects the latest versions satisfying the open-ended constraints. 3. A package or transitive dependency has been compromised, taken over, or publishes an unsafe release after this Skill was audited. 4. The unreviewed release is downloaded and installed. 5. Package installation hooks or imported runtime code execute with the privileges of the installing or running user. ### Impact Assessment Potential impact depends on the behavior of a compromised dependency and the privileges used during installation. Becau ...[truncated 564 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Maintain a complete dependency manifest containing every required runtime package, including PyAutoGUI, Pillow, NumPy, OpenCV, Pyperclip, and RapidOCR where applicable. 2. Pin each dependency to a specifically reviewed version rather than using unconstrained installation commands or open-ended lower bounds. 3. Generate a lock file that also constrains transitive dependencies. 4. Use hash verification, such as `pip --require-hashes`, to ensure downloaded artifacts match reviewed distributions. 5. Install only from an explicitly trusted package index over TLS. 6. Review dependency updates before modifying the lock file and use automated vulnerability scanning. 7. Install dependencies inside an isolated virtual environment as a non-privileged user. 8. Keep optional feature groups explicit so users do not need to copy mutable installation commands from documentation. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • 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
Findings (27)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The skill advertises broad capabilities and also appears to have implementation/documentation drift, including undeclared clipboard operations and references to major features that may not actually exist. This mismatch is dangerous because reviewers and users may trust the declared scope while the skill performs additional actions or omits expected safeguards, enabling covert data handling or misleading activation and execution paths.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The README advertises screenshot capture and OCR-based text extraction/location without clearly warning that these features can collect sensitive on-screen data such as passwords, messages, tokens, personal information, or confidential documents. In a UI automation skill, this omission increases the risk of accidental over-collection and storage of sensitive data, especially because screenshots and OCR output may be saved to disk for later use.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The README includes examples for automated clicking, typing, and form filling, including entering a password, but does not place an explicit warning adjacent to those examples that input may go to the wrong window or application if focus changes. Because this skill directly drives mouse and keyboard events on the host, misdirected automation can send secrets, trigger destructive actions, or interact with privileged interfaces unintentionally.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The README documents screenshot capture, OCR-based text extraction, and screen text enumeration, but does not clearly warn that these features can collect sensitive on-screen information such as passwords, personal data, tokens, chat content, or confidential documents. Because this skill is specifically designed for screen inspection and automation, the absence of privacy guidance makes accidental overcollection and unsafe handling of captured data more likely.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The README includes examples for automated message sending and form filling, including typing credentials and clicking submit, without an explicit warning that UI automation can act on the wrong window or transmit data to third-party applications. In the context of a keyboard/mouse automation skill, this increases the chance of accidental credential disclosure, unintended actions, or misuse by downstream agents that treat the examples as safe defaults.

Lp3

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding
Without declared permissions the skill's intent is opaque and cannot be validated.

Vague Triggers

Medium
Confidence
94% confidence
Finding
An overly broad activation description can cause the agent to invoke this skill in many ordinary contexts, including ones involving sensitive applications or data. Because this skill can control mouse/keyboard, capture screens, and potentially manipulate the clipboard, over-triggering increases the chance of unintended privileged actions or privacy-invasive automation.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The skill documents screenshot capture and OCR of screen text without an explicit privacy warning, despite those features being able to collect credentials, messages, tokens, personal information, or proprietary data visible on screen. In the context of a UI automation skill, this materially increases the risk of silent over-collection and misuse of sensitive information.

Vague Triggers

Medium
Confidence
91% confidence
Finding
Broad trigger examples without constraints or negative examples make accidental activation more likely, especially for routine requests like clicking, typing, or taking screenshots. In a skill that can drive the UI and access on-screen content, accidental invocation can quickly turn into unauthorized actions or exposure of sensitive information.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The cleanup commands include destructive deletion examples, including execute modes, without a prominent warning that deletion may be irreversible and scope-sensitive. In a skill that encourages automation and bulk operations, users may run cleanup in the wrong directory or with overly broad criteria and lose important files.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The trigger section includes broad, everyday phrases such as '截图', '输入文字', '清理文件', and '自动执行重复操作', which can cause the skill to activate in ordinary conversations without strong user intent for desktop automation. In a skill that can control mouse/keyboard, take screenshots, OCR the screen, and delete files, accidental activation materially increases the chance of unintended clicks, keystrokes, screen capture, or file cleanup actions.

Missing User Warnings

Medium
Confidence
87% confidence
Finding
The documentation presents screenshot capture, OCR/text discovery, and auto-click capabilities as routine workflows, but the safety guidance only covers operational issues like active window selection and hotkeys, not privacy or authorization boundaries. In this context, users may be encouraged to capture sensitive on-screen data or trigger actions on the wrong application without clear warnings, consent checks, or review steps.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The auto-clean routine deletes files immediately with os.remove() once thresholds are exceeded, without a dry-run default, confirmation prompt, recycle-bin behavior, or path safety restrictions. In a UI automation skill that creates screenshots and derived images, this can cause unintended irreversible data loss if the directory or filename patterns are broader than expected, or if users invoke it against the wrong folder.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
The file’s docstring and all user-facing CLI/help text are written only in Chinese, which imposes a specific language on users. Under the policy, locale constraints should be optional or clearly justified as region-specific, neither of which is present here.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The OCR workflow saves a full-screen screenshot to `.temp_screenshot.png` on disk without user-facing disclosure or strong guarantees about secure handling. Screenshots can contain secrets, messages, tokens, or personal data, and writing them to a predictable local file increases the chance of leakage, recovery after crashes, or access by other local processes/users.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
Although presented as a finder utility, the script also performs direct UI actions via `pyautogui.click()` on located image or OCR matches. In an automation skill, that expands the trust boundary from passive screen analysis to active input injection, which can trigger unintended or unsafe actions if the match is wrong, the screen changes, or the command is invoked in a sensitive context.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The script can automatically click the first image match immediately when `--click` is supplied, with no confirmation, delay, or secondary validation. In a UI automation skill, mis-detection or adversarial screen content could cause unintended actions such as dismissing prompts, approving operations, or interacting with privileged applications.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The OCR path clicks the first text match automatically without confirming that the detected text and coordinates are correct. OCR is inherently error-prone and susceptible to ambiguous or manipulated screen content, so this can result in mis-clicks on destructive or security-sensitive controls.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This code file contains user-facing documentation and runtime messages entirely in Chinese, including the module docstring and error/help text. Under the policy rule, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified, which is not present here.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
This code captures the full screen and writes the image to a user-specified file path, which can expose sensitive on-screen data and modify the filesystem. While it prints after saving, there is no prior warning, confirmation, or docstring/comment disclosing the privacy and file-write impact of the operation.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
This function captures a selected screen region and saves it to disk, creating both privacy risk and a filesystem side effect. The code logs success afterward, but it does not provide any advance disclosure or warning that sensitive visible content may be recorded and stored.

Description-Behavior Mismatch

Medium
Confidence
94% confidence
Finding
The manifest describes mouse/keyboard automation, screenshots, image utilities, locating, overlays, and cleanup, but does not mention clipboard read/write behavior. This file adds copy-to-clipboard and paste orchestration features that modify system clipboard state, which is materially different from the listed capabilities and broader than ordinary mouse/keyboard primitives.

Natural-Language Policy Violations

Low
Confidence
86% confidence
Finding
This requirements file includes only Chinese natural-language comments such as the dependency description and install instructions. Under the stated policy, forcing a specific language without user opt-in can be a locale/language policy violation, and no alternative language or opt-in is provided here.

Unpinned Dependencies

Low
Category
Supply Chain
Content
# 安装命令: pip3 install -r requirements.txt

# 核心依赖 - 跨平台键鼠控制
pyautogui>=0.9.54

# 可选依赖 - 用于图像识别定位
# opencv-python>=4.8.0
Confidence
93% confidence
Finding
Using a lower-bounded dependency specifier (pyautogui>=0.9.54) allows installation of any newer release, which can introduce unreviewed behavioral changes or a compromised upstream version through the software supply chain. In a UI automation skill that can control mouse and keyboard, a malicious or vulnerable dependency could materially increase risk because the package operates in a high-impact execution context.

Natural-Language Policy Violations

Low
Confidence
81% confidence
Finding
User-facing docstrings, help text, and CLI descriptions throughout the file are presented exclusively in Chinese. The file does not offer a language option or explain that the tool is intentionally limited to a Chinese-speaking context, which can violate language-choice policy.

Static analysis

No suspicious patterns detected.