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.
- Live guild existence check:: Role ID must be a valid 17-20 digit snowflake present in fetchGuildRoles(guildId), preventing cross-guild role injection.
- @everyone block:: Rejects any role where String(role.id) === String(guildId) or role.name === "@everyone".
- Managed role block:: Rejects roles with role.managed === true (bot roles, Server Booster roles, linked integration roles, and Twitch/YouTube subscriber roles).
- 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).
- 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 Flag | Hex Bitmask (BigInt) | Security Rationale |
|---|---|---|
| ADMINISTRATOR | 0x8n | Grants full bypass of all channel overwrites and server security controls |
| MANAGE_GUILD | 0x20n | Allows modifying server settings, webhooks, AutoMod rules, and Taicket Real Admin access |
| MANAGE_ROLES | 0x10000000n | Allows assigning or editing other roles and channel permission overwrites |
| MANAGE_CHANNELS | 0x10n | Allows creating, editing, or deleting channels and categories |
| BAN_MEMBERS | 0x4n | Allows permanently banning server members |
| KICK_MEMBERS | 0x2n | Allows kicking server members |
| MANAGE_WEBHOOKS | 0x20000000n | Allows creating arbitrary webhooks for phishing or mass-ping raids |
| MODERATE_MEMBERS | 0x10000000000n | Allows timing out arbitrary server members |
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.
{
"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
}
]
}