Back to skill

Security audit

ofd-text-extractor

Security checks for vulnerabilities and agentic risk

Overview

This skill is a straightforward OFD text extractor with disclosed local file reading and optional JSON export, though it should be used carefully on untrusted or very large OFD files.

Install is reasonable if you need OFD text extraction. Run it only on OFD files you trust or have size-checked, avoid automated processing of arbitrary uploads without resource limits, and choose the JSON output path deliberately because it can overwrite a file at that path.

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/extract_ofd.py:44
Finding

Unbounded OFD Archive Processing Enables Resource Exhaustion

Content
View full analysis

Vulnerability Details

File Location: scripts/extract_ofd.py, lines 44–45, 85, 105, and 129
Vulnerability Type: Unrestricted ZIP archive decompression and in-memory XML processing
Risk Level: Medium

Vulnerable Code

python
with zipfile.ZipFile(ofd_path, 'r') as zf:
    # First: parse Document.xml to obtain the template-page mapping
    template_map = extract_template_map(zf)

    # Second: locate every page content file
    content_files = sorted([
        name for name in zf.namelist()
        if 'Pages/Page_' in name and name.endswith('/Content.xml')
    ])
python
doc_content = zf.read(doc_path).decode('utf-8')
python
content_xml = zf.read(page_path).decode('utf-8')
python
tpl_content = zf.read(tpl_path).decode('utf-8')

Technical Analysis

OFD files are ZIP archives whose contents are controlled by the file provider. The extractor enumerates all entries and loads matching document, page, and template XML entries entirely into memory through ZipFile.read().

No validation limits are imposed on:

  • The number of archive entries
  • The uncompressed size of an individual entry
  • The cumulative uncompressed size
  • The compression ratio
  • The number of pages or templates processed
  • XML and text complexity
  • Execution time or memory consumption

Consequently, a malicious archive can declare very large uncompressed XML entries despite having a small compressed size. The implementation may hold the decoded XML string, regular-expression results, and extracted output objects in memory simultaneously. Archives containing many qualifying page or template entries can also force repeated decompression, regex scanning, text extraction, sorting, and character-position calculation.

Although the implementation does not extract entries to the filesystem and therefore does not expose a demonstrated ZIP path-traversal issue, its unrestricted in-memory e ...[truncated 1615 chars]

Remediation
View remediation

Remediation Suggestions

  1. Inspect every ZipInfo record before reading archive content and reject archives that exceed strict limits for:

    • Maximum entry count
    • Maximum uncompressed size per entry
    • Maximum cumulative uncompressed size
    • Maximum compressed-to-uncompressed ratio
    • Maximum page and template count
  2. Apply checks immediately before every read rather than relying only on an initial archive-wide check. Track cumulative bytes across document, page, and template reads.

  3. Permit only expected OFD XML locations and reject duplicate, encrypted, malformed, or suspiciously named entries.

  4. Avoid unrestricted zf.read(). Open entries with zf.open() and read them incrementally through a bounded reader that aborts when the configured byte limit is reached.

  5. Parse XML incrementally where feasible and impose limits on extracted text length, TextObject count, TextCode count, and generated character-position records.

  6. Run untrusted document processing with OS-enforced memory, CPU, and execution-time limits. In service deployments, isolate extraction in a disposable least-privileged worker.

  7. Catch zipfile.BadZipFile, decompression errors, decoding failures, and resource-limit exceptions separately, returning a controlled validation error without retrying the same file indefinitely.

  8. Add regression tests using archives with excessive entry counts, large declared sizes, extreme compression ratios, oversized XML text, and many matching page/template entries.

Vulnerability Patterns
  • 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
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
83% confidence
Finding

The skill documentation invokes scripts that can write output files (-OutputFile / --output) but the skill manifest does not declare any permissions or allowed-tools scope. That mismatch weakens least-privilege controls and can allow the agent runtime to execute file-writing behavior without an explicit, reviewable permission boundary, increasing the risk of unintended overwrites or writing sensitive extracted data to disk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

This markdown file is entirely presented in Chinese and does not indicate that the skill is region- or locale-specific, nor does it offer an English or user-selectable alternative. Under the language/locale policy, forcing a single language without user opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.