Security of API
Security of API
A web hook is simply a URL where API providers sent a post when something happens e.g. stripe sent
notifications about new payment to web hook URL.
Securing web hook is slightly different from securing web api coz webbook url are generally publicly
accessed to on the internet therefore its important for developers to ensure that post request actually
came from the stated sender. In the absence of such a verification, an attacker can forge a request to
the web hook URL.
1. Verification tokens
When you connect to an https URL with transport layer security handshake protocol, the server sent its
certificate to the client. The client then verify the server certificate before trusting response.
With mutual tls, server and client both authenticate with each other. Server sent client a certificate
request, client (web hook provider) responds with certificate. Serve verify the certificate before trusting
request.
One fundamental problem is that all these methods rely on developers to do the righ thing. They do not
enforce authentication.
Different application developers can follow different standards and it’s difficult to determine whether
they are verifying web hook request. More secure option is to send limited information in the payload
indicating to the application that something to retrieve the full event, the application will need to
make…
The key benefit is that even if application does not verify the web hook they will receive the web event
only after making regular authenticating request to web API.
1. Avoid sending sensitive information as part of web hook payload, therefore use authenticated API
request to send sensitive information.
2. When signing web hook include time stamp. This way, application can implement checks for replay
attacks.
3. Support regeneration of shared secretes that are used for verification or for signing we hook so that in
case of a compromised secrete, an application developer can rotate this secret and ensure authentity of
future reques
4. Provide developers with sdk and sample code that verify authenticity of the we hook request