Back to skill

Security audit

IMAP Mailbox

Security checks for vulnerabilities and agentic risk

Overview

This IMAP email skill is purpose-aligned overall, but it handles mailbox credentials and email-derived files in ways that need review before installation.

Review this skill before installing. It needs your IMAP credentials and can read mailbox contents, which fits its purpose, but it currently disables TLS certificate verification, saves email-derived digests into OpenClaw memory, and can write attachment files using unsafe sender-provided names. Install only if you trust the environment and preferably after fixing TLS verification, attachment filename sanitization, storage locations, and dependency sources.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
cli.js:20
Finding
IMAP TLS Certificate Validation Is Disabled<![CDATA[ ## Vulnerability Details **File Location**: `cli.js:20-29`; `download-attachments.js:14-23` **Vulnerability Type**: Improper certificate validation **Risk Level**: High ### Vulnerable Code ```js function createImap(config) { return new imap({ user: config.email, password: config.password, host: config.host, port: config.port, tls: config.tls, tlsOptions: { rejectUnauthorized: false } }); } ``` ```js const imapConn = new imap({ user: config.email, password: config.password, host: config.host, port: config.port, tls: config.tls, tlsOptions: { rejectUnauthorized: false } }); ``` ### Technical Analysis Both IMAP connection implementations explicitly set `rejectUnauthorized` to `false`. When TLS is enabled, this instructs the client to accept certificates that are expired, self-signed, issued for another hostname, or signed by an untrusted authority. Consequently, TLS encryption does not provide reliable server authentication. An attacker capable of intercepting or redirecting network traffic can present an attacker-controlled certificate without causing the client to reject the connection. ### Attack Path 1. The victim invokes a mailbox command while connected through a network controlled or observed by the attacker. 2. The attacker intercepts or redirects the connection to the configured IMAP host. 3. The attacker presents a forged or otherwise invalid TLS certificate. 4. The client accepts the certificate because certificate validation is disabled. 5. The client supplies the configured email address and password to the impersonated IMAP endpoint. 6. The attacker can capture credentials and proxy, inspect, or manipulate mailbox traffic. ### Impact Assessment A successful attack can expose the mailbox username and password and compromise the confidentiality and integrity of retrieved email data. The attacker may obtain the same mailbox access permitted by the stolen credentials, including reading messages ...[truncated 301 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Remove the `tlsOptions: { rejectUnauthorized: false }` setting or explicitly set `rejectUnauthorized: true`. - Require TLS for credential-bearing IMAP connections unless an explicitly documented legacy mode is necessary. - For private IMAP infrastructure, accept a configured trusted CA certificate rather than disabling verification globally. - Validate that the certificate hostname matches `config.host`. - Fail closed when certificate validation fails, and provide an actionable error rather than silently weakening transport security. - Rotate mailbox credentials after deploying the correction if the application has previously been used on untrusted networks. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
download-attachments.js:39
Finding
Email Attachment Filename Allows Path Traversal and Arbitrary File Overwrite<![CDATA[ ## Vulnerability Details **File Location**: `download-attachments.js:39-42` **Vulnerability Type**: Path traversal through an attacker-controlled attachment filename **Risk Level**: High ### Vulnerable Code ```js parsed.attachments.forEach((att, i) => { const filename = att.filename || `attachment_${i}`; const filePath = path.join(outputDir, filename); fs.writeFileSync(filePath, att.content); console.log(`Saved: ${filename} (${att.content.byteLength} bytes) -> ${filePath}`); }); ``` ### Technical Analysis The filename in a MIME attachment is controlled by the email sender. The implementation passes `att.filename` directly to `path.join` without removing directory separators, rejecting traversal components, resolving the final path, or checking that the destination remains inside `outputDir`. A filename containing components such as `../../` can escape the intended `~/.openclaw/workspace/memory/patent-attachments` directory. `fs.writeFileSync` also overwrites an existing target by default. The vulnerability is triggered when a user downloads attachments from an attacker-crafted message. Exploitation is limited to paths writable by the operating-system account running the Skill, but that scope may include Agent state, user configuration, scripts, and other user-owned files. ### Attack Path 1. An attacker sends the victim an email containing an attachment with a filename such as `../../target-file`. 2. The victim invokes the attachment-download script for the malicious email UID. 3. `mailparser` exposes the attacker-controlled MIME filename as `att.filename`. 4. `path.join(outputDir, filename)` normalizes the traversal components and constructs a path outside the intended attachment directory. 5. `fs.writeFileSync` writes attacker-controlled attachment bytes to the resulting path. 6. If the target exists and is writable, it is overwritten. If the selected target is later interpreted as configuration, memory, or executable content, furthe ...[truncated 680 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Do not use the MIME filename as a filesystem path. - Reduce supplied names to a basename and reject any name containing `/`, `\`, `..`, NUL bytes, or platform-specific path syntax. - Prefer generating a trusted random filename and retaining the original name only as metadata. - Resolve and validate the destination before writing: ```js const safeName = path.basename(att.filename || `attachment_${i}`); const base = path.resolve(outputDir); const destination = path.resolve(base, safeName); if (!destination.startsWith(base + path.sep)) { throw new Error('Unsafe attachment filename'); } ``` - Open files with exclusive-create semantics, such as the `wx` flag, to prevent silent overwrite of existing files. - Apply restrictive file permissions and enforce attachment size and count limits. - Consider storing attachments outside Agent memory so untrusted files cannot be mistaken for trusted state. ]]>

T02 · Agent Memory Poisoning

Error
Location
cli.js:203
Finding
Attacker-Controlled Email Metadata Is Persisted in Agent Memory<![CDATA[ ## Vulnerability Details **File Location**: `cli.js:203-207` and `cli.js:246-273` **Vulnerability Type**: Persistent storage of untrusted content in Agent memory **Risk Level**: High ### Vulnerable Code ```js const from = decodeMime(header.match(/From: (.*)/i)?.[1] || '未知发件人'); const subject = decodeMime(header.match(/Subject: (.*)/i)?.[1] || '无主题'); const date = header.match(/Date: (.*)/i)?.[1] || ''; emails.push({ uid, from, subject, date, isSeen }); ``` ```js let digest = `# 📬 邮件简报 - ${dateStr}\n\n`; digest += `共有 **${newEmails.length}** 封新邮件\n\n`; digest += `---\n\n`; newEmails.forEach((email, i) => { digest += `### ${i + 1}. ${email.subject}\n`; digest += `- **发件人:** ${email.from}\n`; digest += `- **日期:** ${email.date}\n`; digest += `- **UID:** \`${email.uid}\`\n\n`; }); digest += `\n---\n💡 查看完整邮件: \`imap-mailbox read <UID>\`\n`; // 保存到文件 const digestDir = path.join(process.env.HOME, '.openclaw', 'workspace', 'memory', 'email-digests'); if (!fs.existsSync(digestDir)) { fs.mkdirSync(digestDir, { recursive: true }); } const fileName = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}-${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}.md`; const filePath = path.join(digestDir, fileName); fs.writeFileSync(filePath, digest); ``` ### Technical Analysis Email sender and subject fields are controlled by remote email senders. The digest function embeds those fields directly into Markdown and persists the result beneath `.openclaw/workspace/memory/email-digests`. No trust boundary, escaping, structural encoding, or instruction/data separation is applied. A malicious sender can therefore place prompt-like instructions or crafted Markdown in persistent Agent memory. If a later Agent session loads these files as contextual memory and treats their contents as instructions rather than untrusted mailbox data, the attacker-controlled text may ...[truncated 1752 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Do not store remote email content under the Agent’s trusted memory directory. - Store mailbox digests in an application-specific data directory outside Agent memory. - If integration with Agent memory is required, use a structured format that clearly labels every mailbox field as untrusted external data. - Escape Markdown metacharacters and remove control characters before rendering sender-controlled fields. - Add explicit delimiters stating that enclosed content is data and must never be followed as instructions. - Ensure the memory loader applies provenance labels and prevents retrieved external data from overriding system, developer, or user instructions. - Consider storing only numeric message identifiers and trusted summary metadata, with email text fetched on demand. - Provide retention and deletion controls for previously generated digest files. ]]>

T08 · Insecure Dependencies

Warning
Location
package-lock.json:21
Finding
Dependency Lockfile Uses an Unencrypted Third-Party Package Mirror<![CDATA[ ## Vulnerability Details **File Location**: `package-lock.json:21-402` **Vulnerability Type**: Dependencies retrieved from an unsafe package source **Risk Level**: Medium ### Vulnerable Code Representative lockfile entries include: ```json "node_modules/@selderee/plugin-htmlparser2": { "version": "0.11.0", "resolved": "http://mirrors.tencentyun.com/npm/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.11.0.tgz", "integrity": "sha512-P33hHGdldxGabLFjPPpaTxVolMrzrcegejx+0GxjrIb9Zv48D8yAIA/QTDR2dFl7Uz7urX8aX6+5bCZslr+gWQ==", "license": "MIT", "dependencies": { "domhandler": "^5.0.3", "selderee": "^0.11.0" } } ``` ```json "node_modules/imap": { "version": "0.8.19", "resolved": "http://mirrors.tencentyun.com/npm/imap/-/imap-0.8.19.tgz", ``` The reviewed lockfile consistently resolves dependencies through: ```text http://mirrors.tencentyun.com/ ``` ### Technical Analysis The lockfile directs package installation to a third-party mirror over unencrypted HTTP. HTTP does not authenticate the registry endpoint or protect package downloads from interception. The included SHA-512 integrity values substantially reduce the ability of a network attacker to silently replace package archives while the lockfile remains unchanged. Therefore, ordinary interception is more likely to cause installation failure or denial of service than undetected code execution. Nevertheless, the configuration adds avoidable trust in a non-default mirror and creates a higher-risk dependency workflow when lockfiles are generated, updated, or accepted after source changes. ### Attack Path A supply-chain compromise can occur through the following workflow: 1. A developer or build environment installs or updates dependencies using the configured HTTP mirror. 2. The mirror is compromised, impersonated, or manipulated during dependency resolution. 3. A malicious or substituted package version is selected while the lockfile is being regenerated or updated. 4 ...[truncated 993 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Regenerate `package-lock.json` using the official npm registry over HTTPS: ```text https://registry.npmjs.org/ ``` - If an internal mirror is required, use an authenticated, organizationally controlled HTTPS registry with valid certificate verification. - Enforce deterministic installation with `npm ci` and reject unexpected lockfile changes during review. - Retain package integrity hashes and monitor changes to package versions, resolved URLs, and integrity fields. - Add dependency vulnerability and provenance scanning to the build pipeline. - Review transitive dependency updates before committing a regenerated lockfile. - Disallow plain-HTTP package registries in developer and CI configuration. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (22)

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding
The documented behavior does not fully match the detected behavior: the skill apparently writes local state and digest files that are not disclosed, while a declared attachment-download feature is not actually represented in the supplied implementation. Behavior mismatches are dangerous because they undermine user and reviewer expectations, making it easier to hide persistence, sensitive data retention, or other side effects involving email content.

Missing User Warnings

High
Confidence
99% confidence
Finding
The IMAP client disables TLS certificate validation via rejectUnauthorized: false while sending mailbox credentials from local config. This enables man-in-the-middle attacks in which an attacker can impersonate the mail server, capture credentials, and read or alter mailbox traffic; in an email-management skill, that is especially dangerous because it exposes both authentication secrets and sensitive message content.

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
96% confidence
Finding
linkify-it 5.0.0 is flagged with quadratic-complexity denial-of-service issues. In this skill, parsing attacker-controlled email bodies is a core function, so a crafted message containing pathological input could consume excessive CPU during text/link processing and degrade or block mailbox handling.

Known Vulnerable Dependency: nodemailer==8.0.2 — 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
nodemailer 8.0.2 has multiple published advisories, including header injection and resource-consumption issues. Even if only present transitively, its inclusion is especially concerning here because the skill processes untrusted email-derived content and the package provides outbound mail functionality that is outside the stated IMAP-focused purpose.

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
89% confidence
Finding
semver 5.3.0 is affected by a regular-expression denial-of-service vulnerability. Although this appears to be a transitive dependency under utf7 and may not be directly exposed, vulnerable utility libraries still increase risk if attacker-influenced version strings or package metadata are ever parsed during runtime or auxiliary operations.

Lp3

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding
The skill declares capabilities that inherently require network access and likely access to local configuration, but it does not explicitly scope or constrain those tools via permissions or allowed-tools metadata. In an email-reading skill, missing scope increases the chance of overbroad execution, unintended data access, or silent expansion of what the agent may do with mailbox contents and local secrets.

Vague Triggers

Medium
Confidence
94% confidence
Finding
Broad trigger phrases such as checking email or reading inbox can overlap with ordinary conversation, increasing the risk of accidental activation. In the context of a mailbox skill, unintended activation could expose email metadata, fetch message contents, or initiate network actions without sufficiently clear user intent.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The CLI emits Chinese-only messages and later formats dates with the zh-CN locale, indicating a fixed language/locale behavior. There is no opt-in, language selection mechanism, or documentation showing that the skill is intentionally limited to a Chinese-speaking or region-specific context.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The digest operation saves sender, subject, date, and UID information from emails into markdown files under the user's home directory. While it logs the save path after writing, the code does not provide prior disclosure in comments, help text, or a prompt that mailbox contents will be stored locally.

Intent-Code Divergence

Medium
Confidence
97% confidence
Finding
The code exposes a 'setup' command and earlier error text instructs users to run 'imap-mailbox setup' when the config file is missing. However, setupConfig only prints '配置已存在' and does not create, validate, or update configuration, which directly contradicts the documented/advertised intent of the setup flow.

Context-Inappropriate Capability

Medium
Confidence
89% confidence
Finding
The manifest describes an IMAP mailbox skill for reading and managing email, but this file directly accesses ~/.config/imap-mailbox/config.json to load account credentials. While IMAP access itself is expected, reading arbitrary local files from the home directory is a separate local-file access capability that is not justified or declared by the stated skill purpose.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The code loads mailbox configuration, including credentials, from a user-specific config file and uses them to access an email account. While the script's purpose implies email access, there is no comment, docstring, or explicit user-facing disclosure that sensitive credentials are being read from disk.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The script writes downloaded attachments and email text directly to disk in a persistent workspace path without confirmation, sanitization, or minimization. This can expose sensitive documents and message content to other local components, and attacker-controlled attachment filenames may cause unsafe writes within the target tree.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The script is named and described as an attachment downloader, but it also exports the full email body text to a workspace file. That broadens data collection beyond the apparent feature scope and can persist sensitive message content, increasing the risk of unintended disclosure to other tools, users, or processes with access to the workspace.

Context-Inappropriate Capability

Medium
Confidence
92% confidence
Finding
The lockfile includes nodemailer as a transitive dependency even though the skill is described as IMAP mailbox reading/management, not outbound mail sending. Extra outbound-capable mail functionality expands the attack surface and can enable unintended data exfiltration or misuse if exposed through code paths or future changes, especially in an email-processing skill handling sensitive content.

Vague Triggers

Low
Confidence
87% confidence
Finding
The use-case section describes when the skill may be used but does not clearly define when it should not activate, leaving room for ambiguous routing decisions. For an email-access skill, that ambiguity can result in unintentional mailbox operations or disclosure of sensitive message summaries when the user was only speaking generally about email.

Description-Behavior Mismatch

Low
Confidence
86% confidence
Finding
The manifest describes an IMAP mailbox skill for listing, reading, searching, downloading attachments, and digest mode. While digest mode is declared, this implementation also stores mailbox-tracking state and generated digest content under ~/.openclaw/workspace/memory, which extends behavior from transient mailbox operations into local persistence of email metadata and summaries.

Natural-Language Policy Violations

Low
Confidence
87% confidence
Finding
The code explicitly formats dates using toLocaleDateString('zh-CN'), which imposes a Chinese locale regardless of the user's preferences or system settings. This is a natural-language/locale policy concern because the tool does not offer a choice or explain the restriction.

Unpinned Dependencies

Low
Category
Supply Chain
Content
"imap-mailbox": "./cli.js"
  },
  "dependencies": {
    "html-to-text": "^9.0.5",
    "imap": "^0.8.19",
    "mailparser": "^3.6.5",
    "minimist": "^1.2.8"
Confidence
95% confidence
Finding
The dependency uses a caret version range, which allows npm to install newer compatible releases rather than an exact reviewed version. This increases supply-chain risk because a future upstream compromise, malicious publish, or breaking security change could be pulled into the skill without explicit maintainer review.

Unpinned Dependencies

Low
Category
Supply Chain
Content
},
  "dependencies": {
    "html-to-text": "^9.0.5",
    "imap": "^0.8.19",
    "mailparser": "^3.6.5",
    "minimist": "^1.2.8"
  }
Confidence
95% confidence
Finding
The imap package is specified with a caret range, so builds may resolve to different upstream versions over time. For a mail-handling skill that processes credentials and network data, this creates avoidable supply-chain exposure if an unreviewed release introduces malicious code or a vulnerable behavior.

Unpinned Dependencies

Low
Category
Supply Chain
Content
"dependencies": {
    "html-to-text": "^9.0.5",
    "imap": "^0.8.19",
    "mailparser": "^3.6.5",
    "minimist": "^1.2.8"
  }
}
Confidence
95% confidence
Finding
The mailparser dependency is not strictly pinned, allowing automatic adoption of later semver-compatible releases. Because this skill parses attacker-controlled email content, pulling in unreviewed parser changes raises supply-chain and parser-security risk beyond a typical utility package.

Unpinned Dependencies

Low
Category
Supply Chain
Content
"html-to-text": "^9.0.5",
    "imap": "^0.8.19",
    "mailparser": "^3.6.5",
    "minimist": "^1.2.8"
  }
}
Confidence
94% confidence
Finding
The minimist dependency is referenced with a caret range instead of an exact version, permitting drift across installations. While the direct impact is usually limited, it still widens the attack surface for dependency confusion, compromised maintainer releases, or introduction of known vulnerable subversions.

Static analysis

Detected: suspicious.insecure_tls_verification

HTTPS certificate verification is disabled.

Warn
Code
suspicious.insecure_tls_verification
Location
cli.js:28

HTTPS certificate verification is disabled.

Warn
Code
suspicious.insecure_tls_verification
Location
download-attachments.js:22