Back to skill

Security audit

file-organizer

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed local file organizer that can move files after preview and confirmation, with some usability and reliability cautions but no evidence of hidden or malicious behavior.

Install only if you want an agent to help reorganize local folders. Use the dry-run preview first, confirm the exact target directory, avoid running it on important folders without a backup, and be cautious with the recursive option because failures could leave some files already moved.

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/organize-files.ps1:53
Finding

Recursive destination collisions can cause partial filesystem reorganization

Content
View full analysis

Vulnerability Details

File Location: scripts/organize-files.ps1, lines 53–75 and 90–96
Vulnerability Type: Non-atomic destination collision handling
Risk Level: Medium

Vulnerable Code

powershell
# --- Collect loose files ---
$files = Get-ChildItem -LiteralPath $target -File -Recurse:$Recurse | Where-Object {
    $_.Name -notlike ".*" -and
    $_.FullName -ne $scriptFullName -and
    $_.Name -ne "organize-report.md"
}

if ($files.Count -eq 0) {
    Write-Host "No files to organize in $target"
    exit 0
}

# --- Plan the moves ---
$plan = foreach ($f in $files) {
    $cat = Get-Category $f
    $destDir = Join-Path $target $cat
    $dest = Join-Path $destDir $f.Name

    $i = 1
    while (Test-Path -LiteralPath $dest) {
        $name = [System.IO.Path]::GetFileNameWithoutExtension($f.Name)
        $ext = $f.Extension
        $dest = Join-Path $destDir "$name ($i)$ext"
        $i++
    }

    [PSCustomObject]@{
        File     = $f.Name
        Category = $cat
        From     = $f.FullName
        To       = $dest
    }
}
powershell
# --- Execute ---
$moved = 0
foreach ($p in $plan) {
    $destDir = Split-Path -Parent $p.To
    New-Item -ItemType Directory -Path $destDir -Force | Out-Null
    Move-Item -LiteralPath $p.From -Destination $p.To
    $moved++
}

Technical Analysis

The script calculates every destination before moving any files. Its collision check uses Test-Path, which only detects paths that already exist on disk. It does not detect duplicate destination paths generated earlier in the same in-memory plan.

When -Recurse is enabled, two files in different source subdirectories can have the same filename and category. If the corresponding destination does not exist during planning, both entries receive the same To path. During execution, the first move succeeds and the second fails because its destination has just been created.

Because $ErrorActionPreference is set to Stop and the script h ...[truncated 1510 chars]

Remediation
View remediation

Remediation Suggestions

  1. Maintain a case-insensitive set of reserved destination paths while building the plan. Treat both existing filesystem paths and paths already assigned to earlier plan entries as collisions.
  2. Generate numeric suffixes until the candidate path is absent from both the filesystem and the reserved-path set.
  3. Perform a complete preflight validation before making any filesystem changes, including confirming that every source still exists and every destination remains available.
  4. Revalidate each destination immediately before moving its source file to reduce time-of-check/time-of-use risk.
  5. Implement rollback handling: if any move fails, move successfully processed files back to their original paths where possible and report any rollback failures.
  6. Require an explicit execution option after a dry run, rather than defaulting to live changes when -DryRun is omitted.
  7. Add automated tests covering duplicate names across recursive subdirectories, case-only filename differences on case-insensitive filesystems, pre-existing suffixed names, and failures occurring after one or more successful moves.
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 (2)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill advertises very broad trigger phrases such as 'clean up', 'sort', and 'organize files in a folder', which can match many ordinary user requests without sufficiently constraining scope, directory, or operation type. Because this skill performs filesystem moves, unintended invocation could cause disruptive file reorganization or data-handling actions in the wrong directory if selected too eagerly by an agent.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This markdown file documents an execution example that reorganizes files into new folders and creates organize-report.md, which affects user data layout. While the dry-run example is clearly labeled, the real execution example does not include a warning or caution that files will be moved and the directory contents changed.

Content

No source excerpt is available for this finding.