Back to skill

Security audit

QQemail-agent

Security checks for vulnerabilities and agentic risk

Overview

This QQ Mail helper is mostly coherent, but it needs Review because it stores reusable mailbox credentials in plaintext and reads broad recent mailbox content without tight scope or strong user safeguards.

Install only if you are comfortable giving this skill read access to recent QQ Mail messages and send access from the account. Prefer using a dedicated mailbox or folder, avoid pasting authorization codes into chat, store secrets outside the project or with strict permissions, add `.env` to ignore lists, and revoke or rotate the QQ authorization code after testing or any suspected exposure.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
Findings (3)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/fetch_orders.py:35
Finding
Mailbox Collection Exceeds the Stated Order-Processing Scope## Vulnerability Details **File Location**: `scripts/fetch_orders.py`, lines 35-47 **Vulnerability Type**: Excessive mailbox access and collection **Risk Level**: High ### Vulnerable Code ```python emails = [] for msg in mailbox.fetch(AND(date_gte=date_since.date()), limit=50, reverse=True): emails.append({ 'subject': msg.subject, 'from': msg.from_, 'date': msg.date, 'text': msg.text or msg.html }) print(f"共获取 {len(emails)} 封邮件\n") for i, email in enumerate(emails, 1): print(f"{i}. [{email['date']}] {email['subject']}") print(f" From: {email['from']}") ``` ### Technical Analysis The Skill is described as retrieving order emails, but the IMAP query only restricts messages by date. It does not filter by mailbox folder, sender, recipient, subject, message labels, or other order-specific characteristics. It consequently retrieves the subject, sender, date, and complete plain-text or HTML body of up to 50 recent messages. This violates least-privilege and data-minimization principles. Authentication is performed with a mailbox-wide authorization code, and the implementation uses that access to collect unrelated messages rather than limiting collection to content necessary for order processing. ### Attack Path 1. A user supplies a valid QQ Mail authorization code and runs the documented `fetch_orders.py` command. 2. The script logs in to the mailbox with the user's IMAP privileges. 3. It queries every message within the configured date range, up to the limit of 50 messages. 4. It extracts the complete text or HTML body from each message without determining whether the message concerns an order. 5. The resulting collection becomes available to the calling process or AI workflow for subsequent processing. 6. Unrelated confidential messages may therefore be disclosed beyond the intended order-processing scope. ### Impact Assessment The script can acces ...[truncated 466 chars]
Remediation
## Remediation Suggestions - Require an explicit order-specific sender, subject, folder, or label filter before querying the mailbox. - Retrieve message headers first and fetch a body only after confirming that the message is relevant. - Show the proposed query and scope to the user and obtain confirmation before reading message bodies. - Use a dedicated mailbox or folder for order processing where possible. - Minimize the default date range and message count. - Redact authentication codes, financial data, and other sensitive patterns before passing content to an AI workflow. - Clearly disclose the exact mailbox data that will be read and retained.

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:39
Finding
Reusable Mailbox Authorization Code Is Collected and Stored in Plaintext## Vulnerability Details **File Location**: `SKILL.md`, lines 39-59 **Vulnerability Type**: Plaintext sensitive credential handling **Risk Level**: High ### Vulnerable Code ```python import os env_content = """# IMAP配置(接收邮件) IMAP_HOST=imap.qq.com IMAP_PORT=993 IMAP_USER={邮箱} IMAP_PASS={授权码} # SMTP配置(发送邮件) SMTP_HOST=smtp.qq.com SMTP_PORT=465 SMTP_USER={邮箱} SMTP_PASS={授权码} """ # 写入 .env 文件 with open('.env', 'w', encoding='utf-8') as f: f.write(env_content) print("✅ 配置完成!") ``` ### Technical Analysis The setup procedure directs the user to provide a reusable mailbox authorization code to the Agent and then writes that code into a plaintext `.env` file. The same credential is used for both IMAP and SMTP access. The file is created using the process's default permissions. The instructions do not enforce owner-only access, use an operating-system credential store, ensure exclusion from source control, or provide a secure secret-entry mechanism. Supplying the credential through an Agent conversation can also expose it through conversation history, telemetry, execution logs, or retained context. Because this authorization code enables both mailbox reading and email sending, disclosure has consequences comparable to compromise of a reusable application password. ### Attack Path 1. The setup workflow asks the user to provide their email address and QQ Mail authorization code in the conversation. 2. The Agent interpolates the authorization code into `env_content`. 3. The Agent writes the code to `.env` as plaintext under default filesystem permissions. 4. The secret may subsequently be captured in conversation records, workspace backups, logs, shared directories, or an accidental source-control commit. 5. A local user, collaborator, compromised process, or repository recipient obtains the authorization code. 6. The exposed code is used to authenticate to QQ Mail through IMAP or SMTP until it ...[truncated 485 chars]
Remediation
## Remediation Suggestions - Do not ask users to disclose authorization codes in Agent conversations. - Collect secrets through hidden interactive input or a trusted secret-management interface. - Store the authorization code in an operating-system keychain or dedicated secret manager rather than a plaintext project file. - If a local file is unavoidable, create it with owner-only permissions such as mode `0600` and verify those permissions before use. - Add `.env` to `.gitignore` and provide a non-secret `.env.example` template. - Avoid recording credentials in logs, command history, telemetry, exception messages, or conversation memory. - Use separate, least-privilege credentials for receiving and sending where the provider supports that separation. - Document credential revocation and rotation procedures and advise immediate rotation after suspected exposure.

T08 · Insecure Dependencies

Warning
Location
requirements.txt:1
Finding
Third-Party Dependencies Use Open-Ended Version Constraints Without Integrity Verification## Vulnerability Details **File Location**: `requirements.txt`, lines 1-2 **Vulnerability Type**: Unpinned dependency and supply-chain exposure **Risk Level**: Medium ### Vulnerable Code ```text imap-tools>=0.5.0 python-dotenv>=1.0.0 ``` ### Technical Analysis Both dependencies use open-ended minimum-version constraints. A future installation can therefore resolve to any newer package version available from the configured package index. No lock file, exact version, package hash, or trusted-index requirement is provided. This makes installations non-reproducible and permits unreviewed future releases to enter the environment automatically. Dependency code executes with the privileges of the Python process and can access imported environment variables, mailbox credentials, and retrieved email content. The audit found no evidence that the currently named packages are malicious; the issue is the absence of version and integrity controls. ### Attack Path 1. A user follows the installation instructions or installs from `requirements.txt`. 2. The package installer resolves the newest versions satisfying the open-ended constraints. 3. A compromised, malicious, or unexpectedly incompatible future release is selected without a source change in this project. 4. Package installation hooks or imported package code execute with the user's local privileges. 5. Malicious dependency code could read `.env`, capture mailbox credentials or message data, modify local files, or perform network communication. This path requires compromise of the package distribution channel, a dependency release, or the package-resolution environment; no such compromise was observed in the audited files. ### Impact Assessment Successful supply-chain compromise would execute code with the privileges of the user running the Skill. That code could access the project workspace, plaintext mailbox credentials, fetched email data, and other resources availabl ...[truncated 216 chars]
Remediation
## Remediation Suggestions - Pin each dependency to an exact, reviewed version. - Generate and commit a lock file containing resolved transitive dependency versions. - Require cryptographic hashes during installation, for example through a hash-locked requirements file. - Configure installation to use the intended official package index and disable untrusted extra indexes. - Review dependency changes before updating the lock file. - Run dependency vulnerability and provenance checks in continuous integration. - Install the Skill in an isolated virtual environment with only the filesystem and network permissions it requires.
Vulnerability Patterns
  • 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
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (15)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The description claims two core capabilities: receiving/reading QQ email and sending email to other accounts. The code chunk supports only the reading side via IMAP login and mailbox.fetch for recent messages. There is no SMTP usage, no send-mail function, and no outbound account interaction. This is a material description-to-behavior mismatch because a primary declared capability is absent from the implementation shown.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
There is a material description-to-code mismatch. The description says the skill both reads QQ mailbox messages and sends emails. The code chunk only implements outbound email sending through SMTP. It does not connect to IMAP/POP3, list messages, fetch inbox content, or otherwise read email. The optional local file read is a minor extra implementation detail, but the key issue is that half of the declared core purpose—reading QQ email—is absent from the actual behavior.

Credential Access

High
Category
Privilege Escalation
Content
SMTP_PASS={授权码}
"""

# 写入 .env 文件
with open('.env', 'w', encoding='utf-8') as f:
    f.write(env_content)
Confidence
97% confidence
Finding
The skill directly collects and persists email authorization credentials in a plaintext .env file, which is a credential-handling pattern with clear abuse potential. If that file is exposed, an attacker could access the mailbox over IMAP/SMTP, read sensitive mail, and send messages as the user.

Credential Access

High
Category
Privilege Escalation
Content
"""

# 写入 .env 文件
with open('.env', 'w', encoding='utf-8') as f:
    f.write(env_content)

print("✅ 配置完成!")
Confidence
97% confidence
Finding
The explicit file write to .env operationalizes credential storage in a predictable local path, making secret discovery easier for malware, other users on the host, or accidental publication. Because the stored values are SMTP/IMAP credentials, compromise can immediately enable account misuse and data exfiltration.

Credential Access

High
Category
Privilege Escalation
Content
def check_config():
    """检查配置"""
    if not SMTP_USER or not SMTP_PASS:
        print("错误: 请在 .env 文件中填入 SMTP_USER 和 SMTP_PASS")
        print("\n配置示例:")
        print("SMTP_USER=your_email@qq.com")
        print("SMTP_PASS=your_auth_code")
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
def check_config():
    """检查配置"""
    if not SMTP_USER or not SMTP_PASS:
        print("错误: 请在 .env 文件中填入 SMTP_USER 和 SMTP_PASS")
        print("\n配置示例:")
        print("SMTP_USER=your_email@qq.com")
        print("SMTP_PASS=your_auth_code")
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill documents capabilities that involve network access, reading local configuration, and writing secrets to disk, but it declares no explicit tool scope or permission boundaries. In an agent environment, missing scope declarations weakens least-privilege controls and can let a seemingly simple email skill operate with broader access than users expect.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill instructs users to provide a QQ email authorization code and then has the agent write it into a local .env file without a strong warning about plaintext secret storage, file permissions, or downstream exposure. This increases the risk of credential leakage through source control, backups, logs, shared workspaces, or other local users/processes.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
The script's user-facing text is written in Chinese only, including the top-level description and runtime messages. This imposes a specific language on users without any opt-in or alternative, which matches the language/locale policy violation criteria.

Missing User Warnings

Medium
Confidence
86% confidence
Finding
The script connects to a remote mailbox and retrieves subjects, senders, dates, and message bodies, but it does not provide a meaningful user-facing consent or privacy warning before accessing potentially sensitive email content. In this skill context, the data being fetched may include orders, personal information, and other confidential business communications, so silent bulk retrieval increases privacy and data-handling risk.

Unpinned Dependencies

Low
Category
Supply Chain
Content
imap-tools>=0.5.0
python-dotenv>=1.0.0
Confidence
95% confidence
Finding
The dependency is specified with only a lower bound, so installs may resolve to different versions over time, including versions with newly introduced vulnerabilities or breaking changes. In a mail-handling skill, this weakens supply-chain integrity and makes security posture non-reproducible, even if no specific exploit is evident from this line alone.

Unpinned Dependencies

Low
Category
Supply Chain
Content
imap-tools>=0.5.0
python-dotenv>=1.0.0
Confidence
98% confidence
Finding
python-dotenv is also unpinned, which means the environment may install an arbitrary newer compatible release at deployment time. Because this package is often involved in loading local configuration and secrets, non-deterministic version resolution increases the risk of pulling in a vulnerable or incompatible release.

Unverifiable Dependency: python-dotenv has 2 known advisory(ies) (CVE-2026-28684 (python-dotenv: Symlink following in set_key allows arbitrary file overwrite via ); CVE-2026-28684 (python-dotenv reads key-value pairs from a .env file and can set them as environ)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
91% confidence
Finding
The manifest references python-dotenv without pinning, and the package has known advisories affecting some versions. Because the resolved version is unknown, the deployment could pull an affected release; in a skill likely handling email credentials and other secrets, a vulnerable dotenv package could increase risk around local file handling or environment configuration abuse.

Missing User Warnings

Low
Confidence
75% confidence
Finding
The script accesses IMAP credentials from environment variables, including the mailbox password/auth code. While configuration guidance is shown when values are missing, there is no explicit disclosure that the script will use stored credentials to authenticate to the mail server and access the account.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
This code presents its title, errors, prompts, and success messages in Chinese, indicating a fixed language choice for all users. The policy allows locale constraints only when users are given a choice or the restriction is clearly documented and justified, which is not present here.

Static analysis

No suspicious patterns detected.