TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Collection of best practices for providing and consuming webhooks

235 pointsby m3hover 2 years ago

9 comments

cuu508over 2 years ago
There are some interesting attack vectors to be aware of if you run a service where users can define webhooks, and your service will will call the user-defined webhooks to notify about certain system events. In my case, a monitoring service which can send notifications by calling user-defined webhook.<p>* Timeouts: the user can set up a webhook receiver that takes very long to generate a response. Your service must be able to deal with that.<p>* Timeouts (slowloris): the webhook target could be sending back one byte at a time, with 1 second pauses inbetween. If you are using, say, the &quot;requests&quot; python library for making HTTP requests, the &quot;timeout&quot; parameter will not help here<p>* Private IPs and reserved IPs: you probably don&#x27;t want users defining webhooks to <a href="http:&#x2F;&#x2F;127.0.0.1:&lt;some-port&gt;" rel="nofollow">http:&#x2F;&#x2F;127.0.0.1:&lt;some-port&gt;</a> and probing your internal network. Remember about private IPv6 ranges too<p>* Domains that resolve to private IPs: attacker could set up foo.com which resolves to a private IP. It is not enough to just validate webhook URLs when users set them up.<p>* HTTP redirects to private IPs. If your HTTP client library follows HTTP redirects, the attacker can set up a webhook endpoint that redirects to a private IP. Again, it is not enough to validate the user-supplied URL.<p>* Excessive HTTP redirects. The attacker can set up a redirect loop - make sure this does not circumvent your timeout setting.<p>My current solution for all of the above is to use libcurl via pycurl. I wrote a wrapper that mimics requests API: <a href="https:&#x2F;&#x2F;github.com&#x2F;healthchecks&#x2F;healthchecks&#x2F;blob&#x2F;master&#x2F;hc&#x2F;lib&#x2F;curl.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;healthchecks&#x2F;healthchecks&#x2F;blob&#x2F;master&#x2F;hc&#x2F;...</a> (may contain bugs, use at your own risk :-)
评论 #32521104 未加载
评论 #32518343 未加载
评论 #32519718 未加载
评论 #32520035 未加载
评论 #32520138 未加载
评论 #32521471 未加载
评论 #32520806 未加载
caseysoftwareover 2 years ago
Hello all! I&#x27;m one of the creators of webhooks.fyi over at <a href="https:&#x2F;&#x2F;ngrok.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ngrok.com&#x2F;</a><p>Happy to answer any questions!<p>First, we started this project when we launched in-product webhook verification. We realized that we were collecting great information, had uncovered some clear and obvious patterns (both good &amp; bad), and knew we could publish the results to help the ecosystem as a whole.<p>Next, yes it&#x27;s ridiculously hard to build webhooks correctly. There are so many shortcuts that feel &quot;okay&quot; and you don&#x27;t really think about until you realize that it didn&#x27;t quite work as you had planned and now you have a gap. We&#x27;re hoping the site can help people move more of that thinking earlier and make better decisions.<p>Finally, we&#x27;re missing a bunch of webhooks! While we looked at 100+ in our own research, we only had time to add ~50 to this initial pass. If you&#x27;d like to add your favorites, pull requests welcome: <a href="https:&#x2F;&#x2F;github.com&#x2F;ngrok&#x2F;webhooks.fyi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ngrok&#x2F;webhooks.fyi</a><p>And yes, seriously, you can use ngrok to verify webhooks pretty easily:<p><i>ngrok http 80 --verify-webhook=slack --verify-webhook-secret=[secret]</i>
评论 #32520847 未加载
sparselyover 2 years ago
As this page makes very clear, it&#x27;s actually pretty hard to make a robust webhooks implementation!<p>What alternatives are there? I&#x27;ve looked at: * Publishing AWS EventBridge events to other accounts. * &#x2F;events instead of webhooks <a href="https:&#x2F;&#x2F;blog.sequin.io&#x2F;events-not-webhooks&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.sequin.io&#x2F;events-not-webhooks&#x2F;</a> * ???
评论 #32518587 未加载
评论 #32520006 未加载
评论 #32522427 未加载
leetroutover 2 years ago
This is a fantastic resource! Thank you to the folks at ngrok for putting this together! As this site makes clear: webhooks are harder than they appear. Even just consuming webhooks it&#x27;s easy to get bogged down dealing with issues around rate limits or recovering from bugs that cause missed events! Missed events being particularly painful with platforms that don&#x27;t offer replay &#x2F; retry.<p>Disclaimer: I work at <a href="https:&#x2F;&#x2F;hookdeck.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hookdeck.com&#x2F;</a> &amp; I shamelessly plug our tool for giving you an awesome developer experience working with webhooks and helping deal with some of the concerns brought up on webhooks.fyi.<p>And if you are interested in webhooks at large a couple more resources worth checking out is the awesome-webhooks[1] list and the r&#x2F;webhooks[2] subreddit (I just got ownership of the sub and started dusting it off this week after being neglected for the past few years! Please, come join!)<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;realadeel&#x2F;awesome-webhooks" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;realadeel&#x2F;awesome-webhooks</a><p>[2] <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;webhooks&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;webhooks&#x2F;</a>
dgudkovover 2 years ago
If only there was a single standard for webhook subscription verification. Cloud services invent their own authentication protocols. Webhook verification in Dropbox is different from that in Trello. The lack of a single standard makes it hard to design a universal incoming webhook service (we faced this problem).
评论 #32521048 未加载
评论 #32525052 未加载
评论 #32521127 未加载
danpalmerover 2 years ago
Great resource! I’ve encountered most of these problems at some point.<p>It would be great to see advice about implementations. Things like when to process in a queue and when not to, tying idempotency tokens to database transactions, etc. These are subtle issues, but when done well can help make very robust systems.
评论 #32520310 未加载
egorfineover 2 years ago
Excellent. I&#x27;m in process of building a service delivering notifications via webhooks right now. Thank you!
评论 #32520037 未加载
babbledabblerover 2 years ago
Seeing this right after finishing a webhook integration.
Traubenfuchsover 2 years ago
Why are callback registration and async APIs now called webhooks?
评论 #32518186 未加载
评论 #32518180 未加载
评论 #32518170 未加载