Discord IntegrationAnti-Escalation

Role Management

Universal anti-escalation role delegation guard (isRoleSafeForDelegation), role hierarchy checks, and the exact DANGEROUS_ROLE_PERMS_MASK permission bitmask.

Universal Role Delegation Safety (isRoleSafeForDelegation)

Any Taicket module that grants Discord roles automatically or through member interactions (Verification, Greeting Human/Bot Auto-Roles, Leveling Rewards, Economy Store Items and Craft Recipes, Reaction Roles, and Component Builder buttons) runs every target role through isRoleSafeForDelegation with isOwner: false before saving.

Running with isOwner: false across MCP guarantees that even a compromised Server Owner token or prompt-injected AI session cannot wire an administrative or moderation role into a public reaction button, welcome auto-role, or economy shop item.

  1. Live guild existence check:: Role ID must be a valid 17-20 digit snowflake present in fetchGuildRoles(guildId), preventing cross-guild role injection.
  2. @everyone block:: Rejects any role where String(role.id) === String(guildId) or role.name === "@everyone".
  3. Managed role block:: Rejects roles with role.managed === true (bot roles, Server Booster roles, linked integration roles, and Twitch/YouTube subscriber roles).
  4. Bot & actor hierarchy check:: Rejects roles where role.position >= botHighestPos (bot cannot assign them) or role.position >= actorHighestPos (caller cannot escalate above their own highest Discord role).
  5. Dangerous permission bitmask block:: Computes (BigInt(role.permissions) & DANGEROUS_ROLE_PERMS_MASK) !== 0n and rejects any role holding privileged moderation or administrative bits.

DANGEROUS_ROLE_PERMS_MASK Specification

The exact 8 Discord permission flags blocked by DANGEROUS_ROLE_PERMS_MASK (matching dashboard/src/lib/security.js verbatim):

Discord Permission FlagHex Bitmask (BigInt)Security Rationale
ADMINISTRATOR0x8nGrants full bypass of all channel overwrites and server security controls
MANAGE_GUILD0x20nAllows modifying server settings, webhooks, AutoMod rules, and Taicket Real Admin access
MANAGE_ROLES0x10000000nAllows assigning or editing other roles and channel permission overwrites
MANAGE_CHANNELS0x10nAllows creating, editing, or deleting channels and categories
BAN_MEMBERS0x4nAllows permanently banning server members
KICK_MEMBERS0x2nAllows kicking server members
MANAGE_WEBHOOKS0x20000000nAllows creating arbitrary webhooks for phishing or mass-ping raids
MODERATE_MEMBERS0x10000000000nAllows timing out arbitrary server members
Exact DANGEROUS_ROLE_PERMS_MASK bitwise checktypescript
export const DANGEROUS_ROLE_PERMS_MASK =
  0x8n | // ADMINISTRATOR
  0x20n | // MANAGE_GUILD
  0x10000000n | // MANAGE_ROLES
  0x10n | // MANAGE_CHANNELS
  0x4n | // BAN_MEMBERS
  0x2n | // KICK_MEMBERS
  0x20000000n | // MANAGE_WEBHOOKS
  0x10000000000n; // MODERATE_MEMBERS

export function hasDangerousRolePermissions(permissions: string | number | bigint): boolean {
  try {
    const bits = BigInt(permissions ?? 0);
    return (bits & DANGEROUS_ROLE_PERMS_MASK) !== 0n;
  } catch {
    return true;
  }
}

Precomputed Safety Flags in get_server_topology

get_server_topology annotates every role in the server with delegationSafe and unsafeReason so AI assistants automatically filter out unsafe roles when proposing Verification, Auto-Role, Leveling, Economy, Reaction Role, or Component Builder configurations.

Role objects returned by get_server_topologyjson
{
  "botHighestRolePosition": 14,
  "roles": [
    {
      "id": "1189452019384729650",
      "name": "Moderator",
      "position": 12,
      "managed": false,
      "delegationSafe": false,
      "unsafeReason": "Role grants privileged moderation or administrative Discord permissions."
    },
    {
      "id": "1189452019384729655",
      "name": "Verified Member",
      "position": 5,
      "managed": false,
      "delegationSafe": true,
      "unsafeReason": null
    }
  ]
}

Related documentation