fix(stripe): fail closed when webhook secret is unset (BUNYIP-203) #246
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/bunyip-203-stripe-webhook-fail-closed"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Stripe webhook handler called verify_webhook_signature unconditionally. When STRIPE_WEBHOOK_SECRET is unset, StripeConfig::from_env falls back to the public source literal whsec_placeholder, so anyone who knows that constant could forge a valid Stripe-Signature header and drive forged checkout/subscription/invoice events into membership activation, entitlement grants, and tier upgrades.
Add StripeService::webhook_secret_configured(), which returns false when the configured webhook secret is empty or equals the whsec_placeholder placeholder. The handler now consults it before verifying and returns 500 (fail closed) instead of verifying against the guessable placeholder, so an instance brought up without a real secret never trusts an event. main.rs logs a loud warning at startup when Stripe is otherwise wired but the webhook secret is missing. The placeholder literals are hoisted to named constants and reused by is_configured.
#BUNYIP-203