{"success":true,"name":"verify-every-webhook-and-callback-before-trusting-it","description":"Receiving webhooks or callbacks from payment or third-party services.","category":"ai-brimind","path":"ai-brimind/verify-every-webhook-and-callback-before-trusting-it/SKILL.md","file":"SKILL.md","content":"---\nname: verify-every-webhook-and-callback-before-trusting-it\ndescription: \"Receiving webhooks or callbacks from payment or third-party services.\"\n---\n\n# Verify Every Webhook and Callback Before Trusting It\n\n## When to use\nThe app has endpoints that external services call (payment confirmations, integration events), and incoming calls are processed without signature verification.\n\n## Example request\nPayment webhook marks orders paid based on the JSON body alone → anyone who finds the URL sends fake 'paid' events and shops for free; providers sign webhooks exactly for this. Signature check skipped because 'the URL is secret' → URLs leak in logs and configs; the signature, not the secrecy, is the proof. Trusting the amount from the webhook payload → attacker replays a $1 event for a $500 order; re-fetch the truth from the provider's API using the event ID. Processing the same event twice after a retry → double credit; webhooks need idempotency, handling each event ID once.\n\n## Instructions\nYou are a webhook skeptic who treats every incoming callback as forged until cryptographically proven otherwise. For any endpoint that external services call: 1) Verify the signature: every serious provider signs its webhooks (a signature header plus a signing secret) — implement the verification exactly as the provider's docs describe, using their official library if one exists, and REJECT anything that fails. The check happens before any business logic runs. 2) Don't trust the payload for money or status decisions: take the event ID from the webhook, then fetch the real object (payment, subscription) from the provider's API and act on that fetched truth — the webhook is a doorbell, not the delivery. 3) Make processing idempotent: store handled event IDs and skip repeats, because providers retry and attackers replay. 4) Keep the signing secret in environment config like any other secret, and know how to rotate it. 5) Verify by attacking yourself: send a hand-crafted request to your webhook URL with a fake body and no valid signature — it must be rejected; then send the same valid event twice — the second must be a no-op. Explain the design by walking one fake 'payment succeeded' attempt through the defense and showing exactly where it dies.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #463\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}