{"success":true,"name":"verify-webhooks-and-callbacks-a-post-to-your-url-proves-noth","description":"Adding an endpoint that receives events from a payment or external service","category":"ai-brimind","path":"ai-brimind/verify-webhooks-and-callbacks-a-post-to-your-url-proves-noth/SKILL.md","file":"SKILL.md","content":"---\nname: verify-webhooks-and-callbacks-a-post-to-your-url-proves-noth\ndescription: \"Adding an endpoint that receives events from a payment or external service\"\n---\n\n# Verify Webhooks and Callbacks: A POST to Your URL Proves Nothing\n\n## When to use\nYou are building an endpoint that an external service calls (payment result, delivery status, OAuth callback), and the app will act on what arrives.\n\n## Example request\nMarking an order paid whenever the webhook URL receives 'status: paid' → anyone who finds the URL can send that JSON with curl; the signature header must be verified with the shared secret (webhook signature verification). Trusting the amount in the webhook body → a tampered event says the full price was paid; re-check amount and currency against your own order record (server-side reconciliation). Processing the same event twice after a retry → the user gets double credit; store processed event IDs and skip repeats (idempotency). Accepting any redirect target after OAuth login → attackers bounce users to a fake site with their token; callback and redirect URLs must be whitelisted (open redirect / callback validation).\n\n## Instructions\nAct like a developer who remembers that a webhook endpoint is a public door on the internet, and the sender's name in the JSON is just text. Before acting on any incoming event, authenticate it using the provider's official mechanism: verify the signature header against your secret exactly as the provider documents (using their SDK helper if one exists), reject anything unsigned or mis-signed, and keep the secret in environment configuration. Then verify the content against your own records: look up the order or entity yourself, compare amounts, currencies, and states server-side, and never let the event body overwrite your source of truth directly. Make handling idempotent by recording processed event IDs, because providers retry deliveries. For OAuth or redirect callbacks, validate state parameters and allow only whitelisted redirect URLs. Test like an attacker: send a hand-made request to your endpoint with curl and confirm it is rejected. Only go live once every external callback is signature-verified, reconciled against your data, and safe to receive twice — and explain how this stops forged and replayed events, not just how it handles the provider's happy path.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #536\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}