Validating the Webhook S2S
To validate a Webhook, simply verify the IP it's coming from in the HTTP header.
Here it is the list of IPs from where we send the Webhooks S2S to publishers. Use these IPs to avoid security issues and validate incoming postbacks.
Securing X-Forwarded-For Header
When your service is behind a load balancer or reverse proxy, be aware of potential manipulation of the X-Forwarded-For
header. This header is used to identify the originating IP address of the client connecting to the web server through an HTTP proxy or load balancer.
Risks:
Header Manipulation: Attackers can spoof the
X-Forwarded-For
header to bypass IP restrictions.
Security Measures:
Trusting Proxies: Only trust headers from known proxies or load balancers. Each cloud platform adds the client IP address at a specific position in the
X-Forwarded-For
chain, which you should consider when validating the IP.AWS (ELB/ALB): AWS puts the true client IP at the beginning of the
X-Forwarded-For
list.Google Cloud Platform (GCP): GCP adds the original client IP at the second-to-last position.
Azure: Azure load balancers append the real client IP at the last position.
Make sure to parse this header correctly depending on your cloud provider to avoid accepting a spoofed IP.
PHP Code Example for AWS:
Like this comment
Last updated