Back to skill

Security audit

Discord Connect UI

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real Discord integration, but it can automatically change and restart Clawdbot while handling bot tokens in ways that are not fully safe or accurately described.

Review before installing. Run only in a test Clawdbot checkout first, use dry-run and skip-restart options where possible, back up the gateway/UI source tree, avoid passing live Discord tokens on the command line, prefer a real secret manager, grant the bot minimal Discord permissions, and be prepared for manual cleanup if uninstalling.

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

T09 · Insecure Skill Coding Practices

Error
Location
assets/discord-backend.ts:400
Finding
Discord Bot Token Is Stored in an Inconsistent Plaintext Configuration Field<![CDATA[ ## Vulnerability Details **File Location**: `assets/discord-backend.ts`, lines 98–100 and 400–412 **Vulnerability Type**: Plaintext credential storage and inconsistent configuration key **Risk Level**: High ### Complete Code Snippet ```ts /** * Get the current Discord bot token from config. */ function getToken(ctx: ServerMethodContext): string | undefined { const config = ctx.serverState.config; return config.channels?.discord?.botToken; } ``` ```ts // Merge in the new token const updatedConfig = { ...snapshot.config, channels: { ...snapshot.config.channels, discord: { ...snapshot.config.channels?.discord, token: params.token, }, }, }; // Write the updated config await writeConfigFile(updatedConfig); ``` ### Technical Analysis The token retrieval and token storage paths use different configuration keys. `getToken()` reads `channels.discord.botToken`, while `discordSetToken()` writes the supplied secret to `channels.discord.token`. This inconsistency can prevent the newly submitted token from being activated while still retaining the raw credential in the configuration file. It may also result in duplicate or abandoned secret fields that are not covered by normal credential-management procedures. The implementation directly passes the submitted token to the ordinary configuration writer. It does not convert the token into an OpenBao reference or invoke a secret-storage API, despite the documentation presenting OpenBao-backed credential storage as a security feature. The backend also does not resolve an OpenBao reference before using the value as a Discord authorization credential. The vulnerability is not an indication that the token is sent to an unauthorized domain. Token validation requests are limited to the official Discord HTTPS API. The issue concerns local storage, lifecycle management, and the discrepancy between the claimed and implemented secret-handling behavior. ### Attack Path 1. An authoriz ...[truncated 1150 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Store and retrieve the credential using one canonical key, preferably `channels.discord.botToken`. 2. Add a migration that securely removes any legacy `channels.discord.token` value after moving it to the canonical storage location. 3. Integrate with the host secret-management API rather than writing raw bot tokens through the ordinary configuration writer. 4. When OpenBao references are supported, resolve them through the trusted secret provider immediately before API use and never persist the resolved value. 5. Ensure configuration and backup files containing credentials are created with owner-only permissions. 6. Redact both `token` and `botToken` fields from logs, support bundles, configuration exports, and error reports. 7. Add automated tests confirming that token submission, storage, retrieval, restart, and secret-reference resolution all use the same configuration contract. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/test-token.py:67
Finding
Discord Bot Tokens Are Accepted and Documented Through Process Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/test-token.py`, lines 67–71; `scripts/health-check.py`, lines 257–262; `SKILL.md`, lines 193–194; `references/bot-setup.md`, line 194; `references/troubleshooting.md`, lines 7–12 **Vulnerability Type**: Credential exposure through command-line arguments **Risk Level**: Medium ### Complete Code Snippet From `scripts/test-token.py`: ```python def main(): # Get token from args or environment if len(sys.argv) > 1: token = sys.argv[1] else: token = os.environ.get("DISCORD_BOT_TOKEN", "") ``` From `scripts/health-check.py`: ```python parser = argparse.ArgumentParser(description="Discord bot health check") parser.add_argument("--token", help="Discord bot token") parser.add_argument("--verbose", "-v", action="store_true", help="Verbose output") parser.add_argument("--json", action="store_true", help="JSON output") args = parser.parse_args() token = args.token or os.environ.get("DISCORD_BOT_TOKEN", "") ``` Documented usage in `SKILL.md`: ```bash # Test token independently python scripts/test-token.py YOUR_TOKEN ``` Documented usage in `references/troubleshooting.md`: ```bash # Run health check ./scripts/health-check.py --token YOUR_TOKEN # Test token only ./scripts/test-token.py YOUR_TOKEN ``` ### Technical Analysis The scripts accept the complete bot credential through the process argument vector, and the project documentation actively recommends this usage. Command-line arguments may be exposed through shell history, process inspection interfaces, terminal session recording, CI/CD logs, command auditing, crash reports, and monitoring telemetry. Masking the token when the script later prints status does not protect the original command line. Reading the credential from `DISCORD_BOT_TOKEN` avoids the process argument vector but can still expose it to child processes, diagnostic dumps, or environment-capturing tools. A hidden interactive prompt, protected standard in ...[truncated 1233 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove support for passing bot tokens directly as positional or named command-line arguments. 2. Read the token through `getpass.getpass()` for interactive execution so it is not echoed or stored in shell history. 3. Support protected standard input for automation, with explicit warnings not to pipe from commands that expose the token. 4. Prefer a secret-manager or OpenBao reference for production environments. 5. If environment-variable support remains, document its exposure characteristics and clear the variable before launching unrelated child processes. 6. Replace all token-bearing command examples with safe interactive or secret-reference workflows. 7. Warn users to rotate any credential previously entered through a logged command line if exposure is suspected. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/install-plugin.js:179
Finding
Automatic Installer Performs Non-Transactional Host Source Modification Without Reliable Rollback<![CDATA[ ## Vulnerability Details **File Location**: `package.json`, lines 119–121; `scripts/install-plugin.js`, lines 179–205, 214–308, and 314–335 **Vulnerability Type**: Unsafe installation lifecycle and non-transactional source patching **Risk Level**: Medium ### Complete Code Snippet From `package.json`: ```json "scripts": { "install": "node scripts/install-plugin.js", "uninstall": "node scripts/install-plugin.js --uninstall", "health": "python3 scripts/health-check.py", "test-token": "python3 scripts/test-token.py" } ``` Representative source-patching logic from `scripts/install-plugin.js`: ```js // 1. Install backend handlers log("📦 Installing backend handlers..."); const backendSrc = path.join(ASSETS_PATH, "discord-backend.ts"); const backendDest = path.join(gatewayPath, "src/gateway/server-methods/discord-connect.ts"); copyFile(backendSrc, backendDest); // 2. Register handlers in server-methods.ts log("📝 Registering RPC handlers..."); const serverMethodsPath = path.join(gatewayPath, "src/gateway/server-methods.ts"); let serverMethods = fs.readFileSync(serverMethodsPath, "utf-8"); if (!serverMethods.includes("discord-connect")) { // Add import at the top with other imports const importLine = 'import { registerDiscordConnectHandlers } from "./server-methods/discord-connect.js";'; if (!serverMethods.includes(importLine)) { serverMethods = serverMethods.replace( /(import[^;]+from\s+["'][^"']*server-methods[^"']*["'];?\n)/, `$1${importLine}\n` ); } // Add registration in the function if (!serverMethods.includes("registerDiscordConnectHandlers")) { serverMethods = serverMethods.replace( /(export\s+(?:async\s+)?function\s+registerServerMethods[^{]+{)/, "$1\n registerDiscordConnectHandlers(registerMethod);" ); } writeFile(serverMethodsPath, serverMethods); } ``` Build and restart behavior: ```js // 6. Build if (!options.skipBuild && !options.dryRun) { log(""); log("🔨 Buildin ...[truncated 3261 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove host modification from the generic package `install` lifecycle and require an explicit, clearly documented administrative installation command. 2. Prefer the host's structured plugin-registration mechanism instead of directly patching application source. 3. If patching remains necessary, parse and modify TypeScript through an AST rather than regular expressions. 4. Create verified backups before every write, including when the CLI installer is used. 5. Write modifications to temporary files, validate syntax and expected registrations, and replace destination files atomically only after all checks pass. 6. Treat build failure as an installation failure and automatically restore every modified or copied file. 7. Do not restart the gateway unless compilation and post-install validation succeed. 8. Record a complete installation manifest so uninstall can remove copied files and restore every patched source file. 9. Verify target paths against canonical allowed roots before modification. 10. Present users with the exact files, commands, and restart operations that will occur, and require explicit confirmation unless non-interactive consent was deliberately provided. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (19)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
Claiming full Discord integration while apparently only validating tokens and listing guilds is a meaningful security concern because it can induce users to disclose credentials and approve invasive installation assumptions under false pretenses. The mismatch is more dangerous here because the skill discusses automatic backend/UI changes and bot-token handling, both of which are high-trust operations.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding
Claiming full Discord integration while apparently only validating tokens and listing guilds is a meaningful security concern because it can induce users to disclose credentials and approve invasive installation assumptions under false pretenses. The mismatch is more dangerous here because the skill discusses automatic backend/UI changes and bot-token handling, both of which are high-trust operations.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
Claiming full Discord integration while apparently only validating tokens and listing guilds is a meaningful security concern because it can induce users to disclose credentials and approve invasive installation assumptions under false pretenses. The mismatch is more dangerous here because the skill discusses automatic backend/UI changes and bot-token handling, both of which are high-trust operations.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
Claiming full Discord integration while apparently only validating tokens and listing guilds is a meaningful security concern because it can induce users to disclose credentials and approve invasive installation assumptions under false pretenses. The mismatch is more dangerous here because the skill discusses automatic backend/UI changes and bot-token handling, both of which are high-trust operations.

Description-Behavior Mismatch

High
Confidence
99% confidence
Finding
The code reads the configured bot token from `config.channels?.discord?.botToken` but `discordSetToken` writes it to `config.channels.discord.token`. As a result, the newly saved token is never used by the rest of the handlers, causing authentication failures, misleading connection state, and potentially leaving an older token active if one exists under the read key. In a credential-management skill, this inconsistency is especially dangerous because operators may believe they rotated or fixed a secret when the running system still uses stale credentials.

Intent-Code Divergence

High
Confidence
98% confidence
Finding
The implementation and comments claim the handler saves the Discord token to configuration, but it writes a different field than the rest of the backend reads. That creates a silent configuration integrity bug: the UI or caller receives a success result and restart notice even though subsequent operations will still report no token or use the wrong one. In this skill’s context, which automates credential management and service restarts, deceptive success states increase the likelihood of outage and failed secret rotation.

Instruction Override

High
Category
Prompt Injection
Content
### Finding IDs

1. Enable Developer Mode: User Settings → Advanced → Developer Mode
2. Right-click server/channel/user → **Copy ID**

## Bot Presence
Confidence
70% confidence
Finding
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
```bash
# Reset discord state (if applicable)
rm ~/.clawdbot/data/discord-*.json

# Restart to rebuild state
clawdbot gateway restart
Confidence
85% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Lp3

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding
The skill describes installation steps, token validation, health checks, and automatic integration actions that imply network access and environment interaction, yet it declares no explicit tool scope or permissions. This weakens user visibility and policy enforcement, increasing the chance that an agent executes networked or environment-modifying actions without informed consent.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The installation section says the skill will automatically install components, update navigation, register handlers, and later notes a build and gateway restart, but it does not present this as a prominent risk warning. Silent or under-disclosed local code modification and service restart can disrupt systems, bypass change-management expectations, and create an opportunity for persistence if the skill is abused.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The skill instructs users to paste a Discord bot token and describes storage options, but it does not provide a strong warning about credential sensitivity, redaction, least exposure, and secure handling. Because bot tokens grant remote control over a Discord bot and often access to multiple servers, weak disclosure around handling can lead to accidental leakage in logs, chat transcripts, config files, or screenshots.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
This handler performs two safety-relevant actions: it persists a credential to the config file and schedules a process restart so the new token takes effect. Although the returned message mentions the restart after the fact, there is no prior confirmation prompt or explicit user-facing warning before making these changes.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The post-install hook automatically executes a gateway restart via execSync without explicit prior consent. Automatic service restarts can interrupt active workloads, create denial-of-service conditions for users, and in this skill are more sensitive because the installer also patches core application files and immediately activates those changes.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The uninstall hook deletes files recorded in installContext.installedFiles without any user confirmation or safety check. In a plugin that modifies host application files, this can cause unexpected data loss or break the gateway/UI if the tracked paths are stale, incorrect, or influenced by prior install state.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The troubleshooting guide instructs users to pass a raw Discord bot token directly on the command line, which can expose the credential through shell history, process listings, terminal scrollback, and logging systems. Because this is operational documentation for a live integration, the token is a high-value secret and the lack of handling guidance creates a realistic credential-leak risk.

Missing User Warnings

Medium
Confidence
85% confidence
Finding
Resetting a bot token is a sensitive, potentially disruptive action because it invalidates the previous credential and requires secure storage of the new one. The document presents this as a routine fix but does not warn about operational impact or safe handling of the regenerated secret.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The recovery procedure tells users to delete local Discord state files without clearly warning that the action is destructive and may remove cached guild/channel state or other local operational data. In troubleshooting documentation, destructive remediation without backup guidance can cause avoidable data loss or service disruption, especially if copied verbatim under time pressure.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
This code builds an Authorization header from the supplied bot token and sends it over HTTP requests to Discord. While the script's health-check purpose implies network access, it does not explicitly warn users that their credential will be transmitted to external endpoints as part of validation.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
removeFile(path.join(gatewayPath, "src/gateway/server-methods/discord-connect.ts"));
  removeFile(path.join(uiPath, "src/ui/views/discord.ts"));

  // Note: We don't automatically remove patches from server-methods.ts,
  // navigation.ts, and app-render.ts as it's safer to do manually

  log("");
Confidence
80% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Static analysis

Detected: suspicious.dangerous_exec

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
assets/install-hooks.js:247

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
scripts/install-plugin.js:318