Back to skill

Security audit

Tiangong Wps Word Automation

Security checks for vulnerabilities and agentic risk

Overview

This is a real document automation skill, but it needs Review because it opens Word/WPS documents through COM without active-content protections and has under-scoped write and merge behavior.

Install only if you intend to automate trusted Word/WPS documents on Windows. Avoid using it on documents from unknown sources unless Office/WPS macro and Protected View policies are enforced, use separate output paths, keep backups, and consider pinning pywin32 before installation.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/wps_word_automation.py:14
Finding
Untrusted Documents Are Opened Without Explicitly Disabling Active Content<![CDATA[ ## Vulnerability Details **File Location**: `scripts/wps_word_automation.py`, lines 14–29 **Vulnerability Type**: Unsafe processing of untrusted Office documents **Risk Level**: High ### Vulnerable Code ```python def get_app(app_name: str, visible: bool): import win32com.client # type: ignore progids = APP_PROGIDS.get(app_name, []) for pid in progids: try: app = win32com.client.Dispatch(pid) app.Visible = bool(visible) return app except Exception: continue # fallback to Word app = win32com.client.Dispatch("Word.Application") app.Visible = bool(visible) return app def open_doc(app, path: str): return app.Documents.Open(path, ReadOnly=False) ``` ### Technical Analysis The application creates a Microsoft Word or WPS Writer COM instance and opens a user-supplied document in writable mode. It does not explicitly force-disable macros, use Protected View, validate the input extension, or otherwise restrict active document content. Consequently, macro-enabled documents and other potentially active formats are passed directly to the installed Office application. Whether active content executes depends on the application version, trust-center configuration, trusted-location settings, document provenance, and related host security controls. Independently of macro behavior, opening an attacker-controlled document exposes the Office/WPS parser to potentially malicious content. The same `open_doc` function is used by document-processing commands such as `read`, `replace`, `insert`, `headings`, `header-footer`, `page-break`, `split`, `export`, and `image`. ### Attack Path 1. An attacker supplies or recommends a malicious Office or WPS document. 2. A user or agent invokes one of the Skill commands with the document as `--input`. 3. The script starts Word or WPS through COM. 4. `Documents.Open(path, ReadOnly=False)` opens the document without first enforcing ma ...[truncated 826 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Set the Office automation security policy to force-disable macros before opening any untrusted document. Preserve the previous value and restore it during cleanup. 2. Open untrusted documents through Protected View where supported, or reject them if Protected View cannot be enforced. 3. Implement an explicit extension allowlist for ordinary non-macro formats. Reject macro-enabled formats such as `.docm`, `.dotm`, and equivalent WPS formats unless the caller explicitly authorizes them. 4. Consider opening source documents read-only when a command does not need in-place modification. 5. Disable automatic link updates and other external-content processing when opening documents. 6. Run document automation in a sandboxed, low-privilege process or isolated environment, particularly for documents from untrusted sources. 7. Use `try/finally` cleanup to ensure documents and the application are closed and security settings are restored after errors. 8. Document that Office/WPS security updates must be maintained because document parsing itself remains an attack surface. ]]>

T08 · Insecure Dependencies

Note
Location
SKILL.md:13
Finding
Runtime Dependency Installation Is Unpinned and Unverified<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, line 13 **Vulnerability Type**: Unpinned third-party dependency **Risk Level**: Low ### Vulnerable Code ```text python -m pip install pywin32 ``` ### Technical Analysis The installation instruction requests `pywin32` without a version constraint, lockfile, artifact hash, or explicit trusted package source. The resolved artifact can therefore change between installations, reducing reproducibility and allowing an unreviewed future release to enter the execution environment. No evidence was found that the currently named package is malicious or typosquatted. The risk arises from mutable dependency resolution and the absence of integrity controls rather than from a confirmed malicious package. ### Attack Path 1. A user follows the documented installation command. 2. `pip` resolves the package version and artifact available from its configured index at installation time. 3. If the package release, publisher account, configured index, local package mirror, or dependency-resolution path has been compromised, an altered artifact may be installed. 4. Installed package code can subsequently execute during import or package operation under the privileges of the user running Python. ### Impact Assessment A compromised dependency could execute Python code with the privileges of the installing or executing user. This could affect files, documents, credentials, and network resources accessible to that account. The practical likelihood is reduced because the documentation names the established `pywin32` package directly and no malicious dependency behavior was observed in the audited project. The principal confirmed weakness is the lack of version and integrity pinning. ]]>
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin `pywin32` to a reviewed, compatible version. 2. Provide a requirements or lock file containing cryptographic hashes for approved artifacts. 3. Install with hash enforcement, for example through `pip install --require-hashes -r requirements.txt`. 4. Use an approved package index or organization-controlled mirror and explicitly document the expected source. 5. Periodically review and update the pinned version to receive security fixes. 6. Validate supported Python and Windows versions so users do not need to bypass the pinned dependency due to compatibility failures. ]]>
Vulnerability Patterns
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • 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 (5)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The documented behavior conflicts with the stated scope: the skill says it is for single-document actions, yet it includes a multi-document merge command, and it claims image replacement without documenting or evidencing that behavior. Description-behavior mismatches are dangerous because they can mislead users and reviewers about operational scope, causing broader file processing or unexpected modifications than intended.

Lp3

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding
The skill advertises file-modifying capabilities through documented save, export, split, merge, and image operations, but it does not declare any tool scope such as permissions or allowed-tools. That omission weakens policy enforcement and informed consent, because an orchestrating system may not correctly surface that the skill can write or create files affecting user data.

Description-Behavior Mismatch

Medium
Confidence
98% confidence
Finding
The manifest states the skill is limited to single-document operations, but the documented merge command accepts multiple inputs and produces a combined output. This inconsistency can defeat user expectations and safety review assumptions by expanding the data scope from one file to many, increasing the chance of unintended disclosure or destructive processing.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
Several commands save, export, split, merge, or otherwise create modified document files, but the documentation does not prominently warn about write effects, output creation, or overwrite risk. In a document automation context, this increases the chance of accidental data loss, unintended alteration of important files, or silent generation of derivative copies containing sensitive content.

Intent-Code Divergence

Medium
Confidence
96% confidence
Finding
The notes tell users to avoid batch usage and describe the skill as single-document only, yet the documented commands include multi-document processing via merge. Conflicting guidance is a safety issue because operators may rely on the note while the implementation still allows broader processing, leading to accidental handling of more data than expected.

Static analysis

No suspicious patterns detected.