Back to skill

Security audit

extract-static-wallpapers-from-wallpaperengine

Security checks for vulnerabilities and agentic risk

Overview

The skill is generally aimed at extracting Wallpaper Engine wallpapers, but its extractor can be tricked by a malicious package into writing files outside the chosen output folder.

Install only if you are comfortable reviewing or fixing the extractor first. Until it validates entry paths and confines writes to the output directory, run it only on trusted scene.pkg files inside a disposable working directory with low privileges.

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

Error
Location
scripts/extract_pkg.py:32
Finding

Arbitrary File Write Through Archive Path Traversal

Content
View full analysis

Vulnerability Details

File Location: scripts/extract_pkg.py, lines 32-55
Vulnerability Type: Archive extraction path traversal
Risk Level: High

Vulnerable Code

python
for i in range(num_entries):
    name_len = struct.unpack_from('<I', data, pos)[0]; pos += 4
    name = data[pos:pos + name_len].decode('ascii', errors='replace'); pos += name_len
    # NO alignment padding after filename in PKGV0023
    offset = struct.unpack_from('<I', data, pos)[0]; pos += 4
    size = struct.unpack_from('<I', data, pos)[0]; pos += 4
    entries.append((name, offset, size))
    print(f'  [{i}] {name}  offset={offset}  size={size}  ({size / 1024:.1f} KB)')

data_start = pos
print(f'\nData section at file offset: {data_start}')

# --- Extract all entry files ---
os.makedirs(out_dir, exist_ok=True)
tex_files = []

for name, offset, size in entries:
    file_offset = data_start + offset
    file_data = data[file_offset:file_offset + size]

    out_path = os.path.join(out_dir, name)
    os.makedirs(os.path.dirname(out_path), exist_ok=True)
    with open(out_path, 'wb') as f:
        f.write(file_data)

Technical Analysis

The filename assigned to name is read directly from attacker-controlled package metadata. The extractor then passes that value to os.path.join(out_dir, name) and writes package data to the resulting path without validating that its canonical destination remains inside out_dir.

os.path.join() does not enforce directory confinement. A filename containing parent-directory components such as ../../target can escape the extraction directory. An absolute filename may also cause the output directory component to be discarded. Platform-specific absolute paths, drive-qualified paths, and path separators can create equivalent conditions.

Because the code also invokes os.makedirs() for the attacker-selected parent path, it can create missing directories before w ...[truncated 1598 chars]

Remediation
View remediation

Remediation Suggestions

Canonicalize the output directory and each candidate destination before creating directories or writing data. Reject absolute paths, drive-qualified paths, empty filenames, and entries containing . or .. path components. Confirm confinement with os.path.commonpath() rather than relying on string-prefix comparisons.

A hardened implementation should follow this pattern:

python
base_dir = os.path.realpath(out_dir)
os.makedirs(base_dir, exist_ok=True)

normalized_name = name.replace('\\', '/')
if (
    not normalized_name
    or os.path.isabs(name)
    or os.path.splitdrive(name)[0]
    or any(part in ('', '.', '..') for part in normalized_name.split('/'))
):
    raise ValueError(f'Unsafe package entry path: {name!r}')

out_path = os.path.realpath(os.path.join(base_dir, *normalized_name.split('/')))
if os.path.commonpath([base_dir, out_path]) != base_dir:
    raise ValueError(f'Package entry escapes output directory: {name!r}')

parent = os.path.dirname(out_path)
os.makedirs(parent, exist_ok=True)

# Recheck containment and account for symlink races before writing.
if os.path.commonpath([base_dir, os.path.realpath(parent)]) != base_dir:
    raise ValueError(f'Unsafe package entry parent: {name!r}')

with open(out_path, 'xb') as f:
    f.write(file_data)

For stronger protection, extract into a newly created private directory, refuse symbolic links in every path component, avoid overwriting existing files, and use directory-relative file operations with no-follow semantics where the operating system supports them. Add automated tests covering ../, absolute paths, mixed separators, drive-qualified paths, nested traversal, symlink escapes, and ordinary valid nested entries.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (6)

Tp2

High
Category
MCP Tool Poisoning
Confidence
85% confidence
Finding

Mixing characters from multiple Unicode scripts in a single identifier is a common technique to create visually ambiguous tool names.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill claims to extract only static wallpaper PNGs, but the documented workflow explicitly extracts all files from the package first. That broader behavior can expose additional packaged assets or sensitive content beyond user intent, and the unsupported/loosely validated format handling may cause users to trust output completeness or correctness when parsing untrusted binary files. In the context of a file-extraction skill, description/behavior mismatch is more dangerous because users may authorize access expecting narrow processing while the skill performs bulk extraction.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill name, description, and all operating instructions are written entirely in Chinese, with no indication that another language can be used or that the locale is optional. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest says the skill extracts static wallpaper PNG images from scene.pkg files, but this code writes every entry from the package to disk before separately scanning .tex files for PNGs. That broader behavior goes beyond the stated purpose of extracting wallpaper images and materially expands what content is unpacked.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

A skill whose stated purpose is to extract static wallpaper PNGs does not obviously need to persist every embedded file from the package to disk. This gives the skill a general archive-unpacking capability unrelated to the narrower user intent described in the manifest.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

Archive entry names from the untrusted package are joined directly into output paths and written to disk without normalization or containment checks. A crafted package could use absolute paths or '..' traversal segments to overwrite files outside the intended extraction directory, making this significantly more dangerous in a skill that processes attacker-controlled archives.

Content

No source excerpt is available for this finding.