Back to skill

Security audit

work-mail-notifier

Security checks for vulnerabilities and agentic risk

Overview

This skill appears purpose-built for QQ work email monitoring, but it stores sensitive email metadata locally without explicit private permissions and can read or mark mailbox items when invoked.

Review this before installing if the machine is shared or if QQ work-email metadata is sensitive. The skill needs access to the configured himalaya QQ account, can display message bodies, can mark messages as read, and leaves recent sender/subject/folder metadata on disk; install only if that local persistence and mailbox authority are acceptable.

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

Warning
Location
scripts/work_mail_notifier.py:140
Finding

Email Metadata Is Stored Without Restrictive File Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/work_mail_notifier.py, lines 140–169
Vulnerability Type: Plaintext sensitive-data storage with process-default file permissions
Risk Level: Medium

Vulnerable Code

python
def save_state(state):
    os.makedirs(os.path.dirname(STATE_PATH), exist_ok=True)
    with open(STATE_PATH, "w", encoding="utf-8") as f:
        json.dump(state, f, ensure_ascii=False, indent=2)


def save_anchor_ids(anchor_time: datetime, items):
    """保存上次通知中时间等于 anchor_time 的所有邮件 ID。"""
    anchor_ids = {item["id"] for item in items if item["date"] == anchor_time}
    os.makedirs(os.path.dirname(ANCHOR_IDS_PATH), exist_ok=True)
    with open(ANCHOR_IDS_PATH, "w", encoding="utf-8") as f:
        json.dump(list(anchor_ids), f, ensure_ascii=False)


def save_notification_refs(items):
    os.makedirs(os.path.dirname(LAST_NOTIFICATION_FILE), exist_ok=True)
    groups = {"告警/风险": [], "失败/异常": [], "普通": []}
    for item in items:
        groups[classify_item(item)].append(item)

    ordered = []
    for group_name in ["告警/风险", "失败/异常", "普通"]:
        for item in groups[group_name]:
            ordered.append({
                "ref": f"{item['folder']}#{item['id']}",
                "folder": item["folder"],
                "id": item["id"],
                "from": item["from"],
                "subject": item["subject"],
                "date": item["date"].isoformat(),
                "group": group_name,
            })
    with open(LAST_NOTIFICATION_FILE, "w", encoding="utf-8") as f:
        json.dump(ordered, f, ensure_ascii=False, indent=2)

Technical Analysis

The notification reference file stores email senders, subjects, folder names, timestamps, and message identifiers in plaintext. The state and anchor files also retain mailbox-processing metadata. These files are opened without an explicit private creation mode, and the parent directory is created without explicitly enforcing owner-only permissions.

Consequ ...[truncated 2112 chars]

Remediation
View remediation

Remediation Suggestions

  • Ensure the data directory is owner-only before storing mailbox state:
python
data_dir = os.path.dirname(LAST_NOTIFICATION_FILE)
os.makedirs(data_dir, mode=0o700, exist_ok=True)
os.chmod(data_dir, 0o700)
  • Create each sensitive file with mode 0600, rather than relying on the ambient umask.
  • Use atomic writes through a temporary file created in the same protected directory, apply mode 0600, flush and synchronize it, and then replace the destination with os.replace().
  • Correct permissions on existing files with os.chmod(path, 0o600) after validating that the destination is a regular file owned by the expected user.
  • Retain only metadata required by mark_read.py and show_body.py; avoid persisting sender names and subject lines if they are not essential.
  • Validate ownership and reject symlinks or unexpected file types before reading or replacing persistent state files.
  • Apply the same protection consistently to work_mail_notifier_state.json, work_mail_anchor_ids.json, and last_notification.json.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

This second mismatch finding highlights that the skill operates as a stateful polling workflow with local persistence, which is materially different from a simple user-triggered read-marking helper. Hidden state and background-like polling semantics can surprise users, complicate auditing, and create privacy risks if local reference data is retained without disclosure. The context makes this more concerning because mailbox monitoring and stored references can expose patterns of communication even without full message content.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

This second mismatch finding highlights that the skill operates as a stateful polling workflow with local persistence, which is materially different from a simple user-triggered read-marking helper. Hidden state and background-like polling semantics can surprise users, complicate auditing, and create privacy risks if local reference data is retained without disclosure. The context makes this more concerning because mailbox monitoring and stored references can expose patterns of communication even without full message content.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill declares shell, file read, and file write capable behavior but does not scope or constrain those capabilities in metadata. That increases the chance the agent can invoke powerful operations unexpectedly, especially when handling mailbox content and local state files. In a mail-processing skill, undeclared capability breadth raises the risk of unauthorized file access, state tampering, or unsafe command execution.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The trigger wording is broad enough to match generic email-related requests, which can cause the skill to activate outside its intended QQ mailbox workflow. Over-broad activation is dangerous for a capability that can read mailbox contents and modify read state, because it may expose or act on the wrong account data based on an ambiguous user request. The mail context increases risk since users may assume a general assistant response rather than mailbox access.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The description omits that the skill monitors mailbox folders and stores notification state locally, which is a meaningful privacy and security disclosure gap. Users may not realize their mailbox metadata and workflow state are being persisted on disk, reducing informed consent and making incident response harder if that data is accessed by other local processes. In an email-monitoring skill, undisclosed storage of message references materially increases sensitivity.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/mark_read.py (reported line 12)May include surrounding context.

python
def run_cmd(args):
    return subprocess.run(args, capture_output=True, text=True)


def load_refs():

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/show_body.py (reported line 11)May include surrounding context.

python
def run_cmd(args):
    return subprocess.run(args, capture_output=True, text=True)


def load_refs():

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The file contains hard-coded Chinese user-facing messages, indicating the skill is designed to communicate in a specific language without any visible opt-in or fallback. This can violate language/locale policy when users are not explicitly given a choice or when no region-specific justification is documented.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The command usage output is presented only in Chinese, which imposes a language choice on all users of the script. There is no indication that the tool is region-specific or that users can select an alternate language.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/work_mail_notifier.py (reported line 44)May include surrounding context.

python
def run_cmd(args):
    p = subprocess.run(args, capture_output=True, text=True)
    return p.returncode, p.stdout, p.stderr

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
75% confidence
Finding

The manifest description and all invocation examples are presented only in Chinese, and the natural-language command patterns appear to assume Chinese user input. There is no indication that users may choose another language or that the locale restriction is intentional and documented as a region-specific requirement.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The script fixes its timezone to "Asia/Shanghai", which is a locale-specific behavior affecting how mail timestamps are interpreted and reported. There is no visible opt-in, configurability, or documentation in this file explaining why only this locale is appropriate.

Content

No source excerpt is available for this finding.