Back to skill

Security audit

PDF Master Translator

Security checks for vulnerabilities and agentic risk

Overview

This PDF translator is not clearly malicious, but it needs Review because it sends document content to external AI/rendering services and renders untrusted model output with broad local/network access.

Install only after reviewing the data-flow risks. Do not use this skill on confidential, export-controlled, customer, military, or proprietary PDFs unless sending page images/text to Google GenAI and formulas to math.vercel.app is approved. Run it in a low-privilege sandbox with restricted outbound network access, and patch the renderer to sanitize model output and restrict WeasyPrint resource fetching before production use.

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

Error
Location
scripts/translator_engine_v10.py:130
Finding
Untrusted Model-Generated HTML Is Processed by a Network-Capable PDF Renderer<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/translator_engine.py:129-131, 175` - `scripts/translator_engine_v4.py:164-166, 179` - `scripts/translator_engine_v5.py:156-158, 171` - `scripts/translator_engine_v6.py:160-162, 226` - `scripts/translator_engine_v7.py:147-149, 162` - `scripts/translator_engine_v8.py:63-65, 75` - `scripts/translator_engine_v9.py:118-120, 144` - `scripts/translator_engine_v9_final.py:90-92, 111` - `scripts/translator_engine_v10.py:130-144, 155-159` **Vulnerability Type**: Unsanitized model-generated HTML, server-side request forgery, and local resource inclusion **Risk Level**: High **Classification**: T09: Insecure Skill Coding Practices ### Vulnerable Code Representative code from `scripts/translator_engine_v10.py`: ```python h_html = markdown2.markdown(h_md, extras=["tables"]) b_html = markdown2.markdown(b_md, extras=["tables"]) f_html = markdown2.markdown(f_md, extras=["tables"]) # 4. Assemble image HTML fig_html = "" if fig_b64s: fig_html = "<div class='app'><h3>[ Original Figures/Diagrams ]</h3>" for b64 in fig_b64s: fig_html += f"<div style='text-align:center;'><img src='{b64}' class='extracted-fig'/></div>" fig_html += "</div>" app_html = "" if annotations: app_html = f"<div class='app'><h3>[ Diagram Symbol Description ]</h3>{markdown2.markdown(annotations)}</div>" ``` The generated HTML is subsequently passed to WeasyPrint: ```python def build_pdf(html_segments, out_pdf): css = """...""" html = f"<html><head><style>{css}</style></head><body>{''.join(html_segments)}</body></html>" html = final_sanitizer(html) HTML(string=html, base_url=os.getcwd()).write_pdf(out_pdf) ``` The same data flow exists in the other affected translator versions: Gemini output is converted through `markdown2.markdown()` and then supplied to `HTML(...).write_pdf()`. ### Technical Analysis PDF page images and extracted diagrams are uploaded to Gemini, whose response is treated as Mar ...[truncated 3663 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Sanitize model-generated content with a strict allowlist.** - Permit only the minimum required formatting elements, such as `p`, `br`, `strong`, `em`, `ul`, `ol`, `li`, `table`, `thead`, `tbody`, `tr`, `th`, and `td`. - Remove `img`, `svg`, `iframe`, `object`, `embed`, `link`, `style`, `script`, and other resource-loading or executable elements from model output. - Remove URL-bearing attributes, including `src`, `href`, `srcset`, `poster`, and inline `style`. - Do not rely on regular expressions as an HTML sanitizer. 2. **Escape raw HTML before Markdown conversion.** - Configure the Markdown pipeline to reject or escape embedded HTML. - Treat every Gemini response as untrusted, even when it passes XML structural validation. 3. **Use a restrictive WeasyPrint URL fetcher.** - Allow only internally generated `data:image/png;base64,...` and other explicitly required data URIs. - If remote formula rendering remains necessary, allow only HTTPS requests to the exact approved host. - Reject `file:`, `ftp:`, `gopher:`, and other unnecessary schemes. - Reject loopback, private, carrier-grade NAT, multicast, reserved, and link-local addresses, including cloud metadata endpoints. - Revalidate the destination after DNS resolution and after every redirect to prevent DNS rebinding and redirect bypasses. - Enforce response-size, media-type, redirect-count, and timeout limits. 4. **Avoid remote formula loading during final rendering.** - Fetch formula SVGs through a controlled client with strict destination validation. - Validate and sanitize returned SVG data. - Embed the validated result as a data URI rather than allowing WeasyPrint to perform unrestricted network retrieval. - Prefer a local, sandboxed LaTeX renderer where operationally feasible. 5. **Remove the broad filesystem base URL.** - Do not use `base_url=os.getcwd()` with untrusted HTML. - If a base URL is required, use an ...[truncated 795 chars]
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Memory PoisoningPersistent Context Injection, Context Window Stuffing, Memory Manipulation
  • Rogue AgentSelf-Modification, Session Persistence
Findings (61)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding
A claimed robust multi-agent, zero-loss reconstruction pipeline that actually performs approximate reflow and limited heuristics can materially mislead users about trustworthiness and review requirements. In this context, the exaggerated description increases the likelihood of misuse on sensitive or accuracy-critical source documents.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding
A claimed robust multi-agent, zero-loss reconstruction pipeline that actually performs approximate reflow and limited heuristics can materially mislead users about trustworthiness and review requirements. In this context, the exaggerated description increases the likelihood of misuse on sensitive or accuracy-critical source documents.

Tp4

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding
A claimed robust multi-agent, zero-loss reconstruction pipeline that actually performs approximate reflow and limited heuristics can materially mislead users about trustworthiness and review requirements. In this context, the exaggerated description increases the likelihood of misuse on sensitive or accuracy-critical source documents.

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding
A claimed robust multi-agent, zero-loss reconstruction pipeline that actually performs approximate reflow and limited heuristics can materially mislead users about trustworthiness and review requirements. In this context, the exaggerated description increases the likelihood of misuse on sensitive or accuracy-critical source documents.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
A claimed robust multi-agent, zero-loss reconstruction pipeline that actually performs approximate reflow and limited heuristics can materially mislead users about trustworthiness and review requirements. In this context, the exaggerated description increases the likelihood of misuse on sensitive or accuracy-critical source documents.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
A claimed robust multi-agent, zero-loss reconstruction pipeline that actually performs approximate reflow and limited heuristics can materially mislead users about trustworthiness and review requirements. In this context, the exaggerated description increases the likelihood of misuse on sensitive or accuracy-critical source documents.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
A claimed robust multi-agent, zero-loss reconstruction pipeline that actually performs approximate reflow and limited heuristics can materially mislead users about trustworthiness and review requirements. In this context, the exaggerated description increases the likelihood of misuse on sensitive or accuracy-critical source documents.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
A claimed robust multi-agent, zero-loss reconstruction pipeline that actually performs approximate reflow and limited heuristics can materially mislead users about trustworthiness and review requirements. In this context, the exaggerated description increases the likelihood of misuse on sensitive or accuracy-critical source documents.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding
A claimed robust multi-agent, zero-loss reconstruction pipeline that actually performs approximate reflow and limited heuristics can materially mislead users about trustworthiness and review requirements. In this context, the exaggerated description increases the likelihood of misuse on sensitive or accuracy-critical source documents.

Lp3

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding
The skill advertises executable behavior that uses environment variables and external network access, but it declares no corresponding tool scope or permissions. This creates a covert capability gap: users and policy systems are not clearly informed that sensitive document content and API credentials may be used and transmitted externally.

Context Window Stuffing

Medium
Category
Memory Poisoning
Content
- To prevent the translation Agent from producing out-of-context or broken translations, the pipeline injects the **raw, unformatted text stream** of the entire page as a reference dictionary. The Agent uses this context to seamlessly bridge the visual gaps.

3. **Protocol Downgrade (XML over JSON):**
   - Forcing LLMs to output thousands of words of Markdown inside a strict JSON structure is fragile and prone to escaping errors.
   - The engine enforces simple XML tags (`<HEADER>`, `<BODY>`, `<FOOTER>`) for structural routing.

4. **Strict Math & Symbol Rendering:**
Confidence
80% confidence
Finding
Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The usage instructions tell users how to run the translator but do not warn that document content is sent to external translation and math-rendering services. For engineering, scientific, or military PDFs, this omission can cause unintentional disclosure of confidential or regulated information to third parties.

Session Persistence

Medium
Category
Rogue Agent
Content
**Important Operational Rules:**
- Always specify `--start` and `--end` explicitly.
- For very large documents (>20 pages), it is highly recommended to run this using `nohup ... &` in the background, as the multi-agent cross-checking and API rate-limiting sleep cycles make this a long-running process.

## Output
Confidence
65% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
The documented output includes fixed Chinese headings (`[ 原文图表/示意图 ]` and `[ 图例符号说明 ]`) with no indication that the user can choose the output language or locale. This creates a language/locale policy concern because the skill appears to impose a specific language in generated output regardless of user preference.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The prompt text hard-codes Chinese-language instructions for the layout analysis step, which imposes a specific language on the model output. The file does not offer a user opt-in, language selection, or documented justification for restricting the skill to Chinese.

Natural-Language Policy Violations

Medium
Confidence
98% confidence
Finding
The translation agent prompt is written to require Chinese output and behavior, including strict instruction text in Chinese, but there is no indication that the user selected this locale. This is a natural-language policy concern because the skill enforces a language choice rather than offering one.

Context-Inappropriate Capability

Medium
Confidence
98% confidence
Finding
The code converts LaTeX formulas into image URLs hosted at math.vercel.app by embedding each formula in a GET query string. In this skill's context, formulas may come from sensitive engineering, scientific, or military PDFs, so this leaks document content to an unrelated third-party service during PDF rendering and creates an external dependency that can track access or fail unpredictably.

Intent-Code Divergence

Medium
Confidence
98% confidence
Finding
The comment says formulas are rendered into vector SVG images, but the implementation only inserts remote <img> links that point to an external service. This mismatch is security-relevant because operators may believe formulas are embedded locally while the generated HTML/PDF still causes external fetches, resulting in hidden data exfiltration and unreliable builds.

Context-Inappropriate Capability

Medium
Confidence
89% confidence
Finding
The skill renders LaTeX by embedding remote image URLs from math.vercel.app into the generated HTML/PDF workflow. This causes document-derived formula content to be sent to an unrelated third-party service, creating an undisclosed data egress path and introducing a dependency on external network retrieval during document processing.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The code uploads full page images to Google's GenAI service for layout analysis without any user disclosure, consent flow, or sensitivity check. Because the skill is intended for engineering, scientific, and military-style PDFs, uploaded pages may contain proprietary, export-controlled, or otherwise sensitive information.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The skill uploads extracted figure images to an external model for annotation without warning the user. Figures in technical PDFs often contain high-value schematics, labels, and operational details, so sending them to a third party materially increases confidentiality risk.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The translation stage sends masked page images and prior-page text context to an external AI model without any user-facing notice or approval. This broadens the data exposure beyond a single page and may leak sensitive narrative, metadata, or controlled technical content to a third party.

Natural-Language Policy Violations

Medium
Confidence
98% confidence
Finding
The instruction `翻译为纯正中文。严禁出现中英夹杂。` forces a single language output regardless of user preference. This is a natural-language locale policy concern because the file provides no user choice or documented justification for restricting output to Chinese only.

Context-Inappropriate Capability

Medium
Confidence
84% confidence
Finding
The manifest focuses on translating and reconstructing PDFs, but the implementation pulls a GEMINI_API_KEY from the process environment to access an external AI service. Accessing environment-based secrets is a broader capability than the manifest states and is not an obvious requirement unless remote model usage is explicitly declared.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The workflow uploads full page images, masked pages, and cropped tables/figures to an external AI provider for analysis and translation. Given the skill is explicitly intended for complex engineering, scientific, or military PDFs, this creates a significant confidentiality and data-governance risk if users are not clearly warned and given a choice.

Static analysis

No suspicious patterns detected.