Back to skill

Security audit

Video Hook Generator

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly does what it claims, but its optional save feature can write outside the chosen folder if the topic contains path characters.

Install only if you are comfortable with a local content-generation script. Avoid using --output with untrusted or path-like topic strings until the filename handling is fixed, and expect the skill to operate primarily in Chinese with broad activation phrases.

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/hook_generator.py:187
Finding

Output Path Traversal Through an Unsanitized Topic

Content
View full analysis

Vulnerability Details

File Location: scripts/hook_generator.py:187-198
Vulnerability Type: Path traversal and unauthorized file write
Risk Level: Medium

python
def save_to_file(hooks, topic, output_dir):
    """保存到文件"""
    import os
    import json
    from pathlib import Path

    date_str = datetime.now().strftime("%Y-%m-%d")
    out_path = Path(output_dir) / f"hooks_{topic[:10]}_{date_str}.json"
    out_path.parent.mkdir(parents=True, exist_ok=True)

    with open(out_path, "w", encoding="utf-8") as f:
        json.dump({"topic": topic, "hooks": hooks, "generated_at": date_str}, f, ensure_ascii=False, indent=2)

    return out_path

Technical Analysis

The topic value originates from the user-controlled --topic command-line argument. Its first ten characters are inserted directly into the output path without removing path separators, rejecting .. components, or verifying the resolved destination.

Although the generated path begins with the fixed hooks_ prefix, a slash in the topic can turn that prefix into a directory name. Subsequent traversal components can then escape the intended output directory. For example, a topic beginning with x/../../tmp produces a path structurally equivalent to:

text
<output_dir>/hooks_x/../../tmp_YYYY-MM-DD.json

After filesystem path resolution, this can target a location outside output_dir. The call to mkdir(parents=True, exist_ok=True) creates the attacker-influenced parent path, while open(..., "w") creates or truncates the resulting file.

Exploitation is constrained by the ten-character topic slice, the fixed filename prefix and date suffix, filesystem layout, and the permissions of the process. Nevertheless, the intended output-directory security boundary is not enforced.

Attack Path

  1. An attacker or untrusted caller invokes the script with --output enabled.
  2. The attacker supplies a --topic value ...[truncated 1151 chars]
Remediation
View remediation

Remediation Suggestions

  1. Do not use raw user input as a path component. Generate filenames from an opaque identifier, such as a UUID or a cryptographic hash of the topic.
  2. If a readable topic-derived filename is required, apply a strict allowlist and replace every character outside a limited set such as ASCII letters, digits, underscores, and hyphens.
  3. Resolve both the output directory and candidate path before writing, then verify that the candidate remains inside the output directory.
  4. Reject empty or invalid sanitized filenames rather than silently accepting dangerous input.
  5. Consider exclusive file creation with mode "x" if overwriting existing files is not required.

Example hardening approach:

python
import hashlib
from pathlib import Path

output_root = Path(output_dir).resolve()
output_root.mkdir(parents=True, exist_ok=True)

topic_id = hashlib.sha256(topic.encode("utf-8")).hexdigest()[:16]
out_path = (output_root / f"hooks_{topic_id}_{date_str}.json").resolve()

if not out_path.is_relative_to(output_root):
    raise ValueError("Resolved output path is outside the output directory")

with out_path.open("x", encoding="utf-8") as f:
    json.dump(
        {"topic": topic, "hooks": hooks, "generated_at": date_str},
        f,
        ensure_ascii=False,
        indent=2,
    )

Add regression tests using topics containing /, \, .., absolute-path syntax, Unicode separator-like characters, and symlinked output directories. Each test should verify that no file is created outside the resolved output root.

Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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
Findings (3)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger phrases are very broad, including generic requests like '爆款标题' and '开头怎么写', which overlap with normal writing assistance queries. This can cause unintended invocation of the skill, leading the agent to prioritize this skill's behavior in contexts where the user did not specifically intend to use it.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The skill description is entirely Chinese and assumes a Chinese-language interaction model without indicating fallback behavior or user choice. In multilingual environments, this can cause misrouting, confusion, or inappropriate responses if triggered for users expecting another language.

Content

No source excerpt is available for this finding.