Back to skill

Security audit

Jiji5188 File Manager

Security checks for vulnerabilities and agentic risk

Overview

This is a real local file-management skill, but its sync and rename tools can move or delete files outside the user's apparent intent in edge cases, so it should be reviewed carefully before use.

Install only if you are comfortable reviewing commands before execution. Avoid --delete, --execute, --move, --no-confirm, and scheduled automation until the sync path-overlap and rename destination-containment issues are fixed; test on disposable directories first and keep independent backups.

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

Error
Location
scripts/sync.py:35
Finding

Overlapping synchronization paths can cause source-file deletion

Content
View full analysis

Vulnerability Details

File Location: scripts/sync.py, lines 35–50, 61–68, 93–96, and 130–140
Vulnerability Type: Missing source and destination path-separation validation
Risk Level: High

Vulnerable Code

python
def sync_mirror(source, target, exclude=None, dry_run=True, delete=False):
    source_path = Path(source)
    target_path = Path(target)
    exclude = exclude or []
    
    if not source_path.exists():
        print(f"Error: source directory does not exist: {source}")
        return
    
    target_path.mkdir(parents=True, exist_ok=True)
    
    stats = {'copied': 0, 'updated': 0, 'deleted': 0, 'skipped': 0}
    
    source_files = {}
    for file_path in source_path.rglob('*'):
        if file_path.is_symlink():
            continue
        if file_path.is_file() and not should_exclude(
                file_path, exclude, base_path=source_path):
            rel_path = file_path.relative_to(source_path)
            source_files[rel_path] = file_path

    target_files = {}
    for file_path in target_path.rglob('*'):
        if file_path.is_symlink():
            continue
        if file_path.is_file() and not should_exclude(
                file_path, exclude, base_path=target_path):
            rel_path = file_path.relative_to(target_path)
            target_files[rel_path] = file_path
python
if delete:
    for rel_path, tgt_file in target_files.items():
        if rel_path not in source_files:
            actions.append(('delete', None, tgt_file))
python
for action, src, tgt in actions:
    try:
        tgt.parent.mkdir(parents=True, exist_ok=True)
        
        if action == 'copy':
            shutil.copy2(src, tgt)
            stats['copied'] += 1
        elif action == 'update':
            shutil.copy2(src, tgt)
            stats['updated'] += 1
        elif action == 'delete':
            tgt.unl
...[truncated 2756 chars]
Remediation
View remediation

Remediation Suggestions

  1. Canonicalize both paths before creating or scanning the target:

    python
    source_path = Path(source).expanduser().resolve(strict=True)
    target_path = Path(target).expanduser().resolve(strict=False)
    
  2. Reject identical and overlapping paths:

    python
    if source_path == target_path:
        raise ValueError("Source and target must be different directories")
    
    if source_path in target_path.parents or target_path in source_path.parents:
        raise ValueError("Source and target directories must not overlap")
    
  3. Revalidate every destination immediately before copying, updating, or deleting. Ensure the resolved path remains beneath the intended target root:

    python
    resolved_target = tgt.resolve(strict=False)
    if resolved_target != target_path and target_path not in resolved_target.parents:
        raise ValueError(f"Target escapes synchronization root: {tgt}")
    
  4. Do not create the target until path-overlap validation succeeds.

  5. For deletion mode, produce a complete deletion manifest rather than truncating the preview to the first twenty operations. Require a separate explicit confirmation for deletions.

  6. Add automated tests for equal paths, source-inside-target, target-inside-source, relative paths, .. components, and overlapping paths reached through symlinks.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/batch_rename.py:44
Finding

Batch rename arguments permit moving files outside the selected directory

Content
View full analysis

Vulnerability Details

File Location: scripts/batch_rename.py, lines 44–82 and 178–211
Vulnerability Type: Path traversal through unsanitized destination names
Risk Level: Medium

Vulnerable Code

python
for i, file_path in enumerate(files, 1):
    old_name = file_path.name
    new_name = old_name
    
    if kwargs.get('prefix'):
        new_name = kwargs['prefix'] + new_name
    
    if kwargs.get('suffix'):
        stem = Path(new_name).stem
        suffix = kwargs['suffix']
        ext = Path(new_name).suffix
        new_name = f"{stem}{suffix}{ext}"
    
    if kwargs.get('replace_pattern') and kwargs.get('replace_with') is not None:
        try:
            regex = re.compile(kwargs['replace_pattern'])
            new_name = regex.sub(kwargs['replace_with'], new_name)
        except re.error as e:
            print(f"Regular expression error: {e}")
            return []
    
    if kwargs.get('sequence'):
        template = kwargs.get('sequence_template', 'file_{n}')
        padding = kwargs.get('padding', 3)
        ext = file_path.suffix
        new_name = generate_sequence_name(template, i, padding) + ext
    
    if new_name != old_name:
        operations.append((file_path, file_path.parent / new_name))
python
for old_path, new_path in operations:
    print(f"  {old_path.name}")
    print(f"    → {new_path.name}\n")
python
for old_path, new_path in operations:
    try:
        if new_path.exists():
            print(f"Skipped {old_path.name}: destination already exists")
            failed += 1
            continue
        old_path.rename(new_path)
        success += 1
    except Exception as e:
        print(f"Rename failed for {old_path.name}: {e}")
        failed += 1

Technical Analysis

User-controlled prefixes, regular-expression replacement strings, and sequence templates are used to constr ...[truncated 2510 chars]

Remediation
View remediation

Remediation Suggestions

  1. Treat every generated value as a filename, not a path. Reject absolute paths, parent traversal, and directory separators:

    python
    candidate = Path(new_name)
    if candidate.is_absolute() or candidate.name != new_name:
        raise ValueError("The generated name must be a plain filename")
    if new_name in {".", ".."} or "/" in new_name or "\\" in new_name:
        raise ValueError("Path components are not allowed in rename values")
    
  2. Resolve and enforce destination containment:

    python
    source_parent = file_path.parent.resolve()
    destination = (file_path.parent / new_name).resolve(strict=False)
    if destination.parent != source_parent:
        raise ValueError("Rename destination escapes the working directory")
    
  3. Validate every transformation source, including --prefix, --suffix, --replace, and --template.

  4. Display the complete normalized source and destination paths in the preview rather than only each basename.

  5. Abort execution when duplicate targets are detected instead of merely warning, because partial renaming can leave a batch in an inconsistent state.

  6. Revalidate the destination immediately before rename() to reduce time-of-check/time-of-use risks and add tests for ../, absolute paths, Windows separators, drive-qualified paths, and nested template values.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • 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
Findings (18)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill advertises broad capabilities that are not actually implemented, including deduplication, batch renaming, and sync behaviors. This mismatch is dangerous because users or orchestrators may trust the documented safety and behavior model when invoking operations, leading to unsafe assumptions, incorrect automation decisions, or execution of partial/destructive workflows without expected safeguards.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 60)May include surrounding context.

md
python scripts/sync.py <source> <target> --mirror

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 63)May include surrounding context.

md
python scripts/sync.py <source> <target> --mirror

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 66)May include surrounding context.

md
python scripts/sync.py <source> <target> --mirror

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 94)May include surrounding context.

md
python scripts/sync.py <source> <target> --mirror

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/batch_rename.py (reported line 155)May include surrounding context.

python
help='转换为大写')
    parser.add_argument('--execute', action='store_true',
                       help='执行重命名 (默认仅预览)')
    parser.add_argument('--no-confirm', action='store_true',
                       help='跳过确认')
    
    args = parser.parse_args()

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill documents file-moving, deleting, renaming, and syncing behavior but does not declare any explicit tool scope or permissions boundaries. In an agent ecosystem, missing scope declarations can let a broadly empowered runtime perform destructive filesystem actions without transparent least-privilege constraints, increasing the risk of misuse or accidental damage.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The document claims all modifying actions default to dry-run and require an explicit execution flag, yet the examples show destructive operations like delete/move/mirror directly. This inconsistency can mislead users into running commands they believe are preview-only, resulting in unintended deletion, overwrite, or large-scale file changes.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The document provides backup/sync commands using --mirror and --execute, which can delete or overwrite files when source and destination differ, but it does not warn users about the destructive semantics or recommend dry-run validation first. In a file-management skill, users are especially likely to copy these commands directly, increasing the chance of accidental large-scale data loss.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The scheduled automation example moves files from Downloads every hour with --execute --move, but it does not warn about unintended relocation, breaking user workflows, or moving files that are still needed or in progress. Because this skill is specifically for automated file operations, such unattended examples are more dangerous than in generic documentation due to likely real-world adoption.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
65% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · scripts/batch_rename.py (reported line 155)May include surrounding context.

python
help='转换为大写')
    parser.add_argument('--execute', action='store_true',
                       help='执行重命名 (默认仅预览)')
    parser.add_argument('--no-confirm', action='store_true',
                       help='跳过确认')
    
    args = parser.parse_args()

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file includes user-facing natural language in its module docstring and throughout CLI messages that forces a specific language/locale. Under the policy, language constraints should either offer user opt-in/choice or be clearly documented as region-specific and justified, which is not present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This code file contains natural-language strings that require users to interact in Chinese, including the module description and later CLI prompts/help text. The policy allows locale constraints only when explicitly justified or when users are offered a language choice, neither of which is present here.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

L122 明确写明“目标文件已存在时自动重命名或跳过,不会覆盖”。然而 L60 的“--mirror”同步语义通常包含按源端状态更新目标端,至少从文档呈现上未体现任何防覆盖约束,和“不会覆盖”的绝对性表述存在明显张力。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The guidance "中文文件名(某些系统兼容性问题)" is a natural-language recommendation that disfavors a specific language/script without user opt-in or clear scope. Under the policy, language or locale constraints should either be optional or explicitly justified in a narrow context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code file contains natural-language strings such as the module docstring, CLI description, help text, prompts, and status messages exclusively in Chinese. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code file contains natural-language descriptions and prompts entirely in Chinese, including the module docstring and command-line help/output. Under the policy, forcing a specific language without user opt-in is a locale/language policy violation unless the constraint is explicitly documented and justified, which is not present here.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

The argument parser exposes --by-size with help text claiming it organizes files by size, but selecting that option only prints 按大小分类功能开发中... instead of performing any file organization. This is an intent/documentation mismatch between the user-facing interface and actual behavior.

Content

No source excerpt is available for this finding.