Skip to content
This repository was archived by the owner on Jan 23, 2021. It is now read-only.

Ensure Webhooks are received from a whitelisted IP address #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

willock-stripe
Copy link

This pull request adds a simple guard to ensure that Webhooks are only processed when received from a verified, whitelisted IP address. This makes use of the documented ips_webhooks.json resource, which can be programatically fetched for the purposes of configuring iptables, etc.

Much like #5, this isn't something that you might necessarily want to do in a debugging tool (or even at the application layer!), but piqued my curiosity. Feel free to ignore or close!

Changes

  • Add guard to Webhooks receipt endpoint which ensures that the sender appears on Stripe's whitelist
  • Add request dependency

- Add guard to Webhook receipt endpoint which ensures that the
  sender appears on Stripe's whitelist
- Add `request` dependency
console.log(
chalk.red('Received webhook from a non-whitelisted IP, ignoring.')
);
return;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should return a 400 response.

@willock-stripe
Copy link
Author

@mg-stripe – erring on the side of "this probably shouldn't live in the application code", but take a look if you're interested!

@willock-stripe
Copy link
Author

@mg-stripe let me know if you get a moment to :ponder: this, please! Happy just to close it out if it doesn't make sense.

@CLAassistant
Copy link

CLAassistant commented Aug 6, 2020

CLA assistant check
All committers have signed the CLA.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants