Back to skill

Security audit

OW Strategy 3 Step | 大恩专题策略三步法

Security checks for vulnerabilities and agentic risk

Overview

This skill is a real-estate marketing template, but its helper script can write project files outside its intended folder if given a crafted project name.

Review this before installing. The marketing guidance itself is ordinary, but avoid running the included project helper with untrusted or path-like project names until the filename handling is fixed; project names should be sanitized and constrained to the intended project directory.

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/three_steps.py:18
Finding

Path Traversal Allows File Creation or Overwrite Outside the Project Directory

Content
View full analysis

Vulnerability Details

File Location: scripts/three_steps.py, lines 18–35
Vulnerability Type: Path traversal and arbitrary JSON file overwrite
Risk Level: Medium

Vulnerable Code

python
def create_project(project_name):
    """创建新项目"""
    ensure_dirs()
    
    project = {
        "name": project_name,
        "created_at": datetime.now().isoformat(),
        "status": "draft",
        "steps": {
            "step1": {"title": "核心课题", "content": "", "completed": False},
            "step2": {"title": "解决方案", "content": "", "completed": False},
            "step3": {"title": "传播规划", "content": "", "completed": False}
        }
    }
    
    project_file = PROJECTS_DIR / f"{project_name}.json"
    project_file.write_text(json.dumps(project, ensure_ascii=False, indent=2))
    
    return project

Technical Analysis

The project_name parameter originates from the command-line argument sys.argv[2] and is inserted directly into a filesystem path. The code does not reject path separators, parent-directory components such as .., absolute paths, or other unsafe filename characters.

Because pathlib.Path preserves traversal components when joining paths, a project name such as ../../target produces a destination equivalent to:

text
state/projects/../../target.json

After filesystem path resolution, this destination is outside the intended state/projects directory. The use of Path.write_text() also overwrites an existing destination by default. There is no containment check, filename allowlist, or exclusive-create protection.

Exploitation is constrained to locations writable by the process, and the destination receives fixed JSON project data. The implementation also appends .json, which restricts the target filename. These constraints reduce—but do not eliminate—the potential for destructive file overwrite.

Attack Path

  1. An attacker gains ...[truncated 1134 chars]
Remediation
View remediation

Remediation Suggestions

  1. Apply a strict allowlist to project names, permitting only a limited set of characters such as letters, digits, spaces, underscores, and hyphens.
  2. Explicitly reject absolute paths, . and .. path components, forward slashes, backslashes, and control characters.
  3. Resolve the final destination and verify that it remains beneath the resolved project directory before writing.
  4. Use exclusive file creation if replacing existing projects is not intended.
  5. Specify UTF-8 explicitly and provide a controlled error when validation or creation fails.

Example hardening:

python
import json
import re
from pathlib import Path

SAFE_PROJECT_NAME = re.compile(r"^[A-Za-z0-9 _-]{1,100}$")

def create_project(project_name):
    ensure_dirs()

    if not SAFE_PROJECT_NAME.fullmatch(project_name):
        raise ValueError("Project name contains unsupported characters")

    base_dir = PROJECTS_DIR.resolve()
    project_file = (base_dir / f"{project_name}.json").resolve()

    if project_file.parent != base_dir:
        raise ValueError("Project path escapes the project directory")

    project = {
        "name": project_name,
        "created_at": datetime.now().isoformat(),
        "status": "draft",
        "steps": {
            "step1": {
                "title": "Core Challenge",
                "content": "",
                "completed": False
            },
            "step2": {
                "title": "Solution",
                "content": "",
                "completed": False
            },
            "step3": {
                "title": "Communication Plan",
                "content": "",
                "completed": False
            }
        }
    }

    with project_file.open("x", encoding="utf-8") as output:
        json.dump(project, output, ensure_ascii=False, indent=2)

    return project

If legitimate project replacement is r ...[truncated 143 chars]

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

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest description lists trigger words such as “专题策略”, “三步法”, “快速策划”, and “策略提案” without clarifying exact invocation boundaries, exclusions, or required context. Several of these phrases are generic within marketing work and could match ordinary user discussion rather than intentional skill activation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The file presents an English overview but much of the operational content and examples remain in Chinese, and there is no statement about supported languages or user language preference. This can create an implicit locale constraint without opt-in, which falls under language/locale policy concerns.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module title and CLI help/output strings indicate the skill is designed exclusively for Chinese-language interaction. Under the policy rule, forcing a specific language without user opt-in can be a natural-language policy violation when no alternative or justification is provided.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The project name is used directly in the output filename, allowing path traversal or overwriting unintended files if a user supplies values such as '../x'. Because the script writes attacker-controlled data to disk without validating or constraining the path, a local user can cause file creation outside the intended projects directory.

Content

No source excerpt is available for this finding.