Menu

Building a Zero-Trust Discord License Key Bot in discord.js v14: HMAC-SHA256 Webhooks, Seat Caps & Refund Revocation
📰

Building a Zero-Trust Discord License Key Bot in discord.js v14: HMAC-SHA256 Webhooks, Seat Caps & Refund Revocation

DEV Community: node·NiNo Studio·about 9 hours ago
#G84QTPWB
#devtonodejs#devto#dev#const#license
Long article (2304 words) — no AI summary yet.
Reading 0:00
15s threshold

Most indie Discord license bots start as a 60-line script: accept a JSON webhook from Stripe or Gumroad, generate crypto.randomUUID() , store it in a JSON file, and grant a VIP role when someone runs /redeem .

Within a week of real traffic, four abuse vectors show up:

Forged webhook requests: Anyone who discovers your /webhook endpoint can POST a fake sale payload and mint unlimited keys.

Timing side-channels & parsed-JSON re-serialization bugs: Comparing signatures with === leaks byte-level timing, and verifying an HMAC over JSON.stringify(req.body) breaks when whitespace or key order differs from the raw payload.

Key sharing across 20 Discord accounts: Without atomic seat-cap binding, one leaked key gets redeemed by an entire server.

Chargeback buyers keeping VIP roles forever: If your webhook only listens for payment.succeeded and ignores charge.refunded / charge.dispute.created , refunded buyers keep gated channels permanently.

Here is a zero-trust architecture using node:crypto , discord.js v14,…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.