Back to skill

Security audit

Discord Message Guard

Security checks for vulnerabilities and agentic risk

Overview

The skill is not malicious, but its advertised Discord loop protection has verified gaps and dependency maintenance risks that should be reviewed before relying on it.

Review this before installing if you need dependable Discord bot-loop prevention. Keep ignoreBots enabled, avoid allowedBotIds or ignoreBots=false until the depth and whitelist ordering are fixed, pin and update dependencies, and limit retained Discord history to what the bot actually needs.

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
src/MessageMetadataExtractor.ts:91
Finding

Ineffective Reply-Depth Tracking and Whitelist Bypass Permit Unbounded Bot Response Loops

Content
View full analysis

Vulnerability Details

File Location: src/MessageMetadataExtractor.ts:91-107; src/ResponseRuleEngine.ts:108-114; src/ResponseRuleEngine.ts:134-160
Vulnerability Type: Improper enforcement of message-loop protection
Risk Level: High

Vulnerable Code

src/MessageMetadataExtractor.ts:91-107:

typescript
private calculateDepth(message: Message): number {
  let depth = 0;
  
  // 如果是回复消息,追踪回复链
  if (message.reference?.messageId) {
    depth = 1;
    
    // 简化实现:通过内容模式估算深度
    // 实际生产中应该 fetch 引用的消息并递归计算
    const coordinationPatterns = [
      /@\w+\s+(你来 | 你处理 | 你负责 | 请处理)/,
      /交给\s*@\w+/,
      /派发给\s*@\w+/,
      /转交\s*@\w+/,
    ];
    
    // 如果内容包含协调模式,增加深度
    if (coordinationPatterns.some(p => p.test(message.content))) {
      depth += 1;
    }
  }
  
  return depth;
}

src/ResponseRuleEngine.ts:108-114:

typescript
// 白名单机器人允许
if (isAllowedBot) {
  return {
    allowed: true,
    reason: 'Whitelisted bot',
    suggestion: 'respond',
  };
}

src/ResponseRuleEngine.ts:134-160:

typescript
// 规则 3: 深度限制
if (metadata.depth >= this.config.maxDepth) {
  return {
    allowed: false,
    reason: `Max depth exceeded (${metadata.depth} >= ${this.config.maxDepth})`,
    suggestion: 'ignore',
  };
}

// 规则 4: 会话状态检查
if (sessionState?.isProcessing) {
  if (this.config.queueWhenBusy) {
    return {
      allowed: false,
      reason: 'Session busy, should queue',
      suggestion: 'queue',
    };
  } else {
    return {
      allowed: false,
      reason: 'Session busy, dropping message',
      suggestion: 'ignore',
    };
  }
}

Technical Analysis

The reply depth is not calculated from the actual reply chain. Every message begins with a depth of zero and is assigned a depth of one whenever it references another message. It may reach two only when the new message text m ...[truncated 2478 chars]

Remediation
View remediation

Remediation Suggestions

  1. Track the real cumulative reply depth.

    • Fetch the referenced message and traverse its parent references.
    • Enforce a strict traversal limit and detect repeated message IDs to prevent cycles.
    • Alternatively, maintain trusted server-side depth metadata keyed by message ID and derive each reply's depth as the parent's depth plus one.
    • Do not infer security-sensitive depth solely from message text patterns.
  2. Apply universal safety checks before whitelist exceptions.

    • Enforce maxDepth and channel processing-state checks before returning an allowed result for any bot.
    • Treat the whitelist as permission to participate, not permission to bypass loop and concurrency controls.
  3. Require an explicit trigger for whitelisted bots.

    • Verify that the guarded bot was directly mentioned or that the message is a reply to a message created by the guarded bot.
    • Reject unrelated messages from whitelisted bots.
  4. Make mention semantics consistent.

    • Replace the contradictory bot and human mention flags with a single unambiguous mentionsGuardedBot property, or define separate flags whose names match their behavior.
    • Ensure the rule engine consumes only states that the production extractor can generate.
  5. Add integration tests using extractor-produced metadata.

    • Test reply chains longer than maxDepth.
    • Test whitelisted bots while a session is processing.
    • Test whitelisted and non-whitelisted bot mentions.
    • Assert that all bot paths stop at the configured maximum depth.
Vulnerability Patterns
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (20)

Known Vulnerable Dependency: vitest==1.6.1 — 1 advisory(ies): CVE-2026-47429 (When Vitest UI server is listening, arbitrary file can be read and executed)

Critical
Category
Supply Chain
Confidence
90% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: vitest==1.6.1 — 1 advisory(ies): CVE-2026-47429 (When Vitest UI server is listening, arbitrary file can be read and executed)

Critical
Category
Supply Chain
Confidence
90% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: lodash==4.17.23 — 2 advisory(ies): CVE-2025-13465 (lodash vulnerable to Prototype Pollution via array path bypass in `_.unset` and ); CVE-2021-23337 (lodash vulnerable to Code Injection via `_.template` imports key names)

High
Category
Supply Chain
Confidence
80% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: nanoid==3.3.11 — 3 advisory(ies): CVE-2026-67214 (nanoid: non-secure generators can loop indefinitely with negative size); CVE-2026-67213 (nanoid: custom generators can loop indefinitely when size is zero); CVE-2026-73086 (nanoid: Integer Overflow or Wraparound)

High
Category
Supply Chain
Confidence
80% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: postcss==8.5.8 — 4 advisory(ies): CVE-2026-45623 (PostCSS: Arbitrary file read and information disclosure via attacker-controlled ); CVE-2026-69153 (PostCSS: incomplete fix of GHSA-6g55-p6wh-862q — attacker-controlled sourceMappi); CVE-2026-41305 (PostCSS has XSS via Unescaped </style> in its CSS Stringify Output) +1 more

High
Category
Supply Chain
Confidence
80% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: undici==6.21.3 — 13 advisory(ies): CVE-2026-1525 (Undici has an HTTP Request/Response Smuggling issue); CVE-2026-6733 (undici vulnerable to HTTP response queue poisoning via keep-alive socket reuse); CVE-2026-1527 (Undici has CRLF Injection in undici via `upgrade` option) +10 more

High
Category
Supply Chain
Confidence
93% confidence
Finding

undici 6.21.3 is a runtime dependency of discord.js and is therefore present in the skill's operational dependency graph, not just dev tooling. Multiple advisories affecting HTTP parsing, smuggling, CRLF injection, and connection reuse can materially impact any component making outbound or proxied HTTP requests, increasing risk of request confusion, header injection, or denial of service if exploited through network interactions.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: vite==5.4.21 — 3 advisory(ies): CVE-2026-39365 (Vite Vulnerable to Path Traversal in Optimized Deps `.map` Handling); CVE-2026-53571 (vite: `server.fs.deny` bypass on Windows alternate paths); CVE-2026-53632 (launch-editor: NTLMv2 hash disclosure via UNC path handling on Windows)

High
Category
Supply Chain
Confidence
80% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: ws==8.19.0 — 2 advisory(ies): CVE-2026-45736 (ws: Uninitialized memory disclosure); CVE-2026-48779 (ws: Memory exhaustion DoS from tiny fragments and data chunks)

High
Category
Supply Chain
Confidence
86% confidence
Finding

ws 8.19.0 is a runtime dependency through discord.js/@discordjs/ws, so the vulnerable package is part of the operational stack used for websocket communication. Memory disclosure or memory-exhaustion issues in websocket handling can affect availability and potentially confidentiality when interacting with untrusted or malformed websocket frames, which is relevant for long-lived Discord client connections.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The README content is overwhelmingly written in Chinese, starting at L003 and continuing through the usage and configuration sections, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-only audience. Under the policy rule for natural-language constraints, this is a locale/language restriction presented without user opt-in or documented justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This file contains natural-language comments and user-facing annotation labels oriented to Chinese, such as the class description and coordination phrases, but provides no indication that the skill is intentionally region-specific or that users can opt into this language. Under the language/locale policy, forcing a specific language without opt-in is a policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The extractor's coordination-depth logic relies exclusively on Chinese phrases such as '你来', '你处理', and '请处理'. This encodes a language-specific behavior without any visible user choice or documented justification that the skill is intended only for Chinese-language Discord environments.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: esbuild==0.21.5 — 1 advisory(ies): GHSA-67mh-4wv8-2f99 (esbuild enables any website to send any requests to the development server and r)

Low
Category
Supply Chain
Confidence
60% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
93% confidence
Finding

The production dependency uses a caret range, which allows newer minor/patch releases to be installed over time. This weakens supply-chain reproducibility and can unintentionally pull in a compromised or breaking version if the upstream package is ever affected.

Content

Scanner excerpt · package.json (reported line 14)May include surrounding context.

json
"dev": "tsc --watch"
  },
  "dependencies": {
    "discord.js": "^14.14.1"
  },
  "devDependencies": {
    "typescript": "^5.3.3",

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
86% confidence
Finding

The TypeScript devDependency is not pinned to an exact version, so future installs may resolve to different releases. Although this is a development-only package, it still creates supply-chain and build reproducibility risk, especially in automated build environments.

Content

Scanner excerpt · package.json (reported line 17)May include surrounding context.

json
"discord.js": "^14.14.1"
  },
  "devDependencies": {
    "typescript": "^5.3.3",
    "vitest": "^1.2.0",
    "@types/node": "^20.10.0"
  }

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
90% confidence
Finding

The vitest devDependency is specified with a caret range, allowing automatic version drift. In this file that risk is more significant because Vitest is also flagged separately as having a known critical advisory in a resolved version range, so imprecise versioning can worsen exposure and make auditing harder.

Content

Scanner excerpt · package.json (reported line 18)May include surrounding context.

json
},
  "devDependencies": {
    "typescript": "^5.3.3",
    "vitest": "^1.2.0",
    "@types/node": "^20.10.0"
  }
}

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
84% confidence
Finding

The @types/node devDependency is not pinned, which can cause non-deterministic builds and unexpected dependency changes. This is primarily a supply-chain hygiene issue rather than a direct runtime exploit in the skill itself.

Content

Scanner excerpt · package.json (reported line 19)May include surrounding context.

json
"devDependencies": {
    "typescript": "^5.3.3",
    "vitest": "^1.2.0",
    "@types/node": "^20.10.0"
  }
}

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The file’s user-facing natural-language documentation comments are written exclusively in Chinese, with no indication that language choice is configurable or intentional for a region-specific audience. This can violate a language/locale policy when a skill implicitly enforces one language without opt-in or justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

This TypeScript test file contains natural-language labels and comments in Chinese while asserting English-facing reason strings such as '@everyone', 'ignoreBots', 'Max depth exceeded', and 'Not directly mentioned'. That mixed, hard-coded locale behavior suggests the skill may enforce specific languages for user-visible output without offering any user language selection or documenting a justified locale constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

This TypeScript file contains natural-language comments and at least one user-visible log string in Chinese, but there is no indication that the skill is intentionally limited to Chinese-speaking users or that language selection is configurable. Under the policy, forcing a specific language without user opt-in can be a locale-policy issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

The file-level documentation and inline comments are written entirely in Chinese, which imposes a specific language on readers without offering an alternative or documenting a justified locale restriction. Under the stated policy, language constraints should either provide user choice or be clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.