Back to skill

Security audit

GOG Stale Games Cleaner

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly coherent and disclosed, but its script has unsafe environment-variable handling that can lead to command execution and email-header manipulation.

Review this skill before installing or running it. Use dry-run first, only run it in a trusted environment, and avoid passing untrusted values through STALE_DAYS or EMAIL_TO. The publisher should validate numeric configuration and email recipients before this is treated as low risk.

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/gog-stale-scan.sh:25
Finding
Shell Command Execution Through Unvalidated STALE_DAYS Arithmetic Expression<![CDATA[ ## Vulnerability Details **File Location**: `scripts/gog-stale-scan.sh`, lines 6 and 25 **Vulnerability Type**: Shell arithmetic injection **Risk Level**: High ### Vulnerable Code ```bash STALE_DAYS="${STALE_DAYS:-30}" ``` ```bash CUTOFF_EPOCH=$(( $(date +%s) - STALE_DAYS * 86400 )) ``` ### Technical Analysis The script accepts `STALE_DAYS` from the process environment without verifying that it contains only a valid decimal integer. It subsequently references that variable inside a Bash arithmetic expansion. Bash arithmetic expressions recursively evaluate variable values as arithmetic syntax. Crafted expressions can abuse arithmetic constructs, including evaluated array subscripts and nested shell expansions, to trigger command execution. Quoting the original environment-variable assignment does not prevent this because the dangerous interpretation occurs later inside `$((...))`. An attacker capable of controlling the environment used to invoke the Skill could therefore provide a malicious arithmetic expression instead of a numeric day count. The payload would be evaluated when the script calculates `CUTOFF_EPOCH`, before the GOG library is processed. ### Attack Path 1. An attacker gains the ability to influence the `STALE_DAYS` environment variable, such as through an Agent-controlled invocation, wrapper script, automation configuration, or inherited process environment. 2. The attacker supplies a Bash arithmetic expression containing a command-executing expansion rather than a decimal integer. 3. Line 6 accepts the malicious value without validation. 4. Line 25 evaluates the value as part of the arithmetic expression used to calculate the cutoff timestamp. 5. The embedded command executes with the operating-system privileges and environment of the Skill process. ### Impact Assessment Successful exploitation provides arbitrary local command execution under the account running the Skill. The attacker could read or modify files accessible t ...[truncated 462 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Validate `STALE_DAYS` before using it in any arithmetic context. Require an ASCII decimal integer and enforce a reasonable operational range: ```bash if [[ ! "$STALE_DAYS" =~ ^[0-9]+$ ]]; then echo "Invalid STALE_DAYS: expected a positive integer" >&2 exit 1 fi if (( 10#$STALE_DAYS < 1 || 10#$STALE_DAYS > 36500 )); then echo "Invalid STALE_DAYS: value is outside the allowed range" >&2 exit 1 fi CUTOFF_EPOCH=$(( $(date +%s) - 10#$STALE_DAYS * 86400 )) ``` The `10#` prefix forces decimal interpretation and avoids unexpected octal handling for values with leading zeroes. Validation must occur before the variable is referenced inside any arithmetic expansion. Apply the same allow-list approach to every environment-controlled value that may enter shell arithmetic or command syntax. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/gog-stale-scan.sh:75
Finding
Email Header Injection Through Unvalidated EMAIL_TO Configuration<![CDATA[ ## Vulnerability Details **File Location**: `scripts/gog-stale-scan.sh`, lines 9 and 75–83 **Vulnerability Type**: Email header injection **Risk Level**: Medium ### Vulnerable Code ```bash EMAIL_TO="${EMAIL_TO:-}" # empty = use account address ``` ```bash TMPFILE=$(mktemp /tmp/gog-stale-email-XXXXXX.mml) TO_HEADER="${EMAIL_TO:+To: $EMAIL_TO}" cat > "$TMPFILE" <<HEREDOC From: $(himalaya account list 2>/dev/null | grep -A1 "$EMAIL_ACCOUNT" | tail -1 | awk '{print $NF}' || echo "") ${TO_HEADER} Subject: ${SUBJECT} Content-Type: text/html ${HTML_BODY} HEREDOC ``` ### Technical Analysis `EMAIL_TO` is accepted from the environment and interpolated directly into the header section of an MML email template. The script does not reject carriage-return or newline characters and does not parse the value as a single structured mailbox address. A crafted value containing a line break can terminate the intended `To` header and introduce additional headers such as `Bcc`, `Cc`, or altered MIME metadata. Depending on Himalaya's template parser, an attacker may also be able to modify the boundary between headers and the message body. The temporary file itself is created with `mktemp`, which mitigates predictable-file and symlink attacks. The vulnerability arises from unsafe construction of the message contents, not from the temporary filename. ### Attack Path 1. An attacker gains control over the `EMAIL_TO` environment variable used for a non-dry-run invocation. 2. The attacker provides a value containing a newline followed by an additional email header, such as an unintended recipient header. 3. The script copies the value verbatim into `TO_HEADER`. 4. The generated MML template contains the attacker-supplied header. 5. `himalaya template send` parses and sends the manipulated message. 6. The stale-game report may be delivered to an unintended recipient or have its message metadata altered. ### Impact Assessment The report contains the user's insta ...[truncated 536 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Reject all carriage-return and newline characters before constructing an email header: ```bash if [[ "$EMAIL_TO" == *$'\r'* || "$EMAIL_TO" == *$'\n'* ]]; then echo "Invalid EMAIL_TO: line breaks are not permitted" >&2 exit 1 fi ``` Additionally: 1. Validate that the value represents exactly one permitted mailbox address. 2. Prefer a structured Himalaya recipient option or API over manually assembling raw message headers. 3. If raw templates are unavoidable, serialize all headers through a library or tool that performs standards-compliant encoding and prevents header-boundary injection. 4. Consider requiring an explicitly configured recipient rather than deriving routing behavior from loosely controlled environment data. 5. Test malicious values containing CR, LF, CRLF, `Bcc:`, `Cc:`, and blank lines to verify that they are rejected before the email template is created or sent. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The skill’s stated purpose is cleanup-oriented, but its documented behavior includes sending library-derived data through an external email account and creating Apple Reminders entries, which are actions against external services with privacy and side-effect implications. Even though these behaviors are described later in the document, the top-level declaration does not clearly communicate the permission-sensitive operations, increasing the risk of users or agents invoking it without informed consent.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The skill description does not prominently warn that a normal run will transmit game-usage information by email and create reminder items automatically. This can lead to unintended disclosure of personal activity data and unexpected state changes in linked services, especially when an agent chooses the skill based only on its short description.

Static analysis

No suspicious patterns detected.