Back to skill

Security audit

Office Document Editor

Security checks for vulnerabilities and agentic risk

Overview

This office-document editing skill is mostly coherent, but it includes unsafe SFTP handling and broad document transfer behavior that could expose or corrupt user files.

Install only if you are comfortable with a document editor that can read local files, download documents from URLs/SFTP, write edited outputs, and optionally upload files by SFTP. Avoid untrusted SFTP/URL inputs until path validation and dependency pinning are fixed, and do not use the PPTX slide rearrange feature on important presentations.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/fetch_file.sh:91
Finding
SFTP Batch Command Injection Through Unvalidated Paths<![CDATA[ ## Vulnerability Details **File Location**: `scripts/fetch_file.sh:91-103` **Vulnerability Type**: SFTP batch command injection **Risk Level**: High ### Vulnerable Code ```bash REMOTE_PATH="${SFTP_PATH#*:}" echo " User/Host: $USER_HOST" echo " Remote path: $REMOTE_PATH" # Create temporary batch file BATCH_FILE=$(mktemp) cat > "$BATCH_FILE" << EOF get $REMOTE_PATH $OUTPUT EOF # Execute SFTP sftp -b "$BATCH_FILE" "$USER_HOST" ``` ### Technical Analysis The script derives `REMOTE_PATH` from a caller-controlled SFTP URL and writes it directly into an SFTP batch file. The caller-controlled `OUTPUT` value is inserted into the same command without validation or escaping. Shell quoting around the here-document does not make its contents safe for the SFTP batch-command parser. In particular, newline characters in either value can terminate the intended `get` command and introduce another SFTP batch instruction. OpenSSH SFTP supports commands interpreted by its own command language, including local shell execution through the `!` command. Consequently, an attacker able to influence the script arguments can turn a file-retrieval operation into arbitrary command execution under the account running the Skill. ### Attack Path 1. The attacker supplies a crafted `sftp://` or `ssh://` source to `fetch_file.sh`. 2. The source contains a newline in its remote-path component followed by an additional SFTP batch instruction. 3. The script extracts the crafted value into `REMOTE_PATH`. 4. The here-document writes both the intended `get` instruction and the injected instruction into the temporary batch file. 5. `sftp -b` parses the injected line as a separate command. 6. If a local-shell instruction is injected, the command runs with the permissions and environment of the Skill process. The output filename is another injection surface if an untrusted caller can control the second script argument. ### Impact Assessment Successful exploitation can provide ...[truncated 602 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Reject carriage returns, line feeds, NUL bytes, and other SFTP command-language control characters in `REMOTE_PATH`, `OUTPUT`, and `USER_HOST`. - Apply a strict allowlist for SFTP endpoint syntax and expected remote-path characters. - Do not construct SFTP batch programs from untrusted text where an API or safer transfer mechanism is available. - If batch mode must be retained, use a dedicated escaping routine designed for OpenSSH SFTP syntax; shell escaping alone is insufficient. - Restrict output to a controlled working directory and reject absolute paths and traversal components when arbitrary destinations are unnecessary. - Install an `EXIT` trap immediately after creating the temporary file so it is removed on errors or interruption. - Run SFTP operations in a sandbox with minimal filesystem and network access. - Add regression tests containing newlines, quotes, spaces, command prefixes, and malicious output filenames, verifying that all such inputs are rejected before SFTP starts. ]]>

T08 · Insecure Dependencies

Warning
Location
scripts/generate_diff.py:18
Finding
Unpinned Runtime Package Retrieval and Execution via uvx<![CDATA[ ## Vulnerability Details **File Location**: `scripts/generate_diff.py:18-24` **Vulnerability Type**: Unpinned runtime dependency execution **Risk Level**: Medium ### Vulnerable Code ```python result = subprocess.run( ["uvx", "mammoth", "--output-format=markdown", str(docx_path)], capture_output=True, text=True, check=True ) return result.stdout ``` ### Technical Analysis Diff generation invokes `mammoth` through `uvx` without specifying a reviewed and pinned package version. Depending on the local cache and environment, `uvx` can resolve, download, install, and execute package code from a package registry at runtime. This means that the effective executable is not fully contained in the audited Skill and can change after review. A compromised package release, registry account, package source, or dependency can therefore execute code locally. The process is also passed the path of a potentially sensitive document and runs with the permissions of the Agent account. Although runtime package installation supports the document-conversion feature, unrestricted resolution is not the minimum privilege necessary. A locked, pre-reviewed dependency would provide the same functionality with less supply-chain exposure. ### Attack Path 1. A user requests generation of a DOCX diff. 2. `generate_diff.py` invokes `uvx mammoth`. 3. `uvx` resolves the package and its transitive dependencies from its configured source if a suitable trusted copy is not already fixed locally. 4. A malicious or compromised package version is installed and executed. 5. The package receives the sensitive document path and executes with the Skill process's filesystem and network permissions. 6. Malicious package code can inspect local files, alter generated results, or transmit accessible information. This path depends on compromise or manipulation of the dependency supply chain; the project does not itself contain a malicious `mammoth` payload. ### Impact Assessmen ...[truncated 562 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Declare `mammoth` and all other runtime packages in a project dependency manifest. - Pin exact reviewed versions and commit the generated lock file. - Enforce package hashes or equivalent integrity verification where supported. - Install dependencies during a controlled deployment step rather than retrieving them while processing documents. - Invoke `mammoth` from the locked project environment instead of using an unconstrained `uvx mammoth` command. - Restrict dependency sources to approved registries and disable unexpected extra indexes. - Review and update dependencies through an explicit maintenance process with vulnerability and provenance checks. - Run document conversion in a sandbox without unnecessary network access and with filesystem access limited to the specific input and output locations. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/pptx_editor.py:112
Finding
PPTX Rearrangement Destructively Removes All Slides<![CDATA[ ## Vulnerability Details **File Location**: `scripts/pptx_editor.py:112-128` **Vulnerability Type**: Destructive document-handling logic **Risk Level**: Medium ### Vulnerable Code ```python # Create new slide order new_slides = [slides[i] for i in slide_order] # Delete all slides for i in range(len(prs.slides)): sp = prs.slides._sldIdLst[i] prs.slides._sldIdLst.remove(sp) # Add slides in the new order # Note: python-pptx does not directly support moving slides and requires # more complex handling. # This implementation only prints the suggested order. print(f"⚠️ 注意:python-pptx 不直接支援投影片重排") print(f" 建議順序:{slide_order}") return True ``` ### Technical Analysis The function constructs `new_slides` but never uses it to restore slide relationships. It then removes entries from the presentation's private `_sldIdLst` structure and returns `True`. The caller treats the return value as successful modification and later saves the presentation. Therefore, a supported and documented `rearrange` operation can produce a presentation with all slide references removed rather than a reordered presentation. Use of the private `_sldIdLst` implementation also bypasses stable public APIs and increases the risk of broken package relationships or malformed output. There is no post-operation validation, rollback, or atomic-save safeguard. ### Attack Path 1. A user or automated workflow supplies an edits file containing a slide action with `"action": "rearrange"` and valid indexes. 2. `edit_pptx_advanced` calls `rearrange_slides`. 3. The function validates the indexes and builds an unused `new_slides` list. 4. It removes all slide identifiers from the presentation. 5. The function returns `True`, so the caller records the operation as successful. 6. The altered presentation is saved to the requested output path without checking its slide count or integrity. No shell access or privilege escalation is obtained through this flaw; the exploit affects docum ...[truncated 727 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Disable and explicitly reject the `rearrange` action until a correct implementation is available. - Implement relationship-safe slide reordering that preserves slide IDs, relationships, notes, media, comments, and presentation metadata. - Do not mutate private `python-pptx` internals unless the implementation is comprehensively tested against supported versions. - Verify after editing that the output contains the expected number of slides and that its order matches the requested permutation. - Require `slide_order` to be a complete permutation with no duplicates or omissions unless partial selection is an explicitly documented feature. - Save to a temporary file, reopen and validate it, and then atomically replace the final output. - Refuse input and output paths that resolve to the same file unless an explicit backup and overwrite option is selected. - Return failure when rearrangement is unsupported rather than printing a warning and reporting success. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (32)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The inclusion of network file retrieval from URL/SFTP and possible upload/orchestration behavior exceeds the narrow editing purpose claimed in the description. That kind of scope creep is security-relevant because it expands attack surface to remote endpoints, credential handling, and data movement without sufficiently clear declaration or warning.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The inclusion of network file retrieval from URL/SFTP and possible upload/orchestration behavior exceeds the narrow editing purpose claimed in the description. That kind of scope creep is security-relevant because it expands attack surface to remote endpoints, credential handling, and data movement without sufficiently clear declaration or warning.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The inclusion of network file retrieval from URL/SFTP and possible upload/orchestration behavior exceeds the narrow editing purpose claimed in the description. That kind of scope creep is security-relevant because it expands attack surface to remote endpoints, credential handling, and data movement without sufficiently clear declaration or warning.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
The inclusion of network file retrieval from URL/SFTP and possible upload/orchestration behavior exceeds the narrow editing purpose claimed in the description. That kind of scope creep is security-relevant because it expands attack surface to remote endpoints, credential handling, and data movement without sufficiently clear declaration or warning.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The inclusion of network file retrieval from URL/SFTP and possible upload/orchestration behavior exceeds the narrow editing purpose claimed in the description. That kind of scope creep is security-relevant because it expands attack surface to remote endpoints, credential handling, and data movement without sufficiently clear declaration or warning.

Intent-Code Divergence

High
Confidence
98% confidence
Finding
The slide reordering function removes all slide IDs from the presentation even though the comments and messages state that python-pptx does not directly support reordering and imply a non-destructive advisory behavior. In a document-editing skill, this mismatch can lead to silent data loss or corrupted output when a user requests a reorder, making it a real integrity vulnerability rather than a harmless documentation issue.

Lp3

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding
The skill advertises and documents shell execution, file reads, and file writes but does not declare an explicit tool scope such as permissions or allowed-tools. This creates unnecessary ambient authority: an agent invoking the skill may access local files, uploaded media, and network-fetch helpers without a manifest-level restriction boundary.

Description-Behavior Mismatch

Medium
Confidence
93% confidence
Finding
The manifest positions the skill as document editing, but the documentation expands it into a general document fetcher from URLs and SFTP. That discrepancy is dangerous because reviewers and users may grant trust for local editing while overlooking remote retrieval and the associated risks of importing hostile content, contacting untrusted hosts, or mishandling sensitive files.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The phrase suggesting editing of any DOCX/PPTX file from any source is overly broad and may trigger the skill in contexts beyond what is safe or intended. Overbroad activation language is risky for agent orchestration because it can cause the skill to be selected for tasks involving sensitive local files, remote content, or unsupported formats without adequate checks.

Context-Inappropriate Capability

Medium
Confidence
91% confidence
Finding
Network-based file retrieval is not strictly necessary for document editing and materially expands the attack surface. It enables the skill to pull potentially malicious documents or interact with external infrastructure, which is especially risky in an agent setting where users may not realize the skill can make networked data movements.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The docs instruct users to fetch files from URLs and SFTP but do not provide a clear warning about external network access, credential exposure, or transmission of sensitive data. In an agent environment, omission of these warnings can lead to inadvertent disclosure or retrieval from untrusted sources under the mistaken assumption that the skill is purely local.

Session Persistence

Medium
Category
Rogue Agent
Content
## Creating Edit Rules

Create `edits.json` with your editing instructions:

```json
{
Confidence
60% 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.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
The editing workflow lacks a clear warning that commands produce modified output artifacts and that some changes, such as slide removals or overwrites, may be irreversible without backups. While more of a safety/integrity issue than classic exploitation, this can still cause loss of important user data in automated agent workflows.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The manifest describes a skill for both DOCX and PPTX document editing, but this implementation exclusively uses python-docx and opens files via Document(input_path), which is specific to DOCX. There is no code path for PowerPoint/PPTX editing in this file, so the implemented behavior is narrower than the stated skill description.

Description-Behavior Mismatch

Medium
Confidence
97% confidence
Finding
The skill is ներկայացված as a professional DOCX/PPTX editor with tracked changes and formatting preservation, but this file implements a broad file-ingestion utility instead of editing logic. While loading an uploaded/local file can support editing, network retrieval from arbitrary HTTPS and SFTP sources materially expands behavior beyond the manifest description.

Context-Inappropriate Capability

Medium
Confidence
92% confidence
Finding
The script allows arbitrary retrieval of files from external HTTPS and SFTP sources without validation, allowlisting, or user-facing trust controls. In an agent environment, this expands the trust boundary, can be used to import attacker-controlled content, and may enable SSRF-style access to internal endpoints or unauthorized network interaction depending on runtime network reachability.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
wget -O "$OUTPUT" "$SOURCE"
    else
        echo "❌ Error: Neither curl nor wget found"
        echo "   Please install: sudo apt install curl"
        exit 1
    fi
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Missing User Warnings

Medium
Confidence
87% confidence
Finding
The SFTP path performs remote network access and writes attacker-supplied content locally with no integrity verification, host-key handling policy, or explicit warning about trust and provenance. In practice this can result in users processing spoofed or tampered documents and may expose the environment to risky outbound connections or credential/host trust misuse.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
The module docstring and usage text are written only in Traditional Chinese, and additional user-facing messages throughout the script follow the same pattern. This imposes a specific language on users without opt-in or justification, matching the locale-policy violation criteria.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
def docx_to_text(docx_path):
    """使用 mammoth 轉換 DOCX 為純文字"""
    try:
        result = subprocess.run(
            ["uvx", "mammoth", "--output-format=markdown", str(docx_path)],
            capture_output=True,
            text=True,
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Context-Inappropriate Capability

Medium
Confidence
90% confidence
Finding
The manifest describes professional DOCX/PPTX editing and version control features, but this helper script shells out to `uvx mammoth` using `subprocess.run`. Spawning external processes is a broader execution capability than document editing itself and is not explicitly justified by the stated purpose.

Description-Behavior Mismatch

Medium
Confidence
93% confidence
Finding
The manifest describes a document editing skill focused on professional DOCX/PPTX editing, tracked changes, formatting preservation, highlights, strikethrough, and Git version control. This script additionally implements document acquisition from web URLs and remote SFTP servers, which is a broader file-transfer capability not reflected in the description.

Context-Inappropriate Capability

Medium
Confidence
90% confidence
Finding
Editing DOCX/PPTX files does not inherently require arbitrary network access. The URL and SFTP options introduce external network interaction and remote file movement capabilities that are not justified by the manifest's stated purpose of office document editing.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The script prints the full generated edits.json to the terminal, which may contain sensitive document text entered by the user, such as searched phrases, replacement text, or added content. Terminal output may be logged, captured in transcripts, or visible to bystanders, causing unintended disclosure of confidential document contents.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The script can upload edited documents to arbitrary SFTP destinations, creating an outbound data-transfer path for potentially sensitive files. In an office-document editing skill, this increases the risk of accidental data exfiltration because users may transmit confidential content without strong disclosure, validation, or guardrails.

Static analysis

No suspicious patterns detected.