Back to skill

Security audit

Mineru Pdf Parser

Security checks for vulnerabilities and agentic risk

Overview

This PDF parser matches its stated MinerU purpose, but it needs review because it uploads local PDFs to a third-party service and downloads/extracts remote results with limited runtime safeguards.

Install only if you are comfortable sending PDFs and the MinerU API token to MinerU, and avoid processing confidential documents unless MinerU's privacy and retention terms are acceptable. Treat downloaded results as untrusted, and prefer a version that adds per-run upload confirmation plus safe ZIP validation and size/time limits.

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
mineru_api.py:220
Finding
Unvalidated ZIP Extraction Allows Path Traversal and Arbitrary File Overwrite<![CDATA[ ## Vulnerability Details **File Location**: `mineru_api.py`, lines 220–239 **Vulnerability Type**: Unsafe archive extraction **Risk Level**: High ### Vulnerable Code ```python def download(data: dict, out_dir=None) -> str: """Download results to the specified directory""" url = data.get("full_zip_url") if not url: return None # If no directory is specified, use the default result directory if out_dir is None: out_dir = "result" zip_path = os.path.join(out_dir, "result.zip") os.makedirs(out_dir, exist_ok=True) print(f"📥 Downloading...") r = requests.get(url, stream=True) with open(zip_path, "wb") as f: for c in r.iter_content(8192): f.write(c) with zipfile.ZipFile(zip_path, "r") as z: z.extractall(out_dir) os.remove(zip_path) return out_dir ``` ### Technical Analysis The `download()` function obtains an archive URL from the MinerU API response, downloads the content, and passes the resulting archive directly to `ZipFile.extractall()` without explicitly validating archive member paths. A malicious or compromised archive can contain absolute paths or traversal components such as `../../`. If these entries are not rejected by the deployed Python runtime or extraction environment, extraction can cause files to be written outside the intended `~/.openclaw/MinerU_Results/` directory. The download operation also lacks an HTTP timeout, response status validation, content-type validation, archive-size limit, and integrity verification. Consequently, an invalid or unbounded response could be stored and processed, increasing the potential for denial of service or processing of attacker-controlled content. ### Attack Path 1. An attacker compromises or impersonates the MinerU result service, its storage endpoint, or another component capable of influencing the `full_zip_url` response. 2. The attacker supplies a ZIP archive containing crafted entries such as ...[truncated 1410 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate every archive member before extraction: - Reject absolute paths. - Reject drive-qualified paths. - Reject `..` traversal components. - Resolve each destination path and verify that it remains under the canonical output directory. - Reject symbolic links and other special file types unless explicitly required. 2. Extract members individually only after validation rather than calling `extractall()` directly. 3. Harden the download operation: - Require an HTTPS URL from an explicitly approved host or trusted allowlist. - Add connect and read timeouts. - Call `raise_for_status()` before writing the response. - Enforce a maximum compressed download size. - Enforce limits on member count, individual extracted size, and total extracted size. - Reject unexpected content types where practical. 4. Validate archive integrity before extraction: - Use a trusted digest or signature supplied through an authenticated channel when available. - Verify that the downloaded file is a valid ZIP archive before processing it. 5. Use a private temporary directory and clean it up in a `finally` block. Example path-validation pattern: ```python def safe_extract(zip_file, destination): destination = Path(destination).resolve() for member in zip_file.infolist(): member_path = Path(member.filename) if member_path.is_absolute() or ".." in member_path.parts: raise ValueError(f"Unsafe archive member: {member.filename}") target = (destination / member_path).resolve() try: target.relative_to(destination) except ValueError: raise ValueError(f"Archive member escapes destination: {member.filename}") # Reject symbolic links and other special entries as appropriate. mode = member.external_attr >> 16 if stat.S_ISLNK(mode): raise ValueError(f"Symbolic links are not allowed: {member.filename}" ...[truncated 339 chars]
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (14)

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill requires access to an environment secret (`MINERU_TOKEN`) and sends data over the network to an external service, but it does not declare any explicit tool scope such as `permissions` or `allowed-tools`. This increases the chance that an agent framework will invoke it without clear capability boundaries or user awareness, especially because PDFs and API tokens are both sensitive inputs in this context.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The trigger phrase '将 PDF 转为 Markdown' is broad enough to match many ordinary requests, which can cause the skill to auto-activate in situations where the user did not intend to upload a local file or send document contents to MinerU. In this skill's context, overbroad activation is more dangerous because execution may expose local document contents and use a credentialed external API.

Context-Inappropriate Capability

Medium
Confidence
84% confidence
Finding
The manifest describes a PDF parsing skill that handles local files and URLs via the MinerU API, but it does not mention reading credentials from the host environment. Accessing environment variables is a broader host-data capability than the user-facing document-conversion purpose itself and is not explicitly declared in the stated scope.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
The default language is hard-coded to "ch", which imposes a specific locale unless the user overrides it manually. Under the language/locale policy, forcing a language by default without explicit user choice can be a natural-language policy violation.

Description-Behavior Mismatch

Medium
Confidence
90% confidence
Finding
The skill stores parsed results persistently under the user’s home directory by default, which can leave sensitive document contents on disk longer than the user expects. In a PDF parsing context this is significant because documents may contain confidential research, contracts, or personal data.

External Transmission

Medium
Category
Data Exfiltration
Content
if extra_formats: data["extra_formats"] = extra_formats
    if no_cache: data["no_cache"] = True
    
    res = requests.post("https://mineru.net/api/v4/extract/task", headers=get_header(), json=data)
    result = res.json()
    if result.get("code") == 0:
        return result["data"]["task_id"]
Confidence
70% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
if extra_formats: data["extra_formats"] = extra_formats
    if no_cache: data["no_cache"] = True
    
    res = requests.post("https://mineru.net/api/v4/extract/task", headers=get_header(), json=data)
    result = res.json()
    if result.get("code") == 0:
        return result["data"]["task_id"]
Confidence
70% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
Local PDF files are uploaded to a remote service without an explicit consent or warning step at the point of transmission. Because the skill is for document parsing, this can leak sensitive local content to a third party and is more dangerous in this context than generic telemetry.

External Transmission

Medium
Category
Data Exfiltration
Content
data["extra_formats"] = extra_formats
    
    # 申请上传链接
    res = requests.post("https://mineru.net/api/v4/file-urls/batch", headers=get_header(), json=data)
    result = res.json()
    if result.get("code") != 0:
        print(f"❌ 申请链接失败: {result.get('msg')}")
Confidence
91% confidence
Finding
This outbound request initiates the process for uploading local files to a third-party service, and in context that means sensitive user documents may leave the machine. In a PDF parsing skill, undisclosed external transmission of local files is a real security/privacy issue, especially when the manifest does not prominently warn about it.

Tainted flow: 'url' from requests.post (line 207, network input) → requests.get (network output)

Medium
Category
Data Flow
Content
start = time.time()
    
    while True:
        res = requests.get(url, headers=get_header())
        result = res.json()
        if result.get("code") != 0:
            return None
Confidence
65% confidence
Finding
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Tainted flow: 'url' from requests.post (line 207, network input) → requests.get (network output)

Medium
Category
Data Flow
Content
start = time.time()
    
    while True:
        res = requests.get(url, headers=get_header())
        result = res.json()
        if result.get("code") != 0:
            return None
Confidence
65% confidence
Finding
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Tainted flow: 'url' from requests.post (line 207, network input) → requests.get (network output)

Medium
Category
Data Flow
Content
os.makedirs(out_dir, exist_ok=True)
    
    print(f"📥 下载...")
    r = requests.get(url, stream=True)
    with open(zip_path, "wb") as f:
        for c in r.iter_content(8192):
            f.write(c)
Confidence
96% confidence
Finding
The code downloads a ZIP from a URL returned by the remote MinerU service without validating the hostname, scheme, response size, or content type. If the upstream API is compromised or manipulated, this creates an SSRF-style trust boundary issue and enables retrieval of attacker-controlled content that is immediately processed locally.

Natural-Language Policy Violations

Low
Confidence
86% confidence
Finding
The options table specifies '--lang' defaulting to 'ch', which imposes a specific language/locale by default in the skill's natural-language documentation. The file does not indicate that the user is asked to choose a language first or that the locale default is justified by a region-specific constraint.

Missing User Warnings

Low
Confidence
93% confidence
Finding
The code downloads and extracts a remote ZIP archive without warning the user and without archive safety checks. This is dangerous because attacker-controlled or compromised upstream content could write unexpected files locally, including via ZIP slip path traversal during extraction.

Static analysis

No suspicious patterns detected.