Back to skill

Security audit

Perception Music

Security checks for vulnerabilities and agentic risk

Overview

This skill is a local perception-to-music wrapper with disclosed local file reads and audio generation, but users should trust the local binaries it invokes and note its temp-file hardening issues.

Install only if you are comfortable with a skill that runs local audio/sensor binaries from your machine and writes generated music into your QClaw workspace. Verify the provenance of ~/.local/bin/fm_compose, ~/.local/bin/sense_all, and ffmpeg, and prefer a version that uses private temporary directories before running it on shared or privileged systems.

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

Warning
Location
scripts/compose_from_perception.py:48
Finding

Predictable Shared Temporary Files in Perception Composition

Content
View full analysis

Vulnerability Details

File Location: scripts/compose_from_perception.py, lines 48-76
Vulnerability Type: Predictable temporary-file creation and potential symbolic-link overwrite
Risk Level: Medium

Vulnerable Code

python
date_str = datetime.now().strftime("%Y%m%d_%H%M")
wav_path = f"/tmp/perception_music_{date_str}.wav"
mp3_path = f"/tmp/perception_music_{date_str}.mp3"

fm = os.path.expanduser("~/.local/bin/fm_compose")
if not os.path.exists(fm):
    print("Error: fm_compose not found at ~/.local/bin/fm_compose", file=sys.stderr)
    print("Build from: https://github.com/citriac/perception-music", file=sys.stderr)
    sys.exit(1)

print(f"Composing: brightness={p['brightness']} rms={p['rms']:.1f} phase={p['phase']}", file=sys.stderr)
result = subprocess.run([
    fm,
    "--brightness", str(p["brightness"]),
    "--rms", str(p["rms"]),
    "--phase", p["phase"],
    "--duration", "90",
    "--output", wav_path,
], capture_output=True, text=True, timeout=30)

if result.returncode != 0:
    print(f"Error: {result.stderr}", file=sys.stderr)
    sys.exit(1)
print(result.stderr.strip(), file=sys.stderr)

# Convert to MP3 if ffmpeg available
ffmpeg = os.path.expanduser("~/.local/bin/ffmpeg")
if not os.path.exists(ffmpeg):
    ffmpeg = "ffmpeg"

subprocess.run([ffmpeg, "-y", "-i", wav_path, "-codec:a", "libmp3lame", "-b:a", "128k", mp3_path],
               capture_output=True, timeout=30)

Technical Analysis

The script constructs WAV and MP3 paths directly under the shared /tmp directory using a timestamp with only minute-level precision. These names are predictable, and no exclusive file creation or private temporary directory is used.

A local attacker can create one of the anticipated paths before the script runs. If fm_compose or FFmpeg follows a symbolic link when opening its output, the external process may write through that link. FFmpeg is invoked wi ...[truncated 1542 chars]

Remediation
View remediation

Remediation Suggestions

  • Use tempfile.TemporaryDirectory() to create a private, unpredictable workspace with restrictive permissions.
  • Place both intermediate files inside that directory rather than directly under /tmp.
  • Ensure output files are created exclusively and reject pre-existing destinations.
  • Avoid relying on external tools to provide safe symbolic-link handling.
  • After successful generation, atomically move the finished file into the destination directory with an explicitly defined collision policy.
  • Validate the FFmpeg return code before treating the MP3 as successfully generated.
  • Run the script with the least-privileged account required for audio generation.

Example hardening pattern:

python
import shutil
import tempfile
from pathlib import Path

with tempfile.TemporaryDirectory(prefix="perception_music_") as temp_dir:
    wav_path = Path(temp_dir) / "output.wav"
    mp3_path = Path(temp_dir) / "output.mp3"

    # Invoke the synthesizer and FFmpeg using these private paths.
    # Check both subprocess return codes before publishing the result.

    destination = Path(sc_dir) / f"compose_{date_str}.mp3"
    os.replace(mp3_path, destination)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/daily_compose.py:41
Finding

Predictable Shared Temporary Files in Daily Composition

Content
View full analysis

Vulnerability Details

File Location: scripts/daily_compose.py, lines 41-64
Vulnerability Type: Predictable temporary-file creation and potential symbolic-link overwrite
Risk Level: Medium

Vulnerable Code

python
# Output path
date_str = datetime.now().strftime("%Y%m%d_%H%M")
wav_path = f"/tmp/compose_{date_str}.wav"
mp3_path = f"/tmp/compose_{date_str}.mp3"

# Run Zig FM composer
print(f"Composing: brightness={brightness} rms={rms:.1f} phase={phase}", file=sys.stderr)
result = subprocess.run([
    os.path.expanduser("~/.local/bin/fm_compose"),
    "--brightness", str(brightness),
    "--rms", str(rms),
    "--phase", phase,
    "--duration", "90",
    "--output", wav_path,
], capture_output=True, text=True, timeout=30)

if result.returncode != 0:
    print(f"Error: {result.stderr}", file=sys.stderr)
    return

print(result.stderr.strip(), file=sys.stderr)

# Convert to MP3
ffmpeg = os.path.expanduser("~/.local/bin/ffmpeg")
subprocess.run([ffmpeg, "-y", "-i", wav_path, "-codec:a", "libmp3lame", "-b:a", "128k", mp3_path],
               capture_output=True, timeout=30)

Technical Analysis

The daily composition script writes intermediate media to predictable, minute-resolution filenames in the shared /tmp directory. It does not create a private temporary directory, reserve filenames with exclusive creation, or reject symbolic links.

The daily or scheduled nature of this script can make execution time easier to predict. An attacker who can create entries in /tmp may pre-position a symbolic link at the expected WAV or MP3 path. FFmpeg is passed -y, allowing replacement of an existing destination, and may write through a symbolic link depending on platform safeguards. The behavior of the unavailable fm_compose binary could not be audited, so its handling of pre-existing files and symbolic links is unknown.

Attack Path

  1. The attacker determines or observ ...[truncated 1097 chars]
Remediation
View remediation

Remediation Suggestions

  • Replace deterministic /tmp paths with a directory created by tempfile.TemporaryDirectory().
  • Keep temporary directory permissions restricted to the executing user.
  • Never reuse a pre-existing temporary output path.
  • Check the FFmpeg return code and confirm that the expected output is a regular file before moving it.
  • Publish the completed MP3 using an atomic move into the soundscape directory.
  • Define safe behavior for an existing final destination instead of implicitly replacing it.
  • Configure scheduled execution under a dedicated, minimally privileged account.

Example hardening pattern:

python
import tempfile
from pathlib import Path

with tempfile.TemporaryDirectory(prefix="daily_compose_") as temp_dir:
    wav_path = Path(temp_dir) / "compose.wav"
    mp3_path = Path(temp_dir) / "compose.mp3"

    # Run both external tools and require successful return codes.

    if not mp3_path.is_file() or mp3_path.is_symlink():
        raise RuntimeError("Unsafe or missing generated output")

    final_path = Path(sc_dir) / f"compose_{date_str}.mp3"
    os.replace(mp3_path, final_path)
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (11)

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding

The documentation claims local FM sonification of perception data, but it also describes reading undeclared local data sources and executing undeclared helper binaries, while some advertised sensor mappings are unsupported or delegated to an external binary not shown. This mismatch is dangerous because users and policy engines may approve the skill under a narrower trust model than its actual behavior requires, creating room for unexpected code execution and data access.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill advertises executable behavior such as running Python scripts, invoking local binaries, and producing output files, but it declares no explicit tool scope or permissions. That omission weakens reviewability and containment because a host may grant broader shell and file-write capability than users expect from a simple music-generation skill.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest-style trigger line lists broad activation phrases such as "compose from data" and "FM synthesis skill" without constraints, negative examples, or context boundaries. In a markdown/manifest file, this creates ambiguity about when the skill should activate and increases the risk of unintended invocation.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The quick-start flow says the skill will fall back to executing local binaries such as perceive_full or sense_all to collect data. That extends the skill from passive sonification into active system command execution, which can expose additional local data or run unintended binaries if those paths are replaced, aliased, or insufficiently trusted.

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

python
sense = os.path.expanduser("~/.local/bin/sense_all")
    if os.path.exists(sense):
        try:
            r = subprocess.run([sense], capture_output=True, text=True, timeout=60)
            d = json.loads(r.stdout)
            p = d.get("perceive", {})
            brightness = p.get("brightness", 100)

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

python
sys.exit(1)
    
    print(f"Composing: brightness={p['brightness']} rms={p['rms']:.1f} phase={p['phase']}", file=sys.stderr)
    result = subprocess.run([
        fm,
        "--brightness", str(p["brightness"]),
        "--rms", str(p["rms"]),

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
90% confidence
Finding

If ~/.local/bin/ffmpeg is absent, the code falls back to executing 'ffmpeg' via PATH resolution. In an agent or automation environment, a manipulated PATH could cause execution of a trojaned ffmpeg binary, leading to arbitrary code execution under the agent's privileges.

Content

Scanner excerpt · scripts/compose_from_perception.py (reported line 81)May include surrounding context.

python
if not os.path.exists(ffmpeg):
        ffmpeg = "ffmpeg"
    
    subprocess.run([ffmpeg, "-y", "-i", wav_path, "-codec:a", "libmp3lame", "-b:a", "128k", mp3_path],
                   capture_output=True, timeout=30)
    
    # Save to soundscape directory

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

python
# Run Zig FM composer
    print(f"Composing: brightness={brightness} rms={rms:.1f} phase={phase}", file=sys.stderr)
    result = subprocess.run([
        os.path.expanduser("~/.local/bin/fm_compose"),
        "--brightness", str(brightness),
        "--rms", str(rms),

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

python
# Convert to MP3
    ffmpeg = os.path.expanduser("~/.local/bin/ffmpeg")
    subprocess.run([ffmpeg, "-y", "-i", wav_path, "-codec:a", "libmp3lame", "-b:a", "128k", mp3_path],
                   capture_output=True, timeout=30)
    
    # Save to soundscape directory

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

This code creates a directory and moves a generated MP3 into ~/.qclaw/workspace/soundscape, which is a persistent file write affecting user data. While the script prints the final saved path after completion, there is no prior warning, confirmation, or explanatory docstring/comment that this skill persists output in the user's workspace.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The script writes temporary WAV and MP3 files under /tmp, invokes ffmpeg with -y to overwrite existing output, and later deletes the WAV file. These file-destructive behaviors are not clearly disclosed to the user in comments, docstrings, or a visible warning message.

Content

No source excerpt is available for this finding.