Back to skill

Security audit

Sonarr

Security checks for vulnerabilities and agentic risk

Overview

This Sonarr skill mostly does what it says, but it also includes immediate show removal and optional media-file deletion that are not disclosed in the short manifest description.

Install only if you are comfortable giving this skill authority to modify your Sonarr library. Be especially careful with remove operations: --delete-files can delete media managed by Sonarr, and the script itself will not ask for another confirmation. Keep the Sonarr config file private and consider rotating the API key if process logs may capture command arguments.

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/sonarr.sh:21
Finding
Sonarr API Key Exposed Through Process Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/sonarr.sh`, lines 21-29; the same pattern is used by subsequent `curl` commands throughout the script **Vulnerability Type**: Exposure of credentials through process arguments **Risk Level**: Medium ### Vulnerable Code ```bash API="$SONARR_URL/api/v3" AUTH="X-Api-Key: $SONARR_API_KEY" cmd="$1" shift || true case "$cmd" in search) query="$1" curl -s -H "$AUTH" "$API/series/lookup?term=$(echo "$query" | jq -sRr @uri)" | jq -r ' ``` The `AUTH` variable containing the Sonarr API key is passed to `curl` through the `-H` command-line option. This pattern is also present at lines 38, 42, 51, 54, 70, 78, 83, 104, 131, and 143. ### Technical Analysis When a secret is supplied as a command-line argument, it becomes part of the spawned process's argument vector. Depending on operating-system process visibility, `/proc` permissions, container configuration, monitoring tools, and the privileges of local users, another process may be able to observe a command resembling: ```text curl -s -H X-Api-Key: <secret> http://localhost:8989/api/v3/... ``` Although the exposure window is limited to the lifetime of each `curl` process, the script makes multiple requests and may be invoked repeatedly. Process-monitoring or audit infrastructure may also retain command-line arguments after the process exits. Reading the dedicated configuration file at `~/.clawdbot/credentials/sonarr/config.json` is necessary for the Skill's declared functionality and does not itself exceed least privilege. The reviewed code does not access unrelated credential paths or transmit the key to an unrelated destination. The weakness is specifically the method used to transfer that key from the script to `curl`. ### Attack Path 1. The user invokes a command such as `search`, `config`, `add`, or `remove`. 2. The script reads the Sonarr API key from the dedicated configuration file. 3. It constructs the `AUTH` variable containing th ...[truncated 1329 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Avoid placing the API key in `curl` command-line arguments. Supply sensitive `curl` configuration through standard input, for example: ```bash sonarr_curl() { curl --silent --config - "$@" <<EOF header = "X-Api-Key: $SONARR_API_KEY" EOF } ``` Replace calls such as: ```bash curl -s -H "$AUTH" "$API/series" ``` with: ```bash sonarr_curl "$API/series" ``` Carefully preserve required methods, request bodies, and content-type headers when adapting POST and DELETE operations. 2. If a temporary configuration file must be used, create it with restrictive permissions, keep it outside shared directories, and remove it reliably: ```bash umask 077 config_file=$(mktemp) trap 'rm -f "$config_file"' EXIT ``` Standard input is preferable because it avoids persisting the key on disk. 3. Validate the credential file's ownership and permissions before reading it. Document and enforce restrictive permissions: ```bash chmod 600 ~/.clawdbot/credentials/sonarr/config.json ``` 4. Avoid printing the API key in errors, debugging output, shell tracing, or logs. Ensure the script is not run with `set -x` while credentials are loaded. 5. Restrict Sonarr's network exposure to trusted interfaces and rotate the API key if process monitoring or logs may already have captured it. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (6)

Lp3

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding
The skill invokes shell commands (`bash scripts/sonarr.sh ...`) and depends on `curl` and `jq`, but the manifest does not declare permissions/capabilities accordingly. This creates an auditability and trust gap: consumers may underestimate the skill's execution privileges and the fact that it can make local/networked changes through shell execution.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The declared purpose says the skill searches for and adds TV shows, but the documented behavior also includes existence checks, configuration enumeration, removal of shows, and optional deletion of files. This mismatch is dangerous because users or higher-level agents may authorize the skill for low-risk add/search operations while it actually supports destructive actions that can remove content and delete local media files.

Description-Behavior Mismatch

Medium
Confidence
94% confidence
Finding
The manifest description omits the documented show-removal capability, including an option to delete files. Hiding destructive functionality in documentation rather than the manifest increases the risk of unsafe delegation, especially when an orchestrating agent or user relies on the manifest summary to decide what the skill is allowed to do.

Description-Behavior Mismatch

High
Confidence
99% confidence
Finding
The skill metadata says it searches and adds TV shows, but the script also implements a remove command that can delete series from Sonarr. This is a capability mismatch that can mislead users or calling agents into invoking destructive behavior they did not expect, increasing the chance of unauthorized or accidental content removal.

Context-Inappropriate Capability

High
Confidence
98% confidence
Finding
The script exposes a file-deletion path through Sonarr via the --delete-files option even though the stated purpose is only searching and adding shows. Hidden destructive functionality is especially risky in agent skills because orchestration layers may grant trust based on the manifest and unknowingly expose deletion of managed media files.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The destructive delete-files path executes immediately with no confirmation, preview, or safeguard. In an agent context, a malformed request, prompt injection, or user misunderstanding could trigger irreversible media deletion without any last-chance validation.

Static analysis

No suspicious patterns detected.