Back to skill

Security audit

PDF Watermark

Security checks for vulnerabilities and agentic risk

Overview

This PDF watermark skill does what it claims, but its URL-download workflow is under-scoped enough that users should review it before installing.

Install only if you are comfortable with the agent downloading PDFs from URLs on your behalf. Prefer local files or trusted HTTPS sources, avoid internal/private URLs, and use a private temporary directory with unique filenames when processing sensitive documents.

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

T05 · Unauthorized Access and Privilege Escalation

Error
Location
SKILL.md:52
Finding
Unrestricted Server-Side Retrieval of User-Controlled URLs<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 52-58 **Vulnerability Type**: Server-Side Request Forgery through unrestricted URL retrieval **Risk Level**: High ### Vulnerable Code ```bash curl -L "<PDF_URL>" -o /tmp/temp_input.pdf python3 scripts/add_pdf_watermark.py /tmp/temp_input.pdf "<水印文字>" /tmp/output_watermarked.pdf ``` ### Technical Analysis The skill directs the agent to retrieve an arbitrary user-supplied URL using `curl -L`. It does not require validation of the URL scheme, hostname, resolved IP address, redirect targets, response size, content type, or file signature. Because redirects are followed automatically, validating only the initial URL would also be insufficient. An attacker-controlled public endpoint could redirect the request to a loopback, link-local, private-network, or cloud metadata address. Although the retrieved content is not executed as code, the request originates from the agent's environment and may therefore reach services unavailable to the requester. If an internal service returns a valid PDF, the skill can process that file and return its contents to the requester as a watermarked document. ### Attack Path 1. An attacker asks the agent to watermark a PDF at a crafted URL. 2. The URL directly targets an internal address or redirects to one. 3. Following the documented workflow, the agent invokes `curl -L`. 4. The request is issued from the agent's network context. 5. An internal or otherwise restricted resource responds. 6. If the response is a parseable PDF, the skill watermarks it and sends the resulting document to the attacker. 7. Even when the response is not a PDF, response behavior may permit internal service discovery or cause resource exhaustion. ### Impact Assessment A successful exploit can allow access to HTTP resources available from the agent's network environment, including loopback services, private-network applications, and potentially cloud metadata endpoints. The practic ...[truncated 334 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Accept only HTTPS URLs unless an explicitly approved exception is required. - Parse and validate URLs before retrieval; reject embedded credentials and unexpected ports. - Resolve the destination hostname and reject loopback, link-local, private, multicast, reserved, and unspecified address ranges for both IPv4 and IPv6. - Repeat destination validation after every redirect, or disable redirects and process each redirect manually. - Prefer an explicit allowlist of trusted hosts when the operational use case permits it. - Apply strict connection, transfer, and total-operation timeouts. - Set a maximum response size and abort downloads that exceed it. - Verify the response content type and validate that the downloaded file begins with an expected PDF signature before processing. - Run network retrieval in a sandbox with no access to internal networks or cloud metadata services. - Do not return retrieved content to the requester unless authorization to access the source has been established. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:57
Finding
Predictable Shared Temporary Files Permit Collisions and Symlink Attacks<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 57-58 **Vulnerability Type**: Unsafe temporary-file handling **Risk Level**: Medium ### Vulnerable Code ```bash curl -L "<PDF_URL>" -o /tmp/temp_input.pdf python3 scripts/add_pdf_watermark.py /tmp/temp_input.pdf "<水印文字>" /tmp/output_watermarked.pdf ``` A second documented workflow repeats the same pattern with predictable names: ```bash curl -L "http://example.com/doc.pdf" -o /tmp/doc.pdf python3 scripts/add_pdf_watermark.py /tmp/doc.pdf "<水印文字>" /tmp/doc_watermarked.pdf ``` ### Technical Analysis The documented workflow stores input and output documents at fixed, predictable paths in the shared `/tmp` directory. It does not create a private per-run directory, use exclusive file creation, check for symbolic links, set restrictive permissions, or clean up sensitive files after processing. On a multi-user or concurrent system, another local process can pre-create these paths, replace them with symbolic links, monitor them, or race the watermarking operation. Concurrent legitimate invocations can also overwrite or consume one another's input and output files. The output operation in `scripts/add_pdf_watermark.py` uses ordinary write mode: ```python with open(output_path, 'wb') as output_file: writer.write(output_file) ``` Consequently, an existing destination is truncated, and the script itself does not provide exclusive-creation or symlink protections. ### Attack Path 1. A local attacker predicts one of the documented paths, such as `/tmp/temp_input.pdf` or `/tmp/output_watermarked.pdf`. 2. The attacker pre-creates the path, creates a symbolic link at that path, or repeatedly replaces it during processing. 3. The agent follows the documented commands and writes the downloaded or generated document to that path. 4. The write collides with another job or follows the attacker-controlled filesystem object. 5. Depending on runtime permissions and platform protections, the attacker ...[truncated 781 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Create a unique private directory for each invocation, for example with `mktemp -d`. - Set the directory permissions to owner-only access and retain a restrictive `umask`. - Generate unpredictable input and output filenames inside that directory. - Use exclusive file creation where applicable and reject pre-existing output paths. - Refuse symbolic-link destinations or open files using platform facilities that prevent symlink following. - Keep all intermediate files inside the private per-run directory. - Delete the temporary directory and its contents in a guaranteed cleanup handler after successful or failed processing. - Avoid placing confidential final output in a globally shared directory. - If callers may select an output path, validate it and require explicit confirmation before overwriting an existing file. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (2)

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill explicitly instructs downloading a user-supplied URL with curl and then processing the fetched content, without any restrictions, validation, or warning about external network access. This creates SSRF-style risk, enables retrieval of untrusted content from internal or sensitive endpoints, and increases exposure to downstream parser exploits in the PDF-processing script.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
The file-level description and all CLI usage/output strings are written in Chinese, which effectively imposes a specific language on users of the skill. There is no indication that the tool is intended only for a Chinese-speaking environment, nor any option to select another language.

Static analysis

No suspicious patterns detected.