Back to skill

Security audit

Markdown to PDF (Styled)

Security checks for vulnerabilities and agentic risk

Overview

This Markdown-to-PDF skill is mostly coherent, but its renderer is given broad local file access that could expose local files if used on untrusted Markdown or CSS.

Install only if you will convert Markdown and CSS you trust, or run it in a sandboxed, low-privilege environment. Avoid using it on documents from other people unless local file access is restricted or removed.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/md2pdf.sh:39
Finding
Unrestricted Local File Access During Markdown Rendering## Vulnerability Details **File Location**: `scripts/md2pdf.sh`, lines 39–43 **Vulnerability Type**: Unrestricted local resource access in an untrusted document renderer **Risk Level**: Medium ### Vulnerable Code ```bash pandoc "$IN" -o "$OUT" \ --pdf-engine=wkhtmltopdf \ --pdf-engine-opt=--enable-local-file-access \ --css "$CSS" ``` ### Technical Analysis The script accepts a caller-supplied Markdown document and optionally a caller-supplied CSS file, then renders that content through `wkhtmltopdf` with `--enable-local-file-access`. This option permits the rendering engine to access local files available to the account running the conversion. Because Markdown may contain embedded HTML and resource references, and custom CSS may contain resource-loading directives, untrusted input can instruct the renderer to request local resources. The permission is enabled globally rather than being limited to the input document, selected stylesheet, or bundled asset directory. The shell arguments are correctly quoted, so this is not shell command injection. The vulnerability instead arises from granting excessive filesystem access to a document renderer processing attacker-controlled content. ### Attack Path 1. An attacker creates a crafted Markdown document or custom stylesheet containing a reference to a sensitive local resource. 2. A user or automated service invokes `scripts/md2pdf.sh` with that attacker-controlled file. 3. The script passes the content to `wkhtmltopdf` with `--enable-local-file-access`. 4. The renderer attempts to read the referenced resource with the filesystem privileges of the invoking process. 5. If the resource type can be rendered or embedded, its data may appear in the generated PDF and become available to the attacker. ### Impact Assessment Successful exploitation may disclose local files readable by the user or service account performing the conversion. The accessible scope is bounded by operating-system filesystem permission ...[truncated 531 chars]
Remediation
## Remediation Suggestions 1. Remove `--enable-local-file-access` when processing untrusted Markdown or CSS. 2. If local stylesheet access is necessary, restrict access to explicitly trusted directories using supported `wkhtmltopdf` allow-list controls such as `--allow`, rather than granting unrestricted local access. 3. Copy approved inputs and bundled styles into an isolated per-job directory and permit access only to that directory. 4. Reject or sanitize raw HTML, local URI schemes, CSS imports, and resource-bearing elements before rendering untrusted content. 5. Do not permit arbitrary custom CSS in security-sensitive deployments, or validate it against a strict allowlist. 6. Run conversion under a dedicated, unprivileged account inside a sandbox or container with: - No mounted credentials or sensitive host paths - A read-only minimal filesystem - A private temporary working directory - Network access disabled unless explicitly required - CPU, memory, execution-time, and output-size limits 7. Keep `pandoc` and `wkhtmltopdf` patched and test the hardened configuration with crafted local-file references to confirm that files outside the approved directory cannot be accessed.
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 (3)

Natural-Language Policy Violations

Low
Confidence
83% confidence
Finding
The stylesheet explicitly prioritizes Simplified Chinese font families such as "Source Han Serif SC", "Noto Serif CJK SC", and "Songti SC". This is a natural-language locale preference embedded in the file, and there is no indication of user opt-in or documented justification for forcing that locale-specific presentation.

Natural-Language Policy Violations

Low
Confidence
80% confidence
Finding
The heading font stack again hard-codes Simplified Chinese-specific fonts, reinforcing a single locale choice across the document presentation. Because the file contains no natural-language justification or user-selectable locale handling, this may violate the language/locale policy criterion.

Missing User Warnings

Low
Confidence
76% confidence
Finding
This code file invokes external executables via a shell script to transform user-supplied markdown into a PDF, including passing a CSS path and enabling local file access in the PDF engine. Although the script prints the generated output path afterward, it does not disclose before execution that it will run pandoc/wkhtmltopdf or that local file access is enabled, and there is no explanatory comment or docstring describing this safety-relevant behavior.

Static analysis

No suspicious patterns detected.