Webhook

A webhook is an HTTP request that one service sends to another service's URL when an event happens, such as a payment going through or code being pushed to a repository.

Instead of asking a payment provider "has anything happened yet?" every few seconds, your application gives the provider a URL, and the provider sends an HTTP POST request to that URL whenever an event occurs. This is convenient, but it raises a security question for each side of the conversation.

If you receive webhooks, anyone who learns the URL can send fake events to it, and a forged "payment succeeded" message is worth a lot to a fraudster. Many providers, including GitHub and Stripe, sign each webhook with a shared secret using an HMAC. Your code should check that signature (and a timestamp, so old messages cannot be replayed) before it trusts the event.

If you send webhooks, your users choose the URLs that your servers will call. An attacker can register a URL that points inside your own network, such as http://169.254.169.254/ (the address that cloud servers use to fetch their own credentials), and turn your webhook feature into a tool for server-side request forgery. Resolve each URL before calling it, and refuse any URL that points at a private or internal address.

Further Reading

Learn it hands-on

An attacker can use SSRF vulnerabilities to probe your internal network.