Back to skill

Security audit

Smart Email

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real email assistant, but its install provenance and subagent-based email analysis need review before installing.

Review the repository source before installing, use a pinned trusted commit or release, and resolve the bu-bu-xxx versus openclaw repository mismatch. Treat mailbox auth codes and AI keys as high-value secrets, enter them only in local config, and consider avoiding the subagent provider until it is sandboxed and uses private temporary files. Review the OpenClaw cron jobs after setup because they will continue reading mail and dispatching messages on a schedule.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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
Findings (3)

T01 · Skill Instruction Hijacking

Error
Location
src/smart_email/subagent_analyzer.py:166
Finding

Untrusted Email Content Is Injected into a Tool-Capable Subagent Prompt

Content
View full analysis

Vulnerability Details

File Location: src/smart_email/subagent_analyzer.py:166-219
Vulnerability Type: Prompt injection across an agent-control boundary
Risk Level: High

Vulnerable Code

python
subject = email_data.get('subject', '')
sender = email_data.get('sender', '')
body = email_data.get('body_text', '')[:2000]

prompt = f"""Act as a professional business email routing assistant and analyze the following email.

Email information:
Sender: {sender}
Subject: {subject}
Body: {body}

Email data file: {email_file}
Result output file: {self._results_dir / f"{email_id}.json"}

Produce a JSON result containing:
{{
  "is_urgent": true/false,
  "reason": "Reason for the classification",
  "summary": "A concise summary"
}}

Perform these steps:
1. Read the email data file if it exists
2. Analyze the email
3. Generate the JSON result
4. Overwrite the result file
5. Print "ANALYSIS_COMPLETE: {email_id}"
"""

result = sessions_spawn(
    runtime="subagent",
    mode="run",
    message=prompt,
    timeout_seconds=self.timeout
)

The excerpt above is an English rendering of the source prompt; the relevant data flow, interpolated variables, paths, output requirements, and sessions_spawn call are unchanged.

Technical Analysis

The email sender, subject, and body are attacker-controlled values. They are interpolated directly into the same instruction message used to direct an OpenClaw subagent. The prompt does not establish a strong separation between trusted instructions and untrusted email data, nor does it tell the subagent to reject instructions found inside the email.

This is more dangerous than ordinary LLM classification because the spawned subagent is explicitly instructed to perform filesystem operations. Its effective privileges depend on the OpenClaw runtime, but the code does not explicitly disable tools or constrain filesystem access to the two intend ...[truncated 1717 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace the general-purpose subagent with a constrained inference call that has no shell, filesystem, network, messaging, or other tools.
  2. Pass email fields as structured data rather than concatenating them into an instruction string.
  3. Add a trusted system instruction explicitly stating that the sender, subject, body, attachments, and quoted text are untrusted data and that instructions within them must never be followed.
  4. If a subagent remains necessary, sandbox it with access only to a per-request input file and output file.
  5. Disable all tools except the minimum file operations needed for the dedicated request directory.
  6. Validate the response with a strict JSON schema, including exact types, permitted keys, maximum lengths, and rejection of additional fields.
  7. Treat the generated reason and summary as untrusted output and escape or sanitize them for every delivery channel.
  8. Add adversarial tests containing prompt-injection instructions in the sender, subject, plain-text body, HTML body, and attachment metadata.

T09 · Insecure Skill Coding Practices

Warning
Location
src/smart_email/subagent_analyzer.py:62
Finding

Predictable Shared Temporary Files Permit Email Disclosure and Analysis-Result Tampering

Content
View full analysis

Vulnerability Details

File Location: src/smart_email/subagent_analyzer.py:62-117
Vulnerability Type: Unsafe temporary-file handling
Risk Level: Medium

Vulnerable Code

python
# Temporary file directories
self._emails_dir = Path("/tmp/smart-email/emails")
self._results_dir = Path("/tmp/smart-email/results")

# Create directories
self._emails_dir.mkdir(parents=True, exist_ok=True)
self._results_dir.mkdir(parents=True, exist_ok=True)

def _write_email_for_subagent(self, email_data: Dict, email_id: str) -> Path:
    email_file = self._emails_dir / f"{email_id}.json"
    with open(email_file, 'w', encoding='utf-8') as f:
        fcntl.flock(f.fileno(), fcntl.LOCK_EX)
        try:
            json.dump(email_data, f, ensure_ascii=False, indent=2)
        finally:
            fcntl.flock(f.fileno(), fcntl.LOCK_UN)
    return email_file

def _wait_for_result(self, email_id: str, timeout: float = None) -> Optional[Dict]:
    if timeout is None:
        timeout = self.timeout
    result_file = self._results_dir / f"{email_id}.json"
    start_time = time.time()

    while time.time() - start_time < timeout:
        if result_file.exists():
            try:
                with open(result_file, 'r', encoding='utf-8') as f:
                    fcntl.flock(f.fileno(), fcntl.LOCK_SH)
                    try:
                        result = json.load(f)
                        return result
                    finally:
                        fcntl.flock(f.fileno(), fcntl.LOCK_UN)
            except Exception as e:
                print(f"  [Subagent] Failed to read result: {e}")
                time.sleep(0.5)
        time.sleep(1)

    return None

The comments and diagnostic string in this excerpt are translated into English; the executable operations and data flow correspond to the audited source.

Technical Analysis

Sensitive email data and trusted ...[truncated 2312 chars]

Remediation
View remediation

Remediation Suggestions

  1. Create a private per-run directory with tempfile.TemporaryDirectory() and enforce directory mode 0700.
  2. Generate a cryptographically random request identifier rather than relying on the email ID.
  3. Create files atomically with exclusive semantics, such as os.open with O_CREAT, O_EXCL, and, where available, O_NOFOLLOW.
  4. Set input and output file permissions explicitly to 0600.
  5. Before reading a result, use lstat or equivalent checks to confirm that it is a regular file, is not a symbolic link, and is owned by the expected user.
  6. Write results to a temporary file and atomically rename them into place only after serialization is complete.
  7. Include the random request identifier in the result data and verify it before accepting the result.
  8. Remove stale input and result entries before starting a request, and securely clean the entire private directory after completion.
  9. Prefer an in-memory IPC mechanism or authenticated local socket over shared temporary files where supported.

T08 · Insecure Dependencies

Warning
Location
references/INSTALL.md:9
Finding

Inconsistent Installation Source and Unpinned Dependency Resolution Create Supply-Chain Risk

Content
View full analysis

Vulnerability Details

File Location: references/INSTALL.md:9-17; pyproject.toml:25-29,35-37
Vulnerability Type: Unverified installation source and non-reproducible dependencies
Risk Level: Medium

Vulnerable Code

references/INSTALL.md instructs the Agent to install from the following repository:

bash
cd ~/.openclaw/workspace/skills
git clone https://github.com/bu-bu-xxx/smart-email.git
cd smart-email

pip install -r requirements.txt

However, pyproject.toml declares a different canonical repository and uses open-ended minimum versions:

toml
dependencies = [
    "openai>=1.0.0",
    "requests>=2.28.0",
    "python-dotenv>=1.0.0",
]

[project.urls]
Homepage = "https://github.com/openclaw/smart-email"
Repository = "https://github.com/openclaw/smart-email"

Technical Analysis

The Agent-facing installation guide clones github.com/bu-bu-xxx/smart-email, while package metadata identifies github.com/openclaw/smart-email as the project repository. The reviewed artifact therefore does not establish which source is authoritative.

The installation command clones the repository's current default branch rather than a reviewed release tag or commit. It then installs dependencies from a mutable requirements file. The package constraints only specify minimum versions and do not include upper bounds, hashes, or a lock file.

This does not prove that either repository or any listed dependency is malicious. It does mean that following the installation guide may install code different from the audited artifact, and dependency resolution may change over time without a corresponding Skill review.

Attack Path

  1. An Agent follows the automatic installation instructions in references/INSTALL.md.
  2. It clones the alternate repository's current default branch rather than a reviewed commit.
  3. A repository compromise, ownership change, malicious update, or documentation ...[truncated 971 chars]
Remediation
View remediation

Remediation Suggestions

  1. Establish one canonical repository and make INSTALL.md, both README files, package metadata, and release documentation reference the same verified URL.
  2. Pin installation to a signed release tag or immutable commit hash.
  3. Publish release checksums or signatures and require verification before installation.
  4. Generate a lock file containing exact dependency versions and cryptographic hashes.
  5. Install dependencies with hash enforcement, such as pip install --require-hashes.
  6. Use an isolated virtual environment instead of modifying a shared Python environment.
  7. Add automated checks that reject repository URL mismatches across documentation and package metadata.
  8. Review and update locked dependencies through a controlled process with vulnerability scanning and regression testing.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (97)

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · README_EN.md (reported line 9)May include surrounding context.

md
</div>

<!-- Language Switcher -->
> 🇺🇸 English | [中文](./README.md)

---

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The supplied code does not implement the declared assistant behavior. It only parses a mail ID, constructs archive paths under a local data directory, checks for existence of email.eml/email.md/attachments, and returns those paths. There is no network access, no IMAP handling, no multi-provider mailbox connection logic beyond parsing a provider prefix in the ID, no AI analysis, and no delivery to external communication channels. This is a materially different primary purpose: a local archived-email lookup tool rather than an intelligent email management and alerting assistant.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description is for a full email-processing and notification assistant, involving IMAP retrieval, local archival, AI-based urgency detection, and forwarding to external messaging channels. The supplied code does none of those primary functions. Instead, it is a standalone logging utility that configures file/console logging, rotates logs daily, monkey-patches print, and cleans up old log files. While logging could be a supporting implementation detail in a larger system, this chunk by itself does not implement or directly support the described email-management capabilities in any specific way beyond generic infrastructure. Therefore the code chunk's actual behavior is materially different from the declared purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

该代码与声明有部分重合:确实实现了 IMAP 收取、邮件解析和本地归档(包括正文、附件、Markdown、JSON)。但声明中的核心智能与通知能力在本代码中并不存在。所谓“AI 智能判断紧急邮件”并未出现模型调用、分类逻辑或语义分析,仅检查标准邮件头中的优先级字段;这属于简单规则判断而非 AI。其次,声明中的“自动发送到 Telegram/钉钉/企业微信/飞书等”完全未在代码中体现,没有任何相关 API 调用、Webhook、消息推送或触发逻辑。因此描述明显高于实际行为,构成实质性不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The description presents a full-featured smart email management assistant covering mailbox collection, local archiving, AI urgency judgment, and automatic forwarding to external channels. The supplied code chunk only covers one internal module: analyzing email content for urgency using an OpenClaw subagent and temporary file-based IPC. While urgency analysis is consistent with part of the description, most of the declared end-user capabilities are absent from this code. Because the actual code's primary purpose is substantially narrower than the declared skill behavior, this is a description-behavior mismatch.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

The workflow explicitly instructs the agent to help obtain mailbox authorization codes and populate .env secrets, which creates a credential-handling path inside the agent interaction. In an email skill, these credentials can grant broad mailbox access, so poor secret-handling practices or over-broad agent access could expose accounts or allow persistent compromise.

Content

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

md
当用户表示要开始使用 Smart Email 但尚未完成配置时,Agent 应主动引导用户完成以下步骤:

1. **阅读安装指南**:Agent 自行阅读 `references/USER_GUIDE.md` 获取完整的安装配置流程
2. **协助配置环境变量**:引导用户获取邮箱授权码、填写 .env 配置
3. **引导初始化测试**:指导用户运行 `init` 和 4 步测试流程
4. **协助部署 Cron**:帮助用户执行 `setup-cron --apply` 完成定时任务配置

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

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

md
### 步骤1:提取邮件ID

从消息底部注释提取:`<!-- email_id: xxx -->` 或 `<!-- email_ids: xxx, yyy -->`

### 步骤2:查询原文件

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

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

md
### 步骤1:提取邮件ID

从消息底部注释提取:`<!-- email_id: xxx -->` 或 `<!-- email_ids: xxx, yyy -->`

### 步骤2:查询原文件

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 · README.md (reported line 75)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · README.md (reported line 76)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · README.md (reported line 77)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · README_EN.md (reported line 77)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · README_EN.md (reported line 78)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · README_EN.md (reported line 79)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · references/INSTALL.md (reported line 24)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · references/INSTALL.md (reported line 25)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · references/INSTALL.md (reported line 26)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · references/USER_GUIDE.md (reported line 33)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · references/USER_GUIDE.md (reported line 38)May include surrounding context.

3. 配置环境变量

bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key

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 · src/smart_email/ai_analyzer.py (reported line 35)May include surrounding context.

python
### 3. 配置环境变量

```bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key
```

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 · src/smart_email/ai_analyzer.py (reported line 42)May include surrounding context.

python
### 3. 配置环境变量

```bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key
```

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 · src/smart_email/ai_analyzer.py (reported line 49)May include surrounding context.

python
### 3. 配置环境变量

```bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key
```

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 · src/smart_email/anthropic_analyzer.py (reported line 44)May include surrounding context.

python
### 3. 配置环境变量

```bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key
```

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 · src/smart_email/config.py (reported line 130)May include surrounding context.

python
### 3. 配置环境变量

```bash
# 仅当 ~/.openclaw/.env 不存在时复制配置模板
[ -f ~/.openclaw/.env ] || cp .env.example ~/.openclaw/.env
# 编辑 ~/.openclaw/.env 填写邮箱和 AI API Key
```

Ssd 1

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

Untrusted email fields (sender, subject, body) are interpolated directly into the prompt sent to the LLM, so an attacker can craft an email that contains adversarial instructions. Because the model's output drives urgency classification and summaries, prompt injection can cause misclassification, hiding urgent mail, generating false alerts, or manipulating downstream notification behavior.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.