Operations & false positives4 min read6 sections

How to stop origin bypass attacks on CloudFront + AWS WAF (locking down origins)

Putting Amazon CloudFront and AWS WAF in front of a website stops attack traffic at the edge only if visitors cannot reach your origin server directly. If port 443 on your load balancer or web server remains open to 0.0.0.0/0, attackers look up the origin IP, skip CloudFront completely, and saturate PHP or your database while your WAF graphs look calm. Here is the two-layer lockdown pattern that closes origin bypass permanently.

On this page (6)

How attackers find your origin IP behind CloudFront

Changing public DNS to point at CloudFront does not hide an origin IP that was ever public. Automated scanners pull historical DNS A records, Certificate Transparency logs for unproxied subdomains, SPF and MX records hosted on the same server, and full IPv4 TLS certificate scans.

Once an attacker has the raw IPv4 address, they send requests directly to your origin with a spoofed Host header. Every AWS WAF rate limit, country block, and managed rule is bypassed. We documented a real incident where an origin took roughly 90 million requests an hour after the edge cooled because direct-to-origin traffic was still open.

Layer 1: Lock network ingress to the CloudFront Managed Prefix List

On AWS (ALB, NLB, or EC2), replace 0.0.0.0/0 inbound rules on ports 80 and 443 with the AWS-managed prefix list com.amazonaws.global.cloudfront.origin-facing. AWS maintains that prefix list automatically whenever CloudFront adds or retires edge CIDR ranges, eliminating brittle manual firewall scripts.

Plan for Security Group rule quotas before attaching the managed prefix list: the CloudFront origin-facing prefix list consumes a large slice of a security group's inbound rule weight (often 55 or more entries), so dedicate a clean edge-ingress security group on your ALB or request a quota increase if your group already holds many rules.

On campus firewalls or non-AWS VMs, mirror the same rule by allowing inbound HTTPS only from published CloudFront edge IP ranges plus your internal admin and monitoring CIDRs.

Layer 2: Require a secret custom origin header (X-Origin-Verify)

IP allowlisting alone is not complete isolation, because every Amazon CloudFront distribution in every AWS account shares the same CloudFront edge IP ranges. Without a shared secret header, an attacker can spin up their own CloudFront distribution pointing at your origin IP and bypass your Web ACL.

Configure CloudFront to inject a long random custom origin header (for example X-Origin-Verify) on every origin request, and enforce that header on your origin: an AWS ALB listener rule returning fixed HTTP 403 when the header is missing, or an equivalent check in Nginx, Apache, or IIS.

When rotating the secret header, accept both the current and next value at the origin first, switch CloudFront to send the new value, wait for distribution deployment to complete, and then remove the old value for zero-downtime rotation.

Origin lockdown matrix by hosting stack

Even when you do not control AWS Security Groups, you can still close direct-to-origin bypass cleanly.

Recommended CloudFront origin lockdown controls by hosting environment
Hosting stackNetwork-layer controlApplication / header control
AWS ALB / EC2Security Group inbound 443 restricted to com.amazonaws.global.cloudfront.origin-facingALB listener rule enforcing custom origin verify header, returning 403 otherwise
Campus VM (Apache / Nginx)Perimeter firewall restricted to CloudFront ranges + campus admin CIDRsReject requests missing the custom origin header and drop default-vhost raw IP requests
Managed CMS host / PaaSUse host IP allowlist if offered; retire public origin-only subdomainsValidate custom origin header at edge/webserver config; rotate origin hostname if leaked

Verification checklist before removing 0.0.0.0/0

Before closing public port 443 on your origin, list every legitimate non-browser caller that hits the origin directly: internal uptime monitors, CI deployment webhooks, scheduled cron jobs, or external payment callbacks. Point public webhooks through the CloudFront hostname and allowlist internal monitoring IPs explicitly.

After applying both layers, run two quick curl tests from an external machine: one directly against the origin IP with a Host header (it should time out at the firewall or return 403 without the verify header) and one against your public CloudFront hostname (it should return 200 with valid TLS).

FAQ

Is the AWS CloudFront Managed Prefix List alone enough to stop origin bypass?

It stops direct internet floods immediately, but pairing it with a secret custom origin header closes the remaining gap where another CloudFront distribution points at your origin IP.

Will blocking public port 80 and 443 on my origin break SSL certificate renewal?

Not when TLS terminates on CloudFront with AWS Certificate Manager (ACM), because ACM validates certificates via DNS CNAME records rather than HTTP requests to your origin.

How do I rotate a custom origin header without causing 403 errors?

Configure your ALB, Nginx, or Apache rule to accept both the old and new secret header values, deploy the new header in CloudFront, verify traffic passes, and then remove the old value.

Does WAF Cybersecurity help verify our origin lockdown during onboarding?

Yes. During setup and concierge DNS cutover, we verify your CloudFront edge shield and share clear origin-lockdown guidance for your hosting stack.

Count mode first

Check whether your origin is exposed right now

New rules start in count mode so you review live traffic evidence before a human clicks Promote.