4 points · by pdiffley · 1mo ago · 5 comments
This bugged the hell out of me because the webhook functionality I needed was pretty basic, but using symmetric signatures, which requires the webhook producer to hold onto a secret for every endpoint they send webhooks to, introduced a major secret management problem. Designing and implementing novel secret management techniques for my web app felt like a bad idea, so I started looking into why so many people use symmetric signatures instead of asymmetric signatures.
I frequently saw performance listed as a problem with asymmetric signatures, so I thought this might be why they weren't more broadly used, but a quick benchmark proved that wrong (HMAC signing is much faster, but ed25519 is still fast enough that it doesn't matter).
It seemed like the biggest barrier to using asymmetric signatures was added development complexity. There are small but important details that need to be included in an asymmetric signature, getting asymmetric keys into the right format is more complicated than for symmetric keys, and the crypto libraries you're working with can have sharp edges.
That complexity makes it more difficult for a webhook producer to implement (and document) asymmetric signatures, but then all of their consumers also have to implement the verification step (hopefully correctly). Building a library that does these steps for you is difficult because it has to be available in any language a webhook consumer might be using, not just the language the webhook producer uses.
But it kept bugging me that we're all using a less good form of authentication just because we haven't packaged up the steps to sign and verify an asymmetric signature that is secure for webhooks, so now I've built that library. With a few language implementations to serve as a template, replicating this in enough languages that the large majority of developers can use it feels totally doable, and I am hoping to get several more languages implemented over the next few weeks.
Correct Hooks makes one of the most secure authentication mechanisms for webhooks the easiest to implement for both webhook producers and consumers.
Can you include a mention of the signing key algorithm (ed25519) higher up in the README? That was important information I had to scroll a long ways to find.
I can't respond to this comment directly because it is dead, but that is an important thing to call out. We have replay protection built into the libraries. The signature contains a timestamp, a unique webhook id for the event, the recipient id, and the target endpoint’s url and method.
The verify function returns an error if the timestamp is expired or if the recipient id or target url are not as expected. The timestamp check is standard for any type of signature. The recipient id and target url check is unique to asymmetric signatures and prevents a situation where one user can forward their requests or trick the webhook producer into sending requests to a different user.
If extra protection is desired, the webhook id is returned to the consumer after they verify the request and can be used to guarantee that a webhook can only be received once (eg. throw the webhook ids in redis with a ttl longer than the signature ttl and reject any requests with webhook ids that have already been seen).