Security

The platform is built so that a bot is never a way around the rules of the community it lives in. This page is what that means for you as a bot author.

What the server guarantees

  • Nothing without a grant. A new bot sees and does nothing. It does not inherit @everyone.
  • Never more than its manager. No change by anyone but the Owner can give a bot something elevated (Administrator, the admin area) or anything the person making the change does not hold. A manifest can never ask for anything elevated.
  • Every event is checked when it is sent. A bot never receives an event from a channel it cannot see, and loses a channel's events the moment its access ends; resumed events go through the same checks.
  • No direct messages. Bots never see members' private conversations, not over the gateway, the REST API or webhooks. A forwarded message reaches a bot without the original's text or ids.
  • No management power. No bot endpoint manages roles, bots, webhooks or members, whatever roles the bot holds. Bots cannot sign in or join Talks.

Tokens

  • Only a SHA-256 hash of a token is stored; the secret is shown once.
  • A token is bound to the person who issued it and stops working when that person no longer qualifies (demoted, disabled, banned, or the bot gained a permission they lack). Re-checked at most every 30 seconds, also on open connections.
  • Revoking a token, disabling, deleting or banning the bot closes its gateway connections immediately (4004).
  • The add link keeps the manifest in the URL fragment, which the browser never sends to a server.

Keep your bot safe

  • Treat the token like a password: keep it in an environment variable or a secret store, never in the code or a repository. If it leaks, Regenerate it in the Bots tab; the old one stops at once.
  • Ask for the fewest intents and permissions that work. Admins see and approve exactly what you ask for.
  • Do not trust input: options and component values are validated by the server for type and visibility, but their content is whatever a member typed.
  • Mention carefully: role mentions and @all need an explicit allowed_mentions, so a bot cannot ping everyone by accident.
  • Outgoing webhooks: always verify the signature over the raw body and refuse old timestamps (how).

The design behind these rules, and what the platform leaves out on purpose: the bot platform note. How to report a vulnerability: SECURITY.md.

Something wrong on this page? Tell us.