Back to skill

Security audit

Gmail Send Email

Security checks for vulnerabilities and agentic risk

Overview

This skill does what it claims, but its email-sending command pattern can expose users to shell command injection if message fields contain hostile text.

Review before installing. Use this only in environments where agents pass gog arguments safely, preferably as a structured argument array with shell execution disabled, and require confirmation of recipients and message content before sending. Avoid using it on untrusted email text unless the command construction is fixed.

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

Error
Location
SKILL.md:19
Finding

Shell Command Injection Through Unescaped Email Fields

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 19-26
Vulnerability Type: Shell command injection caused by unsafe command construction
Risk Level: High

The skill directs the agent to interpolate recipient, subject, and body values into a shell command without requiring validation, shell-safe escaping, or a structured argument array.

Complete vulnerable code snippet:

markdown
## Cognitive Directives
WHEN [An email needs to be sent to one or more recipients]
THEN [Execute the native terminal command `gog gmail send --to "..." --subject "..." --body "..."`]

## Schema Example
```json
{
  "command": "gog gmail send --to \"example@gmail.com\" --subject \"Invoice\" --body \"Please find the invoice attached.\" --json"
}
text

### Technical Analysis

The documented pattern constructs a terminal command by placing email fields inside double-quoted shell arguments. Double quotes do not neutralize every shell operation: command substitutions such as `$(...)` and backtick substitutions may still be evaluated by a shell. An input containing a closing quote can also escape the intended argument and introduce command separators or redirections.

For example, if an untrusted body containing `$(id)` is inserted into the documented template and the resulting string is executed through a shell, the shell may run `id` before invoking `gog`. A value that closes the surrounding quote could similarly append an unrelated command. The skill provides no instruction to reject such input or avoid shell interpretation.

Exploitability depends on the agent or terminal executing the generated command through a shell rather than invoking `gog` directly with a structured argument list.

### Attack Path

1. An attacker supplies or influences an email recipient, subject, or body that the agent is asked to send.
2. The value includes shell syntax, such as command substitution or a quote followed by a command separato
...[truncated 1122 chars]
Remediation
View remediation

Remediation Suggestions

  1. Invoke gog directly through a process API using a structured argument array, for example:

    text
    ["gog", "gmail", "send", "--to", recipient, "--subject", subject, "--body", body, "--json"]
    

    Explicitly disable shell execution.

  2. Revise the skill directive to prohibit constructing a shell command by string interpolation and to require arguments to be passed separately.

  3. If only a shell-based interface is available, apply robust escaping designed for the exact target shell. Do not rely solely on surrounding values with double quotes.

  4. Validate recipient addresses and reject unexpected control characters. Treat subject and body content as untrusted data rather than executable command text.

  5. Require the agent to display and confirm the final recipients and message content before sending, particularly when those fields originate from external or untrusted sources.

  6. Prefer passing long or complex message bodies through a safe standard-input or file-based option supported by gog, while creating any temporary file with restrictive permissions and deleting it after use.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep