Back to skill

Security audit

Simple SMTP Mailer

Security checks for vulnerabilities and agentic risk

Overview

This SMTP email skill is purpose-aligned, but it needs Review because its agent guide uses unsafe shell interpolation for email fields and documents persistent plaintext SMTP credentials.

Review before installing. Use an app-specific SMTP password, keep ~/.msmtp/config private and out of backups/repos, confirm exact recipients and message content before sending, and avoid agent workflows that paste untrusted email fields into a shell command string.

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
CLAUDE.md:10
Finding
Shell Command Injection Through Unescaped Email Fields## Vulnerability Details **File Location**: `CLAUDE.md`, lines 10-19 **Vulnerability Type**: Shell command injection caused by unsafe interpolation of user-controlled input **Risk Level**: High ### Vulnerable Code ```bash ## Sending Email Command ```bash echo -e "Subject: <SUBJECT>\n\n<BODY>" | msmtp --file=/Users/yugaoxiang/.msmtp/config <RECIPIENT> ``` Or with From header: ```bash echo -e "Subject: <SUBJECT>\nFrom: <SENDER_EMAIL>\n\n<BODY>" | msmtp --file=/Users/yugaoxiang/.msmtp/config <RECIPIENT> ``` ``` ### Technical Analysis The skill instructs the agent to substitute the subject, body, sender address, and recipient directly into a shell command executed through the `exec` tool. These values can originate from an untrusted email request. Double quotes do not prevent all shell evaluation. In particular, command substitutions such as `$(...)` and backtick substitutions are still evaluated inside double-quoted subject, sender, and body fields. The recipient placeholder is not quoted at all, allowing shell separators, redirections, substitutions, wildcard expansion, and additional command-line arguments to be interpreted. Consequently, an attacker can cause the shell to execute commands unrelated to sending email. For example, a subject containing a benign proof string such as `$(id > /tmp/msmtp-injection-proof)` would execute `id` while the shell constructs the message. An unquoted recipient containing a shell separator could similarly append another command. The examples in `SKILL.md`, lines 61-77, use the same general shell-pipeline pattern, although they contain fixed example values rather than explicit substitution placeholders. ### Attack Path 1. An attacker or untrusted document supplies an email subject, body, sender, or recipient containing shell syntax. 2. The agent follows `CLAUDE.md` and replaces the placeholders in the documented command with those ...[truncated 1219 chars]
Remediation
## Remediation Suggestions 1. Do not construct a shell command by concatenating or interpolating email fields. 2. Invoke `msmtp` directly with an argument array so no shell parses the recipient or other values. 3. Construct the RFC 5322 message as data in memory and provide it to the process through standard input. 4. Validate recipient and sender addresses with a strict email-address parser. Reject newline characters, carriage returns, NUL bytes, shell metacharacters where inappropriate, and values beginning with command-line option prefixes. 5. Validate header fields separately and reject CR/LF characters to prevent email-header injection. 6. Preserve body content as standard-input data rather than embedding it in a command string. 7. Use the current user's resolved home directory or the default `msmtp` configuration lookup instead of the hard-coded `/Users/yugaoxiang/` path. 8. If a shell is unavoidable, pass dynamic data through positional parameters rather than interpolating it into shell source; however, direct process invocation remains the preferred solution. 9. Add tests covering command substitutions, semicolons, pipes, redirections, leading hyphens, quotes, backticks, and multiline header values.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Rogue AgentSelf-Modification, Session Persistence
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (7)

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The skill instructs the agent to transmit user-supplied subject/body content and recipient data through SMTP to an external mail server, but it does not require any user-facing disclosure, confirmation, or boundary check before exfiltrating that content. In an agent setting, this creates a real risk of unintended disclosure of sensitive information or unauthorized outbound communication, especially if the agent composes or forwards content derived from private context.

Session Persistence

Medium
Category
Rogue Agent
Content
## Configuration

Create a configuration file at `~/.msmtp/config` with the following format:

```
account default
Confidence
93% confidence
Finding
The documented approach establishes persistent storage of SMTP credentials in `~/.msmtp/config`, creating a long-lived authentication artifact on disk. In the context of an email-sending skill, persistent credentials increase the risk of account compromise if the home directory, backups, or synced dotfiles are exposed.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill instructs users to place an SMTP password directly into a persistent plaintext config file without an explicit warning about credential sensitivity or safer alternatives. Although `chmod 600` reduces local exposure, this still creates a durable secret-at-rest that may be leaked via backups, dotfile sync, screenshots, shell support sessions, or accidental repository commits.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
**Linux (Debian/Ubuntu):**
```bash
sudo apt install msmtp
```

**Linux (Fedora/RHEL):**
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
**Linux (Debian/Ubuntu):**
```bash
sudo apt install msmtp
```

**Linux (Fedora/RHEL):**
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
### 3. Set Permissions
```bash
chmod 600 ~/.msmtp/config
```

## Sending Email
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The skill explicitly sends data via SMTP email, but the description does not warn users that provided content will be transmitted to an external mail server. This can lead to unintentional disclosure of sensitive data because users may invoke the skill without realizing their prompt content, attachments, or generated output are leaving the local environment.

Static analysis

No suspicious patterns detected.