Back to skill

Security audit

Pet-Game workflow

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed project backup workflow, but it tells agents to run a local Python wrapper broadly and automatically while that wrapper loads unreviewed external code and accepts unsafe paths.

Install only if you trust the local backup_core implementation at the hardcoded path and are comfortable with agents running the backup wrapper automatically during edits and commits. Review or vendor the backup core, restrict paths to the project directory, and add confirmation for restore and clean before relying on it.

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
backup_wrapper.py:25
Finding

Project Directory Traversal Through Unvalidated Relative Paths

Content
View full analysis

Vulnerability Details

File Location: backup_wrapper.py, lines 25-42
Vulnerability Type: Path traversal and insufficient path validation
Risk Level: High

Vulnerable Code

python
    if action == 'backup':
        rel_path = sys.argv[2]
        full_path = os.path.join(PROJECT_PATH, rel_path)
        element = sys.argv[3] if len(sys.argv) > 3 else None
        result = sb.backup(full_path, element)
        print(result)

    elif action == 'list':
        rel_path = sys.argv[2]
        full_path = os.path.join(PROJECT_PATH, rel_path)
        versions = sb.list_versions(full_path)
        for i, v in enumerate(versions):
            print(f"{i}: {v['time']} | {v.get('element', 'baseline')}")

    elif action == 'restore':
        rel_path = sys.argv[2]
        full_path = os.path.join(PROJECT_PATH, rel_path)
        idx = int(sys.argv[3]) if len(sys.argv) > 3 else 0
        result = sb.restore(full_path, idx)
        print(result)

Technical Analysis

The wrapper treats sys.argv[2] as a project-relative path but does not verify that it is actually relative or that its canonical destination remains inside PROJECT_PATH. os.path.join() performs path construction only; it does not enforce directory containment.

A path containing parent-directory components, such as ..\..\sensitive-file, can resolve outside the intended project directory. On supported platforms, an absolute path can also override or otherwise escape the intended base-path semantics. The resulting path is passed to SmartBackup.backup(), SmartBackup.list_versions(), or SmartBackup.restore() without validation.

The exact filesystem behavior of those methods cannot be established because backup_core is not included in the audited project. Nevertheless, the wrapper violates its own trust boundary and provides the external component with attacker-selected out-of-project paths.

Attack Path

...[truncated 1422 chars]

Remediation
View remediation

Remediation Suggestions

  1. Reject absolute input paths.
  2. Canonicalize both the project root and candidate path with os.path.realpath().
  3. Verify containment with os.path.commonpath() before invoking any backup-engine method.
  4. Apply the validation uniformly to backup, list, and restore.
  5. Reject paths that resolve through symbolic links outside the project.
  6. Add tests covering parent traversal, absolute paths, mixed separators, drive-qualified paths, symbolic links, and valid project-relative paths.
  7. Implement equivalent containment validation inside SmartBackup as defense in depth.

Example hardening pattern:

python
def resolve_project_path(rel_path):
    if os.path.isabs(rel_path):
        raise ValueError("Absolute paths are not allowed")

    project_root = os.path.realpath(PROJECT_PATH)
    candidate = os.path.realpath(os.path.join(project_root, rel_path))

    try:
        contained = os.path.commonpath([project_root, candidate]) == project_root
    except ValueError:
        contained = False

    if not contained:
        raise ValueError("Path escapes the project directory")

    return candidate

Replace each direct os.path.join(PROJECT_PATH, rel_path) call with resolve_project_path(rel_path).

T08 · Insecure Dependencies

Error
Location
backup_wrapper.py:8
Finding

Unverified Code Execution Through a Mutable External Python Import

Content
View full analysis

Vulnerability Details

File Location: backup_wrapper.py, lines 8-12
Vulnerability Type: Unverified external dependency and Python import-path manipulation
Risk Level: High

Vulnerable Code

python
import sys
import os
sys.path.insert(0, r'C:\Users\marsz\.qclaw\workspace\tools\backup_system\core')

from backup_core import SmartBackup

PROJECT_PATH = r'C:\Users\marsz\.qclaw\workspace\pet-game'

Technical Analysis

The wrapper inserts a machine-specific external directory at index zero of sys.path and then imports backup_core. Index zero has the highest import precedence, so Python will load backup_core from this mutable external location before searching normal package locations.

The imported module is not included in the audited project, has no pinned version, and is not authenticated through a hash or signature. Python executes module-level code immediately during import. Consequently, replacing or modifying backup_core.py, or an equivalent importable package in the preferred directory, results in code execution whenever the wrapper starts—even before argument validation or a backup action occurs.

This design also prevents a complete review of critical backup and restoration behavior. The documentation instructs agents to execute the wrapper before every file modification, increasing the frequency with which the unverified dependency is loaded.

Attack Path

  1. An attacker obtains write access to:
    text
    C:\Users\marsz\.qclaw\workspace\tools\backup_system\core
    
  2. The attacker creates or modifies backup_core.py and adds malicious module-level code.
  3. A user or agent follows the workflow in SKILL.md and launches backup_wrapper.py.
  4. The wrapper places the attacker-writable directory first in sys.path.
  5. from backup_core import SmartBackup imports the modified module.
  6. Python executes the malicious module-level code with the invoking user's pr ...[truncated 604 chars]
Remediation
View remediation

Remediation Suggestions

  1. Vendor the reviewed backup implementation inside the project or distribute it as a properly versioned package.
  2. Remove the hardcoded sys.path.insert(0, ...) modification.
  3. Pin the dependency to an audited version and verify its integrity using a trusted package lock file, cryptographic hash, or signature.
  4. Ensure dependency directories are not writable by untrusted users or lower-privileged processes.
  5. Use a dedicated virtual environment with controlled installation sources and disable unsafe fallback package indexes.
  6. Review backup_core before deployment, particularly its backup, listing, restoration, and cleanup methods.
  7. If an external local component is unavoidable, resolve its expected file explicitly, verify its digest before loading it, and fail closed when verification fails.
  8. Avoid running this workflow with administrative privileges and restrict the backup process to the minimum filesystem permissions it requires.
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)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

标题中直接以中文定义技能内容,且全文未说明是否允许其他语言、是否基于用户偏好切换语言,构成潜在的语言/locale 强制要求。根据规则,若未提供用户选择或明确的地区合规理由,应视为自然语言策略风险。

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill declares very broad automatic trigger conditions, including any file modification under the project and any Git commit, which can cause it to activate in many routine editing scenarios without clear user intent. This increases the chance that an agent will perform side-effecting actions such as invoking local scripts or enforcing workflow steps unexpectedly, expanding the attack surface and enabling abuse if the referenced tooling is unsafe or later replaced.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The script exposes restore and clean commands that can overwrite files or delete backup history, but it provides no confirmation prompt before execution. Although results are printed afterward, there is no prior user-facing warning or inline comment describing the destructive nature of these operations.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

Comments and CLI usage messages are presented only in Chinese, which imposes a specific language on users without opt-in or justification. The policy allows locale constraints when clearly documented and justified, but this file does not state that the tool is intentionally limited to Chinese-speaking users.

Content

No source excerpt is available for this finding.