Back to skill

Security audit

Sizeup

Security checks for vulnerabilities and agentic risk

Overview

This is a local disk-usage analyzer whose filesystem reads match its stated purpose, with some implementation caveats users should understand.

Install only if you are comfortable with a local tool reading directory names, file sizes, and extensions under paths you ask it to scan. Be careful running it on untrusted directories because crafted filenames may affect terminal display, and do not rely on --depth as a hard privacy or performance boundary.

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

T09 · Insecure Skill Coding Practices

Warning
Location
sizeup.py:127
Finding

Terminal Escape Injection Through Untrusted File Names

Content
View full analysis

Vulnerability Details

File Location: sizeup.py:127-145, sizeup.py:203-221; duplicated in scripts/sizeup.py:127-145, scripts/sizeup.py:203-221
Vulnerability Type: Unsanitized terminal output
Risk Level: Medium

Vulnerable Code

python
print(f"{prefix}{connector}{color}{size_str:>8}\033[0m  {name}")

children = node.get("children", [])
# Filter by min_size
visible = [c for c in children if c.get("size", 0) >= min_size]
truncated = len(visible) - max_items if len(visible) > max_items else 0
visible = visible[:max_items]

new_prefix = prefix + ("    " if is_last else "│   ")
for i, child in enumerate(visible):
    is_child_last = (i == len(visible) - 1) and truncated <= 0
    if "children" in child:
        print_tree(child, min_size, new_prefix, is_child_last, max_items)
    else:
        connector = "└── " if is_child_last else "├── "
        s = format_size(child.get("size", 0))
        cs = "\033[91m" if child["size"] >= 1073741824 else \
             "\033[33m" if child["size"] >= 104857600 else \
             "\033[36m" if child["size"] >= 10485760 else "\033[0m"
        print(f"{new_prefix}{connector}{cs}{s:>8}\033[0m  {child['name']}")

Additional affected output paths include:

python
for i, (size, fp) in enumerate(files, 1):
    rel = os.path.relpath(fp, path)
    print(f"  {i:>3}. {format_size(size):>8}  {rel}")
python
for ext, info in list(exts.items())[:25]:
    print(f"  {ext:<12} {info['count']:>7,} {format_size(info['size']):>10}")

Technical Analysis

File names, relative paths, directory names, and extensions are controlled by the contents of the scanned filesystem. The program writes these values directly to an interactive terminal without escaping control characters.

A malicious file name can contain ANSI CSI or OSC escape sequences. When the file is displayed in tree, top-file, or extension mode, the terminal may interp ...[truncated 1516 chars]

Remediation
View remediation

Remediation Suggestions

Sanitize every filesystem-derived value before writing it to a terminal:

  1. Replace ASCII control characters, DEL, C1 controls, and escape bytes with visible escaped representations.
  2. Apply the same sanitizer to names, relative paths, extensions, and the displayed root path.
  3. Keep raw path values only in structured output such as JSON, where they must remain encoded through json.dumps().
  4. Consider disabling application-generated colors when output is not connected to a TTY.
  5. Add tests using names containing escape, newline, carriage-return, tab, OSC, and CSI sequences.

A minimal defensive helper could use ascii(value) or repr(value) for terminal display. A more readable implementation may preserve safe printable Unicode characters while rendering unsafe code points as \xNN, \uNNNN, or named escapes.

T09 · Insecure Skill Coding Practices

Note
Location
sizeup.py:64
Finding

Depth Limit Does Not Restrict Filesystem Traversal

Content
View full analysis

Vulnerability Details

File Location: sizeup.py:64-68, sizeup.py:92-103, sizeup.py:224; duplicated in scripts/sizeup.py:64-68, scripts/sizeup.py:92-103, scripts/sizeup.py:224
Vulnerability Type: Misleading traversal boundary and uncontrolled resource consumption
Risk Level: Low

Vulnerable Code

python
elif entry.is_dir(follow_symlinks=False):
    if depth is not None and current_depth >= depth:
        # Just get total size without recursing
        dir_size = get_dir_size(entry.path)
        result["size"] += dir_size
        result["dirs"] += 1

The called function still recursively walks the complete subtree:

python
def get_dir_size(path):
    """Quick total size of a directory."""
    total = 0
    try:
        for root, dirs, files in os.walk(path):
            for f in files:
                try:
                    total += os.path.getsize(os.path.join(root, f))
                except (OSError, PermissionError):
                    pass
    except (PermissionError, OSError):
        pass
    return total

The user-supplied limit is passed to the affected scanning logic as follows:

python
result = scan_dir(path, depth=args.depth)

Technical Analysis

The documented --depth N option is described as limiting recursion. However, when scan_dir() reaches the selected depth, it calls get_dir_size() for each child directory. get_dir_size() uses unrestricted os.walk(), so it enumerates every descendant below the apparent boundary and performs metadata lookups for all discovered files.

Consequently, the option limits the detail represented in the output tree but does not impose a hard filesystem traversal boundary. This mismatch can cause users to scan much more data than intended.

Attack Path

  1. A user invokes sizeup on a broad, mounted, remote, or attacker-influenced directory and supplies --depth expecting recur ...[truncated 1023 chars]
Remediation
View remediation

Remediation Suggestions

Choose and clearly implement one of the following designs:

  1. Hard traversal limit: Stop scanning descendants when current_depth reaches the requested limit. Do not call unrestricted os.walk() at the boundary.
  2. Display-only limit: Rename the option to indicate that it only controls displayed tree depth and explicitly document that aggregate directory sizes require complete recursive traversal.
  3. Separate controls: Provide distinct options for display depth and maximum traversal depth.

For stronger resource controls, also consider maximum entry counts, scan deadlines, filesystem-boundary controls, and an option to skip network mounts. Add regression tests proving that paths below a hard traversal boundary are never enumerated.

Vulnerability Patterns
  • 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
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (1)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill advertises filesystem analysis capabilities over arbitrary paths, but the manifest does not declare any explicit tool scope such as permissions or allowed-tools. That creates an authorization ambiguity: an agent or reviewer cannot tell from the metadata what files the skill is expected to access, increasing the risk of over-broad file reads or unintended access to sensitive local data.

Content

No source excerpt is available for this finding.