Back to skill

Security audit

Music Library Organizer / 音乐库整理

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real music-library organizer, but it needs review because it can bulk-move local files and includes unsafe deletion, permission, and install guidance.

Review this before installing. Use it only on a backed-up music library, run dry-run first, inspect the plan carefully, avoid the documented rm -rf and chmod -R recovery steps, install dependencies in a virtual environment instead of system Python, and run the scripts as a low-privilege user limited to the intended media directories.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/organize_music.py:924
Finding

Spreadsheet Formula Injection in Generated CSV Reports

Content
View full analysis

Vulnerability Details

File Location: scripts/organize_music.py:681-688 and scripts/organize_music.py:924-928
Vulnerability Type: CSV formula injection
Risk Level: Medium

Complete Code Snippet

python
self.report.append({
    '类型': '音乐', '原路径': src, '目标路径': str(target_path),
    '歌手': full_artist, '第一歌手': first_artist,
    '歌曲': title, '状态': '干跑-待移动', '音质': rank, '大小KB': file_size_kb(src),
    '来源': source_kind
})
python
with open(self.report_path, 'w', newline='', encoding='utf-8-sig') as fp:
    w = csv.DictWriter(fp, fieldnames=['类型', '原路径', '目标路径', '歌手', '第一歌手',
                                       '歌曲', '状态', '音质', '大小KB', '来源'])
    w.writeheader()
    w.writerows(self.report)

Technical Analysis

Artist names, song titles, source paths, and related values originate from media filenames or metadata tags. These externally controlled values are placed into the report and written directly to a CSV file without neutralizing spreadsheet formula prefixes.

CSV quoting does not prevent formula interpretation. If a value begins with =, +, -, or @, spreadsheet software may interpret the cell as a formula when the report is opened. Depending on the spreadsheet application and its security settings, a malicious formula may initiate external requests, disclose report contents, create misleading links, or invoke other dangerous spreadsheet functionality.

The project documentation explicitly recommends opening generated reports in Excel or LibreOffice, making spreadsheet interpretation part of the expected workflow.

Attack Path

  1. An attacker supplies a music file whose filename or metadata artist/title field begins with a spreadsheet formula prefix.
  2. The owner places the crafted file in a library scanned by organize_music.py.
  3. The script extracts the attacker-controlled value and adds it to self.report.
  4. csv.DictWriter.writerows() writes the va ...[truncated 917 chars]
Remediation
View remediation

Remediation Suggestions

  • Apply a centralized CSV-safety function to every externally derived string before writing reports.
  • Prefix cells beginning with =, +, -, @, tab, or carriage return with a single quote.
  • Preserve an unmodified machine-readable report in JSON if exact source values are required.
  • Document that reports should be imported with formula evaluation disabled.
  • Add tests using filenames and tags such as =1+1, +SUM(1,1), -1+2, and @SUM(1,1).
  • Do not rely on csv.DictWriter quoting alone, because quoting addresses CSV syntax rather than spreadsheet formula execution.

Example hardening:

python
def csv_safe(value):
    if not isinstance(value, str):
        return value
    if value.startswith(('=', '+', '-', '@', '\t', '\r')):
        return "'" + value
    return value

safe_rows = [
    {key: csv_safe(value) for key, value in row.items()}
    for row in self.report
]
w.writerows(safe_rows)

T08 · Insecure Dependencies

Warning
Location
scripts/README.md:102
Finding

Unpinned Dependencies Installed into System Python

Content
View full analysis

Vulnerability Details

File Location: scripts/README.md:102 and scripts/organize_music.README.md:73
Vulnerability Type: Unsafe dependency installation guidance
Risk Level: Medium

Complete Code Snippet

bash
pip install --break-system-packages mutagen pypinyin

The main script documentation provides the equivalent instruction:

bash
python3 -m pip install --break-system-packages mutagen pypinyin

Technical Analysis

The installation instructions resolve mutable latest versions of mutagen and pypinyin without version constraints or cryptographic hashes. They also use --break-system-packages, which bypasses the operating system's protection against modifying distribution-managed Python environments.

If a future dependency release, transitive dependency, package-index response, or source distribution is compromised, package build or import-time code can execute with the privileges of the user running the installation or script. Even without a malicious package, globally modifying system Python can introduce dependency conflicts that affect unrelated applications.

The package names do not appear to be typosquatted, and the audit found no evidence that the currently named packages are malicious. The risk arises from mutable resolution, lack of integrity verification, and installation into a shared system environment.

Attack Path

  1. A user follows the documented installation command.
  2. pip resolves the latest package versions available from its configured index.
  3. A compromised release, malicious index response, or unsafe source distribution is downloaded.
  4. Package build logic may execute during installation, or package code executes when imported by the scripts.
  5. The code runs with the privileges of the user who invoked pip or the organizer.
  6. Because the system Python environment was modified, the malicious or incompatible package may also affect other Python ...[truncated 550 chars]
Remediation
View remediation

Remediation Suggestions

  • Create a dedicated virtual environment instead of modifying system Python.
  • Pin reviewed dependency versions in a requirements file.
  • Generate and verify hashes for every package artifact.
  • Use an explicitly trusted package index and require HTTPS certificate validation.
  • Review and pin transitive dependencies where applicable.
  • Remove --break-system-packages from recommended commands.
  • Run the organizer under a non-privileged account with access limited to the intended library.

Example installation workflow:

bash
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install --require-hashes -r requirements.txt

The requirements file should contain exact reviewed versions and SHA-256 hashes.

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:299
Finding

Recursive World-Readable Permission Grant Recommended as Generic Error Recovery

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:299
Vulnerability Type: Overbroad permission modification
Risk Level: Medium

Complete Code Snippet

text
| Permission denied | `chmod -R a+rX` then retry |

Technical Analysis

The skill recommends recursively granting read permission to all users and traversal permission on directories whenever a permission error occurs. The command does not identify the actual failing object, preserve least privilege, or restrict access to a dedicated user or group.

Applied to the configured library root, chmod -R a+rX can make all nested files readable by every local account and make directories traversable. The recursive operation may also affect files unrelated to the immediate error if they are stored beneath the selected path.

Because this instruction appears in the skill's error-handling policy, an agent following the skill may apply it automatically as a routine retry rather than treating permission expansion as a security-sensitive action.

Attack Path

  1. A permission error occurs while scanning, moving, or reading a file.
  2. The agent follows the documented recovery instruction.
  3. It runs chmod -R a+rX against the affected directory or library root.
  4. Every local user gains read access to files and traversal access to directories under that path.
  5. An unrelated local account reads library contents, metadata, reports, or other files that were previously inaccessible.

An attacker able to place a sensitive file beneath the recursively modified tree could also use the retry behavior to cause that file's permissions to be broadened.

Impact Assessment

This instruction does not directly grant write access or administrative privileges. It can, however, break confidentiality boundaries between local accounts and expose every file covered by the recursive command.

The precise scope depends on where the command is run. If applied to the f ...[truncated 196 chars]

Remediation
View remediation

Remediation Suggestions

  • Remove recursive world-readable permission changes from generic error handling.
  • Diagnose the exact failing path and determine whether ownership, ACLs, mount options, or file modes caused the failure.
  • Grant access only to the service account or group that runs the organizer.
  • Limit permission changes to the smallest necessary file or directory.
  • Require explicit owner approval before changing permissions.
  • Record the original mode and ownership so changes can be reverted.
  • Refuse to modify permissions on symlinks or paths outside the confirmed library root.
  • Prefer group-based access, such as a dedicated media-management group, rather than permissions for all users.

A safer policy is to stop and report the exact inaccessible path, current owner, group, and mode. Any proposed permission change should be shown to the owner before execution.

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

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

A restore-from-trash utility is materially different from a full organizer workflow, yet the skill description suggests the latter. When restoration logic is framed as general organization, users may run it on the wrong dataset or assume protections that do not exist, resulting in misplaced files and inconsistent library state.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

A restore-from-trash utility is materially different from a full organizer workflow, yet the skill description suggests the latter. When restoration logic is framed as general organization, users may run it on the wrong dataset or assume protections that do not exist, resulting in misplaced files and inconsistent library state.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

A restore-from-trash utility is materially different from a full organizer workflow, yet the skill description suggests the latter. When restoration logic is framed as general organization, users may run it on the wrong dataset or assume protections that do not exist, resulting in misplaced files and inconsistent library state.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

A restore-from-trash utility is materially different from a full organizer workflow, yet the skill description suggests the latter. When restoration logic is framed as general organization, users may run it on the wrong dataset or assume protections that do not exist, resulting in misplaced files and inconsistent library state.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

A restore-from-trash utility is materially different from a full organizer workflow, yet the skill description suggests the latter. When restoration logic is framed as general organization, users may run it on the wrong dataset or assume protections that do not exist, resulting in misplaced files and inconsistent library state.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

A restore-from-trash utility is materially different from a full organizer workflow, yet the skill description suggests the latter. When restoration logic is framed as general organization, users may run it on the wrong dataset or assume protections that do not exist, resulting in misplaced files and inconsistent library state.

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 196)May include surrounding context.

md
**完整脚本说明**:参见 `scripts/README.md`

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
89% confidence
Finding

The skill explicitly treats phrases such as 'rm -rf' or '永久删除' as acceptable triggers for irreversible deletion. In an agent setting, normalizing raw destructive shell idioms as user confirmation language increases the chance of unsafe tool invocation, prompt injection confusion, or accidental hard-delete execution on the wrong path.

Content

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

md
每次删除前:

- [ ] 主人明确说"硬删/真删/rm -rf/永久删除"
- [ ] 报告:大小、文件数、不可恢复
- [ ] 二次确认("确认真删除")
- [ ] 5 秒延迟

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script performs state-changing file moves whenever '--apply' is supplied, but there is no enforced owner confirmation or interactive approval step despite the skill promising a scan→plan→owner confirmation workflow. In an agent setting, a caller, wrapper, or prompt-injected automation could add '--apply' and move user media without the explicit consent boundary the manifest claims, causing unintended bulk modification of a personal library.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill description promises a scan → plan → owner confirmation → soft-delete workflow, but the implementation performs destructive moves immediately when --apply is supplied, with no enforced confirmation gate tied to a reviewed plan. This mismatch is dangerous because users may trust the advertised safety guarantees and run the tool on valuable media libraries, leading to bulk unintended reorganization or relocation of files and backups.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill documents shell commands and filesystem mutations but does not declare any explicit tool scope or permissions. That mismatch weakens reviewability and containment, making it easier for an agent to invoke broad file-read, file-write, and shell capabilities on a large real media library without clear policy boundaries.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The document first states that Stage 4 will never delete files, then later defines a Stage 6 hard-delete path. Contradictory safety messaging is risky in operational file-management skills because it can cause reviewers to miss the irreversible branch and approve execution based on an incomplete understanding.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The manifest emphasizes mandatory owner confirmation and soft-delete, but the workflow explicitly includes permanent deletion via rm -rf. Even with stated confirmation steps, embedding hard-delete commands in a supposedly safety-first skill increases the risk that an agent or user treats irreversible deletion as endorsed normal behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill documentation is written entirely in Chinese and uses user-facing operational instructions such as '主人明确说' and '主人确认后真执行', but it does not provide any language choice or explain that the skill is intentionally limited to Chinese-speaking users. This can violate language/locale policy because it implicitly forces a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill description promises a safety workflow with mandatory owner confirmation, but this script executes destructive file moves as soon as '--apply' is supplied, with no in-script confirmation, approval artifact, or review gate. In a media-library cleanup context, this mismatch is dangerous because an agent or operator can trigger bulk changes based on imperfect heuristics and move large numbers of files or directories without the explicit owner-approval step the skill claims to enforce.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring is entirely in Chinese, and the script's operational messages are also presented only in Chinese. For a general-purpose cleanup script, this imposes a specific language/locale without opt-in or a documented region-specific justification, which matches the language-policy violation category.

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 instructions, status messages, and operational guidance only in Chinese, which effectively forces a specific language for understanding and safe use. Under the policy, locale or language restrictions should be opt-in or clearly justified, and neither is present here.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The manifest describes a safe-by-default music library organization workflow centered on scanning, planning, confirmation, soft-delete, verification, and cleanup. Instead of using standard library traversal, the code invokes external subprocesses via subprocess.run to execute find, introducing command execution capability that is broader than necessary for the stated purpose and weakens the claimed safety posture.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/organize_music.py (reported line 603)May include surrounding context.

python
')']
        for skip in ['_低音质备份', 'attachments', '.opencode', '.git']:
            cmd.extend(['-not', '-path', f'*/{skip}/*'])
        result = subprocess.run(cmd, capture_output=True, text=True, timeout=600)
        return [l for l in result.stdout.split('\n') if l.strip()]

    def scan_lyrics(self):

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/organize_music.py (reported line 618)May include surrounding context.

python
')']
        for skip in ['_低音质备份', 'attachments', '.opencode', '.git']:
            cmd.extend(['-not', '-path', f'*/{skip}/*'])
        result = subprocess.run(cmd, capture_output=True, text=True, timeout=600)
        return [l for l in result.stdout.split('\n') if l.strip()]

    def scan_lyrics(self):

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script performs immediate filesystem moves with shutil.move once '--apply' is supplied, rather than using the advertised soft-delete/safe staging workflow. In a media-management context, incorrect heuristic matching can silently relocate large numbers of lyric files, making recovery and audit harder and violating the safety guarantees described by the skill.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

The document is explicitly bilingual in English and Chinese, but nowhere indicates that the user may choose another language or that the skill is restricted to a Chinese/English audience for a justified regional reason. Under the policy rule, fixed language expectations without opt-in can be a locale-policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

The display name and primary description foreground Chinese, and the operational instructions repeatedly direct the agent to wait for specific Chinese confirmation phrases from the owner. This can create a locale/language expectation without explicitly offering the user a language choice, which falls under the language/locale policy concerns.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

Recommending chmod -R a+rX to recover from permission errors broadens access recursively across the media tree and can expose files more widely than intended. While not directly destructive, it violates least privilege and is inconsistent with a safety-focused organizer operating on personal media.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The docstring frames the behavior as '删除(也是软删除)', implying a benign cleanup step, but the code physically relocates empty directories out of the music library tree into TRASH_BASE. While reversible, this is still a structural modification of the library and not merely an in-place no-op cleanup, so the documentation understates the operational effect.

Content

No source excerpt is available for this finding.