Back to skill

Security audit

Html To Pdf

Security checks for vulnerabilities and agentic risk

Overview

This HTML-to-PDF skill does what it claims, but it runs caller-supplied HTML in Chromium with the browser sandbox disabled by default and has weak output-path controls.

Review before installing. Use this only on trusted HTML or inside a disposable/containerized environment, remove or opt in explicitly to --no-sandbox, pin dependencies with a lockfile, and avoid running the font setup or converter under a privileged account. Be careful with output paths because existing files may be overwritten.

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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/html-to-pdf.mjs:20
Finding

Chromium Sandbox Is Unconditionally Disabled

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/html-to-pdf.mjs:31
Finding

Output Directory Allowlist Can Be Bypassed Through Prefix Matching

Content
View full analysis
resolve(p).startsWith(dir)); } ``` The result controls whether a caller-supplied output path is accepted: ```javascript pdfPath = resolve(outRaw); if (!isSafePath(pdfPath)) { console.error('❌ 输出路径不在安全白名单内'); console.error(' 安全路径: HOME(' + process.env.HOME + '), /tmp, 当前目录(' + process.cwd() + ')'); console.error(' 建议: 将 PDF 输出到上述路径,或使用不指定输出参数(默认输出到输入文件同目录)'); process.exit(1); } ``` The accepted path is later written directly: ```javascript writeFileSync(pdfPath, pdf); ``` ### Technical Analysis The allowlist uses a raw string-prefix comparison rather than checking whether the output is actually contained within an approved directory. For example, because `/tmp` is approved, a resolved path such as `/tmp-escape/output.pdf` also begins with `/tmp` and therefore passes validation. Similarly, if `/home/alice` is approved through `HOME`, `/home/alice-other/output.pdf` is incorrectly treated as being inside `/home/alice`. The validation also does not resolve symlinks for an existing destination path or its parent directory. Consequently, an apparently approved path could traverse a symlink and cause the write to occur elsewhere. ### Attack Path 1. An attacker can influence the second command-line argument used as the PDF output path. 2. The attacker selects a path outside an approved directory that shares its string prefix, such as `/tmp-escape/target.pdf`. 3. `resolve()` normalizes the path, but `startsWith('/tmp')` still returns `true`. 4. `isSafePath()` accepts the destination. 5. The generated PDF is passed to `writeFileSync()`. 6. If operating-system permissions permit the write, ...[truncated 729 chars]
Remediation
View remediation
isWithin(parent, candidate)); } ``` 2. Resolve the real path of the destination parent with `realpath()` or `realpathSync()` before validation to address symlink traversal. 3. Create and validate a dedicated output directory instead of allowing broad writes throughout `HOME`, `/tmp`, and the current working directory. 4. Refuse to overwrite an existing file by default. Use an exclusive creation mode such as `flag: 'wx'`, or require an explicit overwrite option. 5. Revalidate the destination immediately before writing to reduce time-of-check/time-of-use risks. 6. Where feasible, open the destination through a safely validated directory handle rather than trusting a path string. ]]>

T08 · Insecure Dependencies

Note
Location
SKILL.md:87
Finding

Installation Instructions Use Unpinned npm Dependencies

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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 (10)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 23)May include surrounding context.

md
node scripts/html-to-pdf.mjs report.html

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 26)May include surrounding context.

md
node scripts/html-to-pdf.mjs report.html

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 29)May include surrounding context.

md
node scripts/html-to-pdf.mjs report.html

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 104)May include surrounding context.

md
node scripts/html-to-pdf.mjs report.html

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 149)May include surrounding context.

md
node scripts/html-to-pdf.mjs report.html

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 152)May include surrounding context.

md
node scripts/html-to-pdf.mjs report.html

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The description states the tool renders HTML to '纯中文 PDF', which imposes a language constraint in natural-language documentation. The file does not present this as an optional mode or offer a user language choice, so it appears to enforce a specific language/locale without opt-in.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
81% confidence
Finding

The skill instructs users to copy fonts into ~/.fonts and rebuild the font cache, which creates persistent changes to the user's environment outside the immediate task. Persistent modification of user directories can have unintended side effects, survive across sessions, and in shared or managed environments may violate change-control expectations.

Content

Scanner excerpt · SKILL.md (reported line 118)May include surrounding context.

方法 A:从 Windows 复制(WSL 环境)

bash
mkdir -p ~/.fonts
cp "/mnt/c/Windows/Fonts/Noto Sans SC (TrueType).otf" ~/.fonts/
cp "/mnt/c/Windows/Fonts/msyh.ttc" ~/.fonts/
cp "/mnt/c/Windows/Fonts/seguiemj.ttf" ~/.fonts/

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The title and all instructional content in this file are presented exclusively in Chinese, with no indication that users may choose another language or locale. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.