Back to skill

Security audit

Huimai Discord Automation

Security checks for vulnerabilities and agentic risk

Overview

This skill looks like a Discord moderation bot, but its code only simulates successful Discord actions, which could mislead an operator into thinking moderation work was actually done.

Review before installing. Do not rely on this skill for real Discord moderation unless it is clearly converted from simulation to actual Discord API integration, returns success only after API confirmation, validates bot permissions, and makes destructive actions confirmable and auditable.

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 (2)

T09 · Insecure Skill Coding Practices

Warning
Location
index.js:43
Finding

Security-Sensitive Discord Operations Falsely Report Successful Completion

Content
View full analysis

Vulnerability Details

File Location: index.js:43-59, index.js:81-104, index.js:125-166, and index.js:194-224
Vulnerability Type: False authentication and moderation success reporting
Risk Level: Medium

Vulnerable Code

js
async simulateConnection() {
  return new Promise(resolve => {
    setTimeout(() => {
      console.log('✅ 已连接到Discord API');
      console.log('✅ 机器人身份验证成功');
      console.log('✅ 服务器连接建立');
      resolve();
    }, 1000);
  });
}
js
async deleteMessages(channelId, limit = 1) {
  console.log(`🗑️ 删除频道 ${channelId} 的 ${limit} 条消息`);
  
  return {
    success: true,
    channelId,
    deletedCount: limit,
    timestamp: new Date().toISOString()
  };
}

/**
 * 分配角色
 */
async assignRole(userId, roleName) {
  console.log(`👤 为用户 ${userId} 分配角色: ${roleName}`);
  
  return {
    success: true,
    userId,
    roleName,
    assignedAt: new Date().toISOString()
  };
}

/**
 * 踢出用户
 */
async kickUser(userId, reason = '') {
  console.log(`🚪 踢出用户 ${userId}, 原因: ${reason || '未指定'}`);
  
  return {
    success: true,
    userId,
    reason,
    kickedAt: new Date().toISOString()
  };
}

Technical Analysis

The implementation does not import a Discord SDK, establish a network connection, or send requests to the Discord API. Nevertheless, simulateConnection() logs that authentication and server connection succeeded. The message deletion, role assignment, and user removal methods similarly return success: true without performing the corresponding Discord operation.

Message sending and replies follow the same simulated-success pattern, while server and user statistics are hard-coded. This creates a fail-open operational condition: callers cannot distinguish an actual moderation action from a local simulation.

The behavior materially conflicts with the documented Discord automation and moderation ...[truncated 1391 chars]

Remediation
View remediation

Remediation Suggestions

  1. Integrate an official, maintained Discord client library or implement authenticated Discord REST API requests.
  2. Validate the bot token during startup and verify that it belongs to the expected bot identity.
  3. Check the bot's effective guild and channel permissions before attempting moderation actions.
  4. Return success only after Discord confirms the operation with an expected HTTP status and response.
  5. Propagate authentication, authorization, rate-limit, network, and validation failures to callers rather than converting them into successful results.
  6. Include Discord response identifiers and audit metadata in successful results so callers can verify that an action occurred.
  7. Move simulated behavior into a dedicated mock or test-only implementation. Require an explicit mock-mode option and clearly label every mock result.
  8. Add integration tests against a controlled Discord test server and assert actual server-side state changes.
  9. Replace hard-coded statistics with API-derived values or explicitly mark them as test fixtures.

T09 · Insecure Skill Coding Practices

Note
Location
index.js:65
Finding

Message Processing Interval Cannot Be Stopped and Accumulates Across Repeated Starts

Content
View full analysis

Vulnerability Details

File Location: index.js:65-72 and index.js:298-303
Vulnerability Type: Timer lifecycle and resource-management flaw
Risk Level: Low

Vulnerable Code

js
startMessageProcessing() {
  setInterval(() => {
    if (this.messageQueue.length > 0) {
      const message = this.messageQueue.shift();
      this.processMessage(message);
    }
  }, 100);
}
js
stop() {
  this.isConnected = false;
  console.log('Discord机器人已停止');
  return true;
}

Technical Analysis

startMessageProcessing() creates a repeating timer but does not retain the interval handle. Consequently, stop() cannot call clearInterval() and only changes the isConnected flag.

The interval callback does not inspect isConnected, so queued messages can continue to be processed after the bot reports that it has stopped. In addition, start() contains no duplicate-start guard. Every invocation therefore creates another permanent 100-millisecond timer.

In Node.js, active intervals also keep the event loop alive. This can prevent clean process termination and cause tests, command-line jobs, or host shutdown procedures to hang.

Attack Path

  1. Code with access to the exported DiscordAutomation instance repeatedly invokes start().
  2. Each successful invocation calls startMessageProcessing() and creates a new interval.
  3. No interval handle is stored, and no duplicate-start check prevents additional intervals.
  4. The caller invokes stop(), but the method only sets isConnected to false.
  5. All created intervals remain active, continue waking every 100 milliseconds, and can continue processing queued messages.
  6. Repeated starts increase timer and callback overhead and can keep the Node.js process alive indefinitely.

Impact Assessment

The flaw does not provide additional privileges or access to protected data. Its scope is process availability and lifecycle ...[truncated 302 chars]

Remediation
View remediation

Remediation Suggestions

  1. Store the timer handle on the instance, for example as this.messageProcessingInterval.
  2. Reject or safely ignore start() when the instance is already running.
  3. In stop(), call clearInterval(this.messageProcessingInterval) and reset the stored handle.
  4. Check isConnected inside the interval callback before processing queued messages.
  5. Define whether queued messages should be discarded, preserved, or drained during shutdown.
  6. Make stop() idempotent so repeated shutdown calls remain safe.
  7. Add tests confirming that no messages are processed after shutdown, repeated starts create only one timer, and the Node.js process can terminate after stop().
Vulnerability Patterns
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (12)

Tp2

High
Category
MCP Tool Poisoning
Confidence
85% confidence
Finding

Mixing characters from multiple Unicode scripts in a single identifier is a common technique to create visually ambiguous tool names.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding

The documented purpose emphasizes routine Discord administration, but the analysis indicates additional capabilities such as channel creation, server statistics collection, user activity analysis, and bot/event-system control that are not clearly disclosed. Undocumented administrative or monitoring behaviors are dangerous because operators may grant broad bot permissions without understanding the full action surface, increasing the chance of unauthorized changes, privacy overreach, or abuse if the skill is misused or compromised.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This skill is designed for channel cleanup, moderation, and bulk management in Discord, which can delete content or alter community structure if configured incorrectly. Without a clear upfront warning about destructive actions, users may enable it with elevated permissions and trigger irreversible changes such as message loss, unwanted archiving, or channel deletion.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill name and description are presented only in Chinese, with no indication that users can choose another language or locale. This can violate language/locale policy requirements when a skill implicitly forces one language for all users.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The file's natural-language descriptions and user-facing strings are entirely in Chinese, including the skill title, status messages, and command help text. There is no indication that the skill is region-specific or that users can opt into a language preference, which creates a locale-policy concern under the rule for language/locale restrictions.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The docstring '启动Discord机器人' and subsequent status messages such as '已连接到Discord API' and '机器人身份验证成功' imply a real bot startup and authenticated API connection. In reality, start() only calls simulateConnection(), which waits on a timeout and prints success messages without any network/API interaction.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The manifest describes a Discord automation skill for auto-replies, permission management, channel cleanup, and log recording, implying actual server operations. However, start() only performs a simulated connection and the file contains only console output rather than real Discord API actions or any log storage/recording mechanism.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This manifest contains user-facing natural-language metadata primarily in Chinese, including the main description and multiple feature labels, without indicating that language selection is optional. The policy requires avoiding forced language or locale constraints unless the skill offers a choice or clearly documents a justified regional limitation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This JavaScript file contains user-facing strings entirely in Chinese, including the title, test progress messages, and success/failure output. Under the policy, forcing a specific language without user opt-in is a natural-language locale violation unless the constraint is explicitly documented and justified, which is not present here.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest describes automated replies, permission management, channel cleanup, and logging for routine Discord operations. This test file invokes broader administrative actions such as assigning an 'admin' role and creating a new channel, which are not clearly covered by that narrower description of day-to-day automation tasks.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest focuses on auto-replies, permission management, channel cleanup, and log recording. An explicit analyzeUserActivity capability introduces analytics/monitoring behavior that is materially different from the stated operational maintenance functions and is not mentioned in the description.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The description advertises 权限管理 as a core capability, which usually includes managing permissions/overwrites or access controls. In this file, the only related behavior is assignRole(), which does not manage channel/server permissions and only returns a simulated success object.

Content

No source excerpt is available for this finding.