Back to skill

Security audit

karaoke-companion

Security checks for vulnerabilities and agentic risk

Overview

This karaoke skill mostly matches its stated purpose, but it needs review because one save command can write outside its intended folder and overwrite user-writable .txt files.

Review before installing if the agent may run commands using untrusted song titles or lyrics. The main fix needed is to sanitize saved filenames, enforce that writes remain inside ~/.karaoke-companion/songs/, avoid silent overwrites, and validate LRCLIB IDs as digits only. Also be comfortable with lyric text and search terms being sent to LRCLIB, LibreTranslate, and DuckDuckGo.

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/lyrics_creator.py:276
Finding

Path Traversal Allows File Writes Outside the Intended Song Directory

Content
View full analysis
Path: file = DATA_DIR / f"{title}.txt" content = f"# {title}\n# 風格:{genre} | BPM:{bpm}\n# 建立:{datetime.now().strftime('%Y-%m-%d')}\n\n{lyrics}" file.write_text(content, encoding="utf-8") return file ``` ### Technical Analysis The `title` parameter is supplied through the command line and incorporated directly into the destination path without filename sanitization or containment validation. A title containing parent-directory components such as `../`, directory separators, or an absolute path can cause the resulting destination to fall outside the documented `~/.karaoke-companion/songs/` directory. Python's `pathlib` also discards the preceding base path when the appended path is absolute. Consequently, an absolute title can directly select another writable location, subject to the automatically appended `.txt` suffix. The function then calls `Path.write_text()`, which truncates and overwrites an existing destination by default. The code does not verify the resolved path, restrict the title to a filename, or request confirmation before overwriting an existing file. ### Attack Path 1. An attacker, untrusted caller, or injected command invokes the `save` operation with a crafted title. 2. The title contains traversal components or an absolute path, for example: ```bash python3 scripts/lyrics_creator.py save /tmp/attacker-controlled \ --lyrics "controlled content" ``` 3. `save_song()` evaluates the destination as `/tmp/attacker-controlled.txt` rather than a file under `DATA_DIR`. 4. `write_text()` creates that file or overwrites it if it already exists and is writable. 5. A traversal title can similarly target other existing directori ...[truncated 985 chars]
Remediation
View remediation
Path: safe_title = re.sub(r"[^A-Za-z0-9 _.-]", "_", title).strip(" .") if not safe_title or safe_title in {".", ".."}: raise ValueError("Invalid song title") base = DATA_DIR.resolve() destination = (base / f"{safe_title}.txt").resolve() if destination.parent != base: raise ValueError("Destination must remain inside the song directory") content = ( f"# {title}\n" f"# Genre: {genre} | BPM: {bpm}\n" f"# Created: {datetime.now().strftime('%Y-%m-%d')}\n\n" f"{lyrics}" ) with destination.open("x", encoding="utf-8") as output: output.write(content) return destination ``` If legitimate overwriting is required, expose it through an explicit option and still enforce resolved-path containment. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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 (24)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The Chinese description promises LRCLIB retrieval, slowdown, section repeat, and lyric-writing aids that are reportedly absent from the code. While not an exploit by itself, this kind of overclaiming undermines informed consent and can mask undeclared data access or unsupported workflows that users may still trust.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The Chinese description promises LRCLIB retrieval, slowdown, section repeat, and lyric-writing aids that are reportedly absent from the code. While not an exploit by itself, this kind of overclaiming undermines informed consent and can mask undeclared data access or unsupported workflows that users may still trust.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The Chinese description promises LRCLIB retrieval, slowdown, section repeat, and lyric-writing aids that are reportedly absent from the code. While not an exploit by itself, this kind of overclaiming undermines informed consent and can mask undeclared data access or unsupported workflows that users may still trust.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The Chinese description promises LRCLIB retrieval, slowdown, section repeat, and lyric-writing aids that are reportedly absent from the code. While not an exploit by itself, this kind of overclaiming undermines informed consent and can mask undeclared data access or unsupported workflows that users may still trust.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill description and usage instructions are written entirely in Traditional Chinese, with no indication that other languages are supported for the overall interface. This can violate language/locale policy when a skill implicitly requires a specific language without user opt-in or an explicit region-specific justification.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill advertises scripts that perform network access, local file caching/writes, and shell-style execution, but the manifest does not declare any tool scope or permissions boundaries. In an agent environment, this weakens containment and informed consent because reviewers and users cannot tell what capabilities the skill may invoke.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Broad trigger terms like generic words for lyrics, translation, or singing can cause accidental activation outside the intended context. Unintended invocation matters here because the skill has network and file capabilities, so a casual conversation could trigger external requests or local writes without clear user intent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code file contains natural-language strings and documentation entirely in Traditional Chinese, including the module description and user-facing interface text, with no indication that the user can select another language. The policy explicitly calls for flagging language or locale constraints when they are forced without user opt-in or documented justification.

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/karaoke_player.py (reported line 86)May include surrounding context.

python
return "0"
            end if
        end tell'''
        out = subprocess.run(["osascript", "-e", script],
                           capture_output=True, text=True, timeout=5)
        return float(out.stdout.strip())
    except Exception:

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/karaoke_player.py (reported line 96)May include surrounding context.

python
return "0"
            end if
        end tell'''
        out = subprocess.run(["osascript", "-e", script],
                           capture_output=True, text=True, timeout=5)
        return float(out.stdout.strip())
    except Exception:

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/karaoke_player.py (reported line 112)May include surrounding context.

python
return "0"
            end if
        end tell'''
        out = subprocess.run(["osascript", "-e", script],
                           capture_output=True, text=True, timeout=5)
        return float(out.stdout.strip())
    except Exception:

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The manifest describes '段落反覆' and the code includes a section selector plus repeat-related fields on KaraokePlayer, suggesting section-loop practice is a supported behavior. However, the selected section is only printed in the CLI, and repeat_start/repeat_end are never used to alter playback flow, so the implemented behavior falls short of the advertised capability.

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 description and all CLI help/output strings are written in Chinese, and there is no visible mechanism for selecting another language or obtaining user opt-in for this locale constraint. Under the policy, forcing a specific language without choice is a natural-language policy violation unless clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The script creates a persistent cache directory under the user's home folder and later writes lyric/query-derived content there without any user notice or consent flow. Cached lyrics and search-derived data can reveal listening interests or user-supplied text to other local users, backups, or forensic collection on shared systems.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

Search queries and lyric lookups are transmitted to external services without explicit disclosure, which creates a privacy issue because user-provided artist/title queries may reveal interests or sensitive text. In this skill context, network access is expected, but the lack of transparency still makes it a real privacy concern.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The function claims to accept only numeric LRCLIB IDs, but it only rejects strings starting with 'http' and will accept arbitrary path fragments. An attacker or confused user could trigger unintended API paths on lrclib.net, bypassing the documented constraint and potentially reaching different endpoints or malformed requests.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The fallback path performs a general DuckDuckGo web search and scrapes snippets, which expands behavior beyond the stated LRCLIB-only lyrics workflow. This sends user queries to an additional third party and imports untrusted web content, increasing privacy, integrity, and policy-scope risk even though it is not direct code execution.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The module docstring states the mode and support text entirely in Chinese, framing the skill as Chinese-language output by default. Because there is no accompanying natural-language opt-in or alternative locale choice in the user-facing description, this can violate a language/locale policy that requires user choice rather than a forced language.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The function sends full lyric text to a third-party service at libretranslate.com over the network without any explicit user consent, privacy notice, or opt-in. In this skill context, users may reasonably assume local processing; silently exfiltrating lyrics or custom text can leak copyrighted, private, or unpublished content to an external operator and create compliance/privacy issues.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The primary description is written entirely in Chinese and presents the skill behavior in that locale without any indication that other interface languages are available by user choice. Under the policy, forcing a specific language without opt-in can be a natural-language policy concern.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The docstring for practice_mode states '減速 + 自動前進', implying the lyrics proceed automatically. In reality, the loop prompts the user to press Enter for each next line, making it manual step-through rather than automatic advancement.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This code performs a filesystem write of user-supplied lyrics into a persistent file under the user's home directory. Although the CLI later logs the saved path after completion, there is no prior confirmation prompt, cautionary message, or docstring warning near the write operation itself disclosing that content will be stored on disk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script's description, help text, and runtime messages are written in Chinese throughout, which imposes a specific language on all users. The file does not offer a language selection mechanism or document that the tool is intentionally limited to a Chinese-speaking audience.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The CLI parser and function documentation present the get command as accepting only an LRCLIB song ID. Later, the search flow tells users to use 'get + ID 或 URL', which contradicts both the documented interface and the function's own rejection of HTTP URLs.

Content

No source excerpt is available for this finding.