Skip to content

Require a secret for POST /api/licenses; fail closed without a webhook secret - #2

Merged
catsika merged 1 commit into
mainfrom
fix/protect-license-route
Oct 24, 2026
Merged

catsika merged 1 commit into
mainfrom
fix/protect-license-route

Conversation

@catsika

@catsika catsika commented Oct 24, 2026

Copy link
Copy Markdown
Member

POST /api/licenses was unauthenticated. It creates licenses with your Keymint admin API key, so anyone who found a deployed copy of this starter could create licenses in your account.

Changes

  • POST /api/licenses now requires Authorization: Bearer $LICENSE_API_SECRET, compared in constant time. It refuses all requests (503) until LICENSE_API_SECRET is set.
  • Input is validated: a well-formed customerEmail, and an integer maxActivations from 1 to 100. Errors from the admin client are logged on the server and no longer returned to the caller.
  • POST /api/webhooks/keymint refuses all requests (503) until KEYMINT_WEBHOOK_SECRET is set, because an empty HMAC key would let anyone forge a signature. A signature of the wrong length is now rejected instead of crashing (timingSafeEqual throws on different lengths).
  • .env.example, the README and the dashboard page document LICENSE_API_SECRET. The README also recommends creating licenses from your payment provider's webhook rather than exposing this route.

The signature format matches what Keymint sends (Keymint-Signature: t=<ts>,v1=<HMAC-SHA256(secret, ts + "." + body)>). tsc --noEmit is clean.

…a webhook secret

POST /api/licenses created licenses with the admin API key and had no
authentication, so anyone who found a deployed starter could mint licenses.
It now requires Authorization: Bearer $LICENSE_API_SECRET (constant-time
compare), refuses requests until the secret is set, validates the email and
maxActivations (1-100), and no longer echoes admin-client errors.

The webhook route now refuses requests when KEYMINT_WEBHOOK_SECRET is unset
(an empty HMAC key is forgeable) and treats a wrong-length signature as
invalid instead of throwing.
@catsika
catsika merged commit 0d608a9 into main Oct 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant