Back to skill

Security audit

126 Mail Cleanup

Security checks for vulnerabilities and agentic risk

Overview

This skill is openly meant to manage and delete mail, but its documented deletion flow can permanently remove unrelated messages already marked deleted in the mailbox.

Install only if you are comfortable granting full IMAP access to your 126.com mailbox and creating local copies of email data. Before using cleanup or strip, make a full backup and avoid any workflow that immediately EXPUNGEs the mailbox unless it restricts expunge to the approved UID set or moves messages to Trash/staging for later manual deletion.

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
SKILL.md:172
Finding

Global IMAP EXPUNGE Can Permanently Delete Unapproved Messages

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 172–186
Vulnerability Type: Unsafe IMAP deletion semantics
Risk Level: High

Vulnerable Code Snippet:

markdown
### What It Does
1. Shows classified email counts by category
2. User reviews and approves DELETE_DOMAINS list and KEEP_DOMAINS list
3. **Safety net**: Copies target emails to a staging folder (e.g., "广告邮件") BEFORE deleting from INBOX
4. Deletes from INBOX via `UID STORE +FLAGS \Deleted` + `EXPUNGE`
5. Random-sample verification (10 emails spot-checked)

### The Safe Deletion Flow

INBOX emails ──UID COPY──> 广告邮件夹 (staging copy) │ └── UID STORE \Deleted + EXPUNGE (remove from INBOX)

User verifies in web client...

text

### Technical Analysis

Although `UID STORE` marks only the approved messages with the IMAP `\Deleted` flag, the subsequent standard `EXPUNGE` command is mailbox-wide. It permanently removes every message already marked `\Deleted` in the selected mailbox, not only the UIDs selected by this cleanup workflow.

Consequently, messages previously marked for deletion by another mail client, another session, or an interrupted operation may be expunged without being included in the reviewed target set. The staging-copy safeguard applies only to messages selected by this skill and therefore does not protect unrelated messages carrying a pre-existing `\Deleted` flag.

This behavior also contradicts the skill's stated safety guarantee that messages are not permanently deleted without user approval.

### Attack Path

1. A separate IMAP or webmail client marks an unrelated message as `\Deleted` but does not expunge it.
2. The user approves a different set of messages for cleanup.
3. The skill copies only its approved target messages to the staging folder.
4. The skill applies `\Deleted` to the approved UIDs using `UID STORE`.
5. The skill executes the mailbox-wide `EXPUNGE` command.
6. The server perma
...[truncated 692 chars]
Remediation
View remediation

Remediation Suggestions

  1. Use UID EXPUNGE <approved-uids> when the server advertises support for UIDPLUS, so permanent deletion is restricted to the reviewed UID set.
  2. Prefer moving approved messages to the server's Trash folder without immediately expunging them. Let retention policy or a separate, explicitly confirmed purge remove them permanently.
  3. Before deletion, query and record all pre-existing \Deleted messages. Abort if unrelated deleted flags are present, or temporarily clear and later restore those flags when server behavior permits.
  4. Serialize the cleanup operation and warn the user to close or pause other mailbox clients to reduce concurrent state changes.
  5. Verify that every approved UID was copied successfully before marking any original message as deleted. A successful IMAP response alone should not substitute for destination verification.
  6. Re-fetch and display the exact UID set immediately before permanent deletion, then require explicit confirmation.
  7. Maintain a durable transaction log containing source mailbox, source UID, destination mailbox, destination UID or Message-ID, copy status, and deletion status.
  8. Treat random sampling as supplemental verification only; destructive processing should verify every targeted message.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • 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
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep