Back to skill

Security audit

Government Word Format Standardizer

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed Word document formatter with one availability hardening gap around oversized DOCX files, but no evidence of hidden commands, data theft, persistence, or deception.

Install only if you want documents forced into this specific Chinese official-document format and have the required fonts available. Use it on documents from trusted sources or in a resource-limited environment, because a crafted oversized DOCX could make conversion consume excessive memory or CPU.

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/convert_to_house_style.py:129
Finding

Unbounded DOCX Archive Decompression Enables Denial of Service

Content
View full analysis

Vulnerability Details

File Location: scripts/convert_to_house_style.py, lines 129-131
Vulnerability Type: Uncontrolled resource consumption through ZIP bomb decompression
Risk Level: Medium

Vulnerable Code

python
def read_zip_entries(docx_path: Path) -> dict[str, bytes]:
    with zipfile.ZipFile(docx_path, "r") as archive:
        return {name: archive.read(name) for name in archive.namelist()}

Technical Analysis

A DOCX file is a ZIP archive whose contents are controlled by the document provider. The converter enumerates every archive member and fully decompresses each member into memory. All resulting byte strings are retained simultaneously in a dictionary.

No validation or limits are applied to:

  • The number of archive members
  • The uncompressed size of an individual member
  • The aggregate uncompressed size
  • The ratio between compressed and uncompressed sizes
  • Processing time or memory consumption

The .docx filename-suffix check does not establish that the archive is safe. An attacker can construct a small, highly compressed DOCX whose members expand to a very large size. The same resource-exhaustion condition can be caused by an archive containing a very large number of members.

Attack Path

  1. An attacker creates a ZIP bomb or another oversized archive and gives it a .docx extension.
  2. The attacker submits the file for conversion through the Skill's normal workflow.
  3. The workflow invokes convert_to_house_style.py.
  4. convert() calls read_zip_entries() before applying any archive resource limits.
  5. archive.read(name) decompresses every member, while the dictionary comprehension retains every decompressed payload in memory.
  6. Memory and CPU consumption increase until the process slows substantially, raises an exception, or is terminated by the operating system.
  7. If conversion runs in a shared service, concurrent users or other workloads on the same worker may also become unavailable.

Imp

...[truncated 766 chars]

Remediation
View remediation

Remediation Suggestions

Validate the archive before decompressing any member:

  1. Set a conservative maximum number of ZIP members.
  2. Reject members whose declared uncompressed size exceeds a per-entry limit.
  3. Reject archives whose aggregate declared uncompressed size exceeds a total limit.
  4. Reject suspicious compression ratios, while accounting for empty or zero-byte compressed members.
  5. Permit only DOCX-relevant member names and reject malformed or duplicate critical parts.
  6. Read only the OOXML parts required for conversion rather than eagerly loading the entire archive.
  7. Stream unchanged members directly from the source archive to the output archive where practical.
  8. Apply process-level memory and execution-time limits as defense in depth.
  9. Return a clear validation error when limits are exceeded.

For example, perform metadata validation before reading payloads:

python
MAX_ENTRIES = 2_000
MAX_ENTRY_SIZE = 50 * 1024 * 1024
MAX_TOTAL_SIZE = 200 * 1024 * 1024
MAX_COMPRESSION_RATIO = 100


def validate_archive(archive: zipfile.ZipFile) -> None:
    members = archive.infolist()

    if len(members) > MAX_ENTRIES:
        raise ValueError("DOCX contains too many archive entries")

    total_size = 0
    for member in members:
        if member.file_size > MAX_ENTRY_SIZE:
            raise ValueError(f"DOCX entry is too large: {member.filename}")

        total_size += member.file_size
        if total_size > MAX_TOTAL_SIZE:
            raise ValueError("DOCX exceeds the total uncompressed-size limit")

        if member.file_size and member.compress_size == 0:
            raise ValueError(f"Invalid compressed entry: {member.filename}")

        if member.compress_size:
            ratio = member.file_size / member.compress_size
            if ratio > MAX_COMPRESSION_RATIO:
                raise ValueError(
                    f"Suspicious compression ratio for entry: {member.filename}"
                )


def read_zip_entries(docx_path: Path) ->
...[truncated 378 chars]
Vulnerability Patterns
  • 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
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (4)

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

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

md
# Format Rules

## Core Rules

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · references/format-rules.md (reported line 1)May include surrounding context.

md
# Format Rules

## Core Rules

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The embedded Word template XML sets fixed locale values such as en-US, zh-CN, and ar-SA in style and theme settings, rather than offering any user-selectable language or locale behavior. This can violate language/locale policy expectations because the file imposes predefined locale defaults across generated documents.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The file uses prescriptive natural language requiring specific Chinese fonts and formatting conventions, such as 方正小标宋简体, 仿宋_GB2312, 黑体, and 宋体. Because this is presented as a mandatory rule set with no indication that the user can choose language or locale, it may violate a language/locale policy under the stated criteria.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.