Back to skill

Security audit

Video Organizer

Security checks for vulnerabilities and agentic risk

Overview

This is a plausible video organizer, but it needs review because its file mutation and undo behavior are under-scoped and more risky than the documentation suggests.

Install only if you are comfortable running a local file organizer against directories you choose. Use preview, keep separate backups, avoid rename patterns or regex replacements containing slashes, dot-dot paths, or absolute paths, and do not rely on undo to remove organized copies. Do not run undo in a directory where .video-organizer-backup.json could have been modified by someone else.

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
video_organizer.py:124
Finding
Unvalidated Rename and Backup Paths Allow File Moves Outside Approved Directories<![CDATA[ ## Vulnerability Details **File Location**: `video_organizer.py:124-127` and `video_organizer.py:172-179` **Vulnerability Type**: Path traversal and untrusted filesystem path handling **Risk Level**: Medium ### Vulnerable Code ```python if pattern: new_name = self.generate_name(video_path, pattern, i) target_path = self.input_dir / new_name elif regex: new_name = self.apply_regex(video_path.name, regex) target_path = self.input_dir / new_name ``` The undo operation also trusts paths loaded directly from the backup file: ```python reverse_mappings = {v: k for k, v in backup.items()} count = 0 for new_str, old_str in reverse_mappings.items(): new_path = Path(new_str) old_path = Path(old_str) if new_path.exists() and not old_path.exists(): new_path.rename(old_path) ``` ### Technical Analysis Names generated from the user-controlled `--pattern` or `--regex` arguments are joined directly to `self.input_dir` without verifying that the resulting path remains inside that directory. A generated name can contain `../` traversal components or be an absolute path. With `pathlib`, joining a base path to an absolute path causes the absolute path to replace the base path. Consequently, the rename destination is not reliably confined to the selected video directory. The undo implementation creates an additional attack surface. `load_backup()` parses `.video-organizer-backup.json`, after which `undo()` treats its keys and values as trusted filesystem paths. No schema, ownership, file type, extension, canonical path, or directory-containment checks are performed. Anyone able to alter that JSON file can specify an existing accessible source file and an absent destination path. The destination must not already exist, and all operations remain subject to the operating-system privileges of the process. The code does not create elevated privileges. ### Attack Path #### Rename traversal 1. An operator invokes `rename` with a ...[truncated 1821 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Restrict generated names to a single filename component: - Reject absolute paths. - Reject `.` and `..`. - Reject directory separators. - Require `Path(new_name).name == new_name`. 2. Canonicalize and validate every destination before creating the mapping: ```python base = self.input_dir.resolve() candidate = (base / new_name).resolve() if not candidate.is_relative_to(base): raise ValueError("Generated filename escapes the input directory") ``` 3. Account for symbolic links by resolving the approved root and candidate path immediately before the filesystem mutation. 4. Validate the complete operation plan before moving any file. Abort the entire operation if any mapping is invalid, duplicated, outside an approved root, or conflicts with an existing path. 5. Treat backup JSON as untrusted input: - Require a dictionary with string keys and values. - Reject unknown fields and malformed mappings. - Define explicit source and destination roots for each operation type. - Resolve every loaded path and enforce containment within those roots. - Confirm that source paths are regular files of an expected type. - Reject mappings involving symlinks or unexpected extensions where appropriate. 6. Create backup files with restrictive permissions and avoid following symlinks when opening or replacing them. Write updates atomically through a securely created temporary file in the same directory. 7. Require an explicit confirmation for undo operations that lists the validated source and destination paths before any mutation. 8. Add automated tests covering absolute paths, `../` traversal, nested names, symlink escapes, malformed backup data, duplicate destinations, and mappings outside approved directories. ]]>
Vulnerability Patterns
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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
Findings (9)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The documented behavior does not match the actual behavior: it claims resolution-based organization and reliable undo, while the implementation reportedly lacks full support and does not correctly reverse organize/copy actions. This is dangerous because users may trust preview/undo semantics and perform bulk file operations that cannot be safely reverted, leading to data duplication, confusion, or partial data loss in managed media libraries.

Intent-Code Divergence

High
Confidence
94% confidence
Finding
The tool advertises undo support, but organize() copies files into the output tree while undo() only renames files from destination back to source. As a result, organized copies are not reliably reverted and users may believe a destructive or state-restoring undo exists when it does not, causing data inconsistency, duplicate files, and operational mistakes during file management.

Natural-Language Policy Violations

Medium
Confidence
83% confidence
Finding
The file presents all user-facing instructions and operational guidance exclusively in Chinese. Under the stated policy, forcing a specific language without an explicit user choice or documented locale limitation is a natural-language policy violation.

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill describes operations that inherently read and modify files, but it does not declare any explicit tool scope or permissions. That creates a least-privilege and transparency problem: an agent or user may invoke a file-mutating skill without clear boundaries on what paths or file operations are authorized, increasing the chance of unintended filesystem access or destructive changes.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This markdown file uses Chinese for the description, headings, instructions, and warnings, but does not indicate that the skill is region-specific or provide any user opt-in for language preference. That can violate a language/locale policy when skills are expected to be usable without forcing a specific language.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
This code file contains natural-language strings that present the tool description only in Chinese. The policy explicitly calls out forced language or locale as a violation when the skill does not offer a language choice or clearly justify the constraint.

Description-Behavior Mismatch

Medium
Confidence
97% confidence
Finding
The manifest description says the tool supports organizing videos by '时间、格式、分辨率' (time, format, resolution). However, the implementation of folder selection only handles 'date' and 'format', and the CLI choices likewise expose only those two modes. This is a direct mismatch between the advertised capability and the implemented behavior.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
The preview, confirmation, cancellation, undo, and argparse help strings are all fixed to Chinese, which forces a locale for all users. There is no indication of user choice, opt-in, or documented region-specific restriction, so this matches the language policy violation category.

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Content
if len(parts) >= 3:
                search = parts[1]
                replace = parts[2]
                return __import__('re').sub(search, replace, filename)
        return filename

    def undo(self):
Confidence
75% confidence
Finding
Dynamic __import__() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Static analysis

No suspicious patterns detected.