Back to skill

Security audit

HERA Mail

Security checks for vulnerabilities and agentic risk

Overview

This skill is a coherent internal mail tool, but its scripts can be misused to read files outside the mailbox and impersonate other agents.

Review before installing. Use this only in a tightly controlled HERA workspace where agents and callers are trusted, avoid sending secrets or sensitive local files as attachments, and require fixes for path containment, safe filename validation, sender authentication, and retention guidance before relying on it for multi-agent workflows.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/read_mail.py:16
Finding

Unchecked Path Components Permit Arbitrary Local File Disclosure and Filesystem Writes

Content
View full analysis

Vulnerability Details

File Location: scripts/read_mail.py, lines 16-36
Vulnerability Type: Path traversal and insufficient path containment
Risk Level: High

Vulnerable Code

python
base_dir = Path("/Users/zhaoruiwu/.openclaw/workspace/hera-agents")
inbox_dir = base_dir / agent_name / "inbox"

mail_file = inbox_dir / mail_file_name

if not mail_file.exists():
    print(f"❌ Mail not found: {mail_file_name}")
    print(f"   Check inbox with: python3 list_inbox.py {agent_name}")
    return

# Read and display content
content = mail_file.read_text()

print("\n" + "=" * 60)
print("📖 MESSAGE CONTENT")
print("=" * 60 + "\n")
print(content)
print("\n" + "=" * 60)

# Mark as read
read_marker = mail_file.with_suffix(".read")
read_marker.touch()
print(f"✓ Marked as read: {mail_file_name}")

Technical Analysis

Both agent_name and mail_file_name are accepted directly from command-line arguments and used to construct filesystem paths without validation or containment checks.

Python's pathlib discards preceding path components when a later component is absolute. Consequently, an absolute mail_file_name causes mail_file to refer directly to the supplied location rather than a file beneath the intended inbox. Relative paths containing .. can also escape the inbox directory.

The selected path is passed to read_text(), and its contents are printed before any .read marker operation occurs. The script then derives another attacker-influenced path using with_suffix(".read") and calls touch(), creating or modifying that file if process permissions allow.

Similar unchecked agent-path construction occurs in:

  • scripts/list_inbox.py:20-21
  • scripts/send_mail.py:18-22
  • scripts/send_mail.py:31-50

In send_mail.py, an absolute or traversing agent path can redirect inbox and outbox operations into unintended writable directories, provided the selected ...[truncated 1771 chars]

Remediation
View remediation

Remediation Suggestions

  1. Define an explicit allowlist of valid agent names rather than accepting arbitrary path components.

  2. Require mail_file_name to be a plain basename ending in .md.

  3. Reject absolute paths, .., path separators, null bytes, and unexpected suffixes.

  4. Resolve the inbox and candidate paths before access, then verify containment:

    python
    inbox_dir = (base_dir / agent_name / "inbox").resolve()
    mail_file = (inbox_dir / mail_file_name).resolve()
    
    if not mail_file.is_relative_to(inbox_dir):
        raise ValueError("Mail path escapes the inbox")
    
  5. Require the target to be a regular file and consider rejecting symbolic links:

    python
    if not mail_file.is_file() or mail_file.is_symlink():
        raise ValueError("Invalid mail file")
    
  6. Construct read markers from a validated mail identifier rather than an arbitrary supplied path.

  7. Apply equivalent resolution and containment checks to every path constructed in list_inbox.py and send_mail.py.

  8. Run the skill under a dedicated, least-privileged account with filesystem access restricted to the HERA workspace.

T01 · Skill Instruction Hijacking

Warning
Location
scripts/send_mail.py:21
Finding

Unauthenticated Sender Selection Allows Trusted-Agent Impersonation

Content
View full analysis

Vulnerability Details

File Location: scripts/send_mail.py, lines 21-57
Vulnerability Type: Missing sender authentication and authorization
Risk Level: Medium

Vulnerable Code

python
# Validate agents exist
from_dir = base_dir / from_agent
to_dir = base_dir / to_agent

if not from_dir.exists():
    print(f"❌ Sender agent not found: {from_agent}")
    return False

if not to_dir.exists():
    print(f"❌ Recipient agent not found: {to_agent}")
    return False

# Create inbox if needed
inbox_dir = to_dir / "inbox"
inbox_dir.mkdir(exist_ok=True)

# Generate mail ID
timestamp = datetime.now().strftime("%Y-%m-%d-%H%M%S")
mail_id = f"{timestamp}-{from_agent}-{to_agent}"
mail_file = inbox_dir / f"{mail_id}.md"

# Create mail content
mail_content = f"""[FROM: {from_agent}]
[TO: {to_agent}]
[TIMESTAMP: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}]
[MAIL-ID: {mail_id}]
[SUBJECT: {subject}]
[STATUS: unread]

---

{body}

---
[END]
"""

# Write mail
mail_file.write_text(mail_content)

Technical Analysis

The script treats the caller-provided from_agent argument as the authoritative sender identity. Its only validation is that a directory bearing that name exists. There is no authentication mechanism, caller-to-agent identity binding, authorization check, message signature, or verification token.

Any local caller that can execute the script and write to the HERA workspace can therefore select a trusted identity such as group-leader and create a message carrying arbitrary subject and body content in another agent's inbox.

This is particularly significant because SKILL.md describes inbox messages as the primary method for assigning work and coordinating agents. A recipient may consequently interpret forged content as an authorized instruction from a trusted agent. The body and subject are also embedded without strict structural validation, ...[truncated 2005 chars]

Remediation
View remediation

Remediation Suggestions

  1. Authenticate every caller and bind the authenticated identity to exactly one permitted from_agent value.
  2. Enforce authorization rules describing which agents may send messages to each recipient.
  3. Use per-agent operating-system accounts or narrowly scoped filesystem permissions so one agent cannot write directly into another agent's outbox or impersonate its identity.
  4. Digitally sign messages using per-agent keys and verify signatures before displaying sender identity or treating a message as an instruction.
  5. Store verified sender identity separately from caller-controlled message content.
  6. Validate subject and identity fields as single-line values and reject newline characters or mail-format delimiters.
  7. Clearly label message bodies and attachments as untrusted input until sender verification succeeds.
  8. Add audit logging containing the authenticated caller, claimed sender, recipient, message identifier, and signature-verification result.
  9. Ensure downstream agents require explicit confirmation before executing sensitive instructions received through mail.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (4)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script builds filesystem paths directly from untrusted command-line inputs for both agent_name and mail_file_name without validating or constraining them to the intended inbox. Because pathlib path joining accepts traversal components such as '..' and absolute paths can override prior components, an attacker can read arbitrary local files and create a corresponding .read marker outside the mailbox directory.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill description says it should be used whenever any HERA agent needs agent-to-agent communication and metadata sets it to always activate, which is an overly broad trigger for a capability that can move messages and attachments between agents. Broad activation increases the chance an agent invokes the mail skill in inappropriate contexts, enabling unnecessary data sharing, prompt-routing abuse, or accidental exfiltration of workspace files through attachments.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The documentation explains how to send arbitrary attachments and describes persistent storage locations for inboxes, outboxes, and attachment files, but it provides no warnings about data retention, sensitivity, or the risks of transferring local files. In an agent environment, this makes accidental disclosure more likely because users or agents may treat mail as ephemeral while actually copying potentially sensitive files into durable shared storage.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The script claims to read a specific email, but it does not enforce that the target is actually a mail file in the inbox or even a Markdown file. This broadens the attack surface beyond intended mail content, enabling access to arbitrary non-mail files if a user supplies crafted input, which can expose sensitive data and cause misleading behavior.

Content

No source excerpt is available for this finding.