Back to skill

Security audit

IMAP/SMTP Email (Plus)

Security checks for vulnerabilities and agentic risk

Overview

This email skill does what it says, but it has real security issues around attachment downloads, credential storage, and weakened TLS settings that users should review before installing.

Review this skill before installing. Use a dedicated app password or restricted mailbox account, keep .env out of version control with permissions set to 0600, do not disable TLS certificate validation except in a controlled test environment, and avoid downloading attachments until filename sanitization and no-overwrite protections are added.

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/imap.js:311
Finding

Path Traversal and Arbitrary File Overwrite Through Attachment Filenames

Content
View full analysis

Vulnerability Details

File Location: scripts/imap.js, lines 311–312
Vulnerability Type: Path traversal and unsafe file overwrite
Risk Level: High

Vulnerable Code

js
const filePath = path.join(outputDir, attachment.filename);
fs.writeFileSync(filePath, attachment.content);

Technical Analysis

The attachment filename originates from email MIME metadata and is therefore controlled by the email sender. It is passed directly to path.join() without first rejecting absolute paths, traversal components such as ../, or other unsafe filename forms.

path.join() constructs a path but does not guarantee that the resulting path remains inside outputDir. A malicious filename can consequently resolve outside the intended attachment directory. Moreover, fs.writeFileSync() overwrites an existing destination by default and can follow symbolic links.

Downloading attachments is part of the Skill's declared functionality, but allowing an email sender to select arbitrary filesystem destinations exceeds the minimum filesystem privileges required for that functionality.

Attack Path

  1. An attacker sends an email containing an attachment whose MIME filename includes traversal components, such as ../../target-file.
  2. The victim or an AI Agent invokes node scripts/imap.js download <uid> for that message.
  3. The Skill parses the attacker-controlled attachment filename.
  4. path.join(outputDir, attachment.filename) constructs a path outside the intended output directory.
  5. fs.writeFileSync() writes the attacker-controlled attachment content to that path.
  6. If the destination already exists, it is overwritten; if the path references a symbolic link, the linked target may be modified.

Impact Assessment

An attacker can write or overwrite files accessible to the operating-system account running the Skill. The exact scope is limited by that account's filesystem permissions, but pote ...[truncated 486 chars]

Remediation
View remediation

Remediation Suggestions

  • Treat every attachment filename as untrusted input.
  • Reduce the supplied filename to a safe leaf name with path.basename().
  • Reject absolute paths, . and .. path components, null bytes, empty filenames, and platform-specific path separators.
  • Resolve both the output directory and destination path, then verify that the destination remains beneath the output directory.
  • Refuse to overwrite existing files by using an exclusive creation flag such as { flag: 'wx' }, unless overwrite behavior is explicitly requested and confirmed.
  • Detect and reject symbolic-link destinations.
  • Generate a safe fallback filename when MIME metadata is absent or invalid.
  • Consider setting restrictive permissions on downloaded files.

Example hardening pattern:

js
const baseDir = path.resolve(outputDir);
const safeName = path.basename(attachment.filename || 'attachment.bin');

if (!safeName || safeName === '.' || safeName === '..') {
  throw new Error('Invalid attachment filename');
}

const filePath = path.resolve(baseDir, safeName);
if (!filePath.startsWith(baseDir + path.sep)) {
  throw new Error('Attachment path escapes output directory');
}

fs.writeFileSync(filePath, attachment.content, {
  flag: 'wx',
  mode: 0o600,
});

T09 · Insecure Skill Coding Practices

Warning
Location
setup.sh:135
Finding

Email Credentials Stored Without Enforced Restrictive File Permissions

Content
View full analysis

Vulnerability Details

File Location: setup.sh, lines 135–151
Vulnerability Type: Insecure plaintext credential storage
Risk Level: Medium

Vulnerable Code

bash
# Create .env file
cat > .env << EOF
# IMAP Configuration
IMAP_HOST=$IMAP_HOST
IMAP_PORT=$IMAP_PORT
IMAP_USER=$EMAIL
IMAP_PASS=$PASSWORD
IMAP_TLS=$IMAP_TLS
IMAP_REJECT_UNAUTHORIZED=$REJECT_UNAUTHORIZED
IMAP_MAILBOX=INBOX

# SMTP Configuration
SMTP_HOST=$SMTP_HOST
SMTP_PORT=$SMTP_PORT
SMTP_SECURE=$SMTP_SECURE
SMTP_USER=$EMAIL
SMTP_PASS=$PASSWORD

The same heredoc continues by writing the sender address and SMTP certificate-verification setting before closing the file.

Technical Analysis

The setup script stores an email password, application password, or authorization code in a plaintext .env file. It does not set a restrictive umask before creating the file and does not explicitly apply permissions such as mode 0600 afterward.

The resulting permissions therefore depend on the environment's existing umask. Under a permissive umask, the credentials may be readable by other local users or processes. The project also does not contain a .gitignore, although the documentation advises users to add .env to one, increasing the possibility of accidentally committing the credential file.

Storing credentials is necessary for the declared IMAP/SMTP functionality, but making them potentially accessible beyond the account running the Skill exceeds the minimum privilege required.

Attack Path

  1. A user runs setup.sh in an environment with a permissive umask.
  2. The script creates .env and writes the IMAP and SMTP credentials in plaintext.
  3. Because no restrictive mode is enforced, another local account or process may be able to read the file.
  4. Alternatively, because .env is not excluded by a project-provided .gitignore, the user may accidentally commit and publish it.
  5. An attacker use ...[truncated 646 chars]
Remediation
View remediation

Remediation Suggestions

  • Set umask 077 before creating any credential file.
  • Create .env with mode 0600 and verify its owner.
  • Add .env and equivalent secret files to a project-level .gitignore.
  • Prefer provider-specific application passwords or narrowly scoped authorization tokens instead of primary account passwords.
  • Where practical, use an operating-system credential manager or secret store rather than a plaintext file.
  • Warn before replacing an existing .env file and avoid silently changing its ownership or permissions.
  • Document credential rotation procedures for suspected exposure.

Example hardening:

bash
umask 077

if [ -e .env ]; then
  echo "Refusing to overwrite existing .env"
  exit 1
fi

: > .env
chmod 600 .env

cat > .env <<EOF
# Configuration values
EOF
Vulnerability Patterns
  • 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
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (41)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The description is only partially accurate. The code clearly supports several IMAP mailbox-reading operations: checking messages, fetching full email content, searching, and marking read/unread. However, the claimed SMTP/send-email functionality is absent—there is no SMTP library, no send routine, and no attachment-sending implementation. Additionally, the code includes extra capabilities not mentioned in the description: moving messages to another mailbox, enumerating mailboxes, and downloading attachments to disk. Because the declared purpose prominently includes sending email via SMTP, and that capability is not present, this is a material description-behavior mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The description presents a combined IMAP/SMTP email skill with both read and write operations. However, this code chunk is exclusively an SMTP CLI sender built with nodemailer. It creates an SMTP transporter from environment variables, sends outbound mail, handles attachments, and offers a connection test that sends a test message. There is no IMAP library, no mailbox access, no message retrieval, and no state-changing operations on existing emails. While the sending portion aligns with part of the description, the declared purpose materially overstates the implemented capabilities in this code chunk.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 59)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 71)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 78)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 90)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 108)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 109)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 116)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 122)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 125)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 128)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 135)May include surrounding context.

md
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]

Known Vulnerable Dependency: linkify-it==5.0.0 — 2 advisory(ies): CVE-2026-48801 (LinkifyIt#match scan loop has quadratic algorithmic complexity); CVE-2026-59887 (linkify-it: Quadratic-complexity DoS via the `mailto:` validator scan-loop on at)

High
Category
Supply Chain
Confidence
95% confidence
Finding

The lockfile pins linkify-it 5.0.0, which is reported as vulnerable to quadratic-complexity parsing in URL/mailto matching. In this skill, mail content is attacker-controlled and mailparser depends on linkify-it, so a crafted email body could trigger excessive CPU consumption and cause denial of service during email processing.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: nodemailer==7.0.13 — 10 advisory(ies): CVE-2026-82661 (Nodemailer: CRLF injection in Nodemailer List-* header comments allows arbitrary); GHSA-2x7j-588g-ccc2 (Nodemailer: Quadratic (O(n²)) time complexity in addressparser allows remote den); GHSA-8m3c-c648-2xjj (Nodemailer: resolveContent() on a MailMessage bypasses disableFileAccess/disable) +7 more

High
Category
Supply Chain
Confidence
98% confidence
Finding

The project directly depends on nodemailer 7.0.13, which has multiple advisories including header injection, parser complexity DoS, and content resolution bypass issues. Because this skill sends email and may construct messages from untrusted agent or user input, these flaws are directly relevant and could enable denial of service, header manipulation, or unintended file/URL content inclusion depending on how the library is used.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: semver==5.3.0 — 1 advisory(ies): CVE-2022-25883 (semver vulnerable to Regular Expression Denial of Service)

High
Category
Supply Chain
Confidence
84% confidence
Finding

The lockfile includes semver 5.3.0, which is affected by a ReDoS vulnerability. Here it is a transitive dependency via utf7, so exploitability depends on whether attacker-controlled data reaches semver parsing; that makes it less directly exposed than the email-parser and mail-sending issues, but it is still a genuine vulnerable component present in the dependency tree.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: nodemailer==7.0.13 — 10 advisory(ies): CVE-2026-82661 (Nodemailer: CRLF injection in Nodemailer List-* header comments allows arbitrary); GHSA-2x7j-588g-ccc2 (Nodemailer: Quadratic (O(n²)) time complexity in addressparser allows remote den); GHSA-8m3c-c648-2xjj (Nodemailer: resolveContent() on a MailMessage bypasses disableFileAccess/disable) +7 more

High
Category
Supply Chain
Confidence
97% confidence
Finding

The package explicitly depends on nodemailer 7.0.13, which static analysis reports as having multiple known advisories, including header injection and content-access bypass issues. In an email skill that sends mail and may process user-controlled recipients, headers, body content, or attachments, these flaws can directly affect message integrity, enable abuse of outbound email generation, or expose local/remote content unexpectedly.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/imap.js (reported line 13)May include surrounding context.

js
const nodemailer = require('nodemailer');
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });

// Parse command-line arguments
function parseArgs() {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/smtp.js (reported line 11)May include surrounding context.

js
const nodemailer = require('nodemailer');
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });

// Parse command-line arguments
function parseArgs() {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/smtp.js (reported line 51)May include surrounding context.

js
const nodemailer = require('nodemailer');
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });

// Parse command-line arguments
function parseArgs() {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · setup.sh (reported line 9)May include surrounding context.

sh
echo "  IMAP/SMTP Email Skill Setup"
echo "================================"
echo ""
echo "This script will help you create a .env file with your email credentials."
echo ""

# Prompt for email provider

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · setup.sh (reported line 136)May include surrounding context.

sh
echo "  IMAP/SMTP Email Skill Setup"
echo "================================"
echo ""
echo "This script will help you create a .env file with your email credentials."
echo ""

# Prompt for email provider

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · setup.sh (reported line 137)May include surrounding context.

sh
echo "  IMAP/SMTP Email Skill Setup"
echo "================================"
echo ""
echo "This script will help you create a .env file with your email credentials."
echo ""

# Prompt for email provider

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · setup.sh (reported line 158)May include surrounding context.

sh
echo "  IMAP/SMTP Email Skill Setup"
echo "================================"
echo ""
echo "This script will help you create a .env file with your email credentials."
echo ""

# Prompt for email provider

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script asks whether to accept self-signed certificates and, if the user answers yes, sets certificate verification to false for both IMAP and SMTP connections. Disabling TLS certificate validation enables man-in-the-middle interception of email credentials and message contents, especially dangerous because this skill handles authentication secrets and sensitive communications.

Content

No source excerpt is available for this finding.

Static analysis

Detected: suspicious.env_credential_access

Environment variable access combined with network send.

Critical
Code
suspicious.env_credential_access
Location
scripts/imap.js:23