Skip to content

AWS WAF not able to filter strange requests

0

We have a CloudFront distribution with WAF enabled. The distribution's Origin is an NGINX webserver. We are suffering a DDoS attack where we are receiving HTTP requests with a strange format that WAF is not filtering at all and they are flooding our webserver. These are examples of the request logs we see in the webserver:

119.207.63.94 - - [21/Jun/2025:19:03:58 +0000] "\xB4\x84l\x8Fib\xBB\xE0R\x866\x12\xACBh\x9Dr\x8E\x8C2\xB3e\x11\xCB`\xBAI\x13\x22\xA4\xB0\xA48;\xA3\xB6\x9A(N\xE94\xA8\xF2\xA7\x8Ex~\xAC\x19\xAE\x9E\x0EW\x95\xE1\xB02\xBA-\xCB\xE7D\x13\xF1 \xECr\xA8\xBBM$K\xB2\xD2\xFA\x90d\x0B2\x9F+m\x82\x158\x06\xC3\x5Cz\x1F\x87\xBC\x0Eif\xB2" 400 150 "-" "-" 0 5.501 [] [] - - - - 1681bb8803778cfce863a81796601f03

119.207.63.94 - - [21/Jun/2025:19:03:58 +0000] "p\xC1?Q\xF8*#\x8B\x06\xE5\xF7!" 400 150 "-" "-" 0 3.679 [] [] - - - - c2e9c38816e8cb1985d1429937ac0053

Apparently there is no Method or Protocol in the request, only a weird string. We couldn't find any rule that could match this pattern to block them. We couldn't reproduce it either.

We've read that WAF only intervenes when the HTTP request is properly formed... but in that case, which option do we have to stop this kind of attack?

4 Answers
1

The IP address in that log entry doesn't belong to AWS, so it isn't a CloudFront edge server that's sending the request. The connections are reaching your Nginx server directly, without going through CloudFront and therefore also not getting processed by WAF.

First, open the VPC console in the region where your Nginx server is hosted. Select "Managed prefix lists" from the left, and find the prefix list with the name com.amazonaws.global.cloudfront.origin-facing. This list contains all the IP ranges that CloudFront edge servers use to connect to origin resources, such as your web server. From the data of the prefix list, copy its "prefix list ID". For example, for the us-east-1 region, it would be pl-3b927c52.

From the security group of your web server, remove rules that allow connections inbound from 0.0.0.0/0 and/or ::/0, which denote the entire internet over IPv4 or additionally over IPv6. In its place, add a new rule that permits inbound tcp/443 (or tcp/80 if you're using unencrypted connections between CloudFront and Nginx) from the prefix list with the ID that you looked up. This way, only CloudFront servers protected by WAF will be able to reach Nginx, and all direct connections from the internet to the server will be dropped by the security group.

EXPERT

answered a year ago

EXPERT

reviewed a year ago

  • Also consider VPC Origin. The solution above could also be improved by inserting a custom header in CloudFront and checking for the presence of the header on NGINX, however note that a single NGINX origin is not DDoS or failure resilient - you need ALB with an auto-scaling group and targets in at least 2 AZ.

0

The issue you're experiencing is related to how AWS WAF processes HTTP requests. AWS WAF is designed to filter and block malicious web requests, but it primarily works with properly formed HTTP requests that follow standard protocols.

The logs you've shared show requests with binary/hexadecimal content that don't follow standard HTTP request formats (no proper method, URI, or protocol). These malformed requests are bypassing WAF inspection because they don't meet the basic criteria for AWS WAF to process them properly.

To address this type of attack, consider these approaches:

  1. Configure your NGINX server to quickly reject these malformed requests with minimal resource consumption. This can be done through NGINX configuration optimizations.

  2. Implement rate-based rules in AWS WAF to limit the number of requests from specific IP addresses. While this won't block the malformed requests directly, it can help mitigate the impact of the DDoS attack by limiting traffic from the attacking IPs.

  3. Use AWS Shield Advanced for enhanced DDoS protection capabilities beyond what standard WAF offers.

  4. Consider implementing geo-restrictions in AWS WAF or CloudFront if the attacks are coming from specific geographic regions where you don't expect legitimate traffic.

  5. Enable AWS WAF logging to gather more information about the traffic patterns, which might help identify additional characteristics you could use for filtering.

  6. Add custom rules in AWS WAF that block based on IP addresses identified in your NGINX logs as sources of these malformed requests.

Remember that AWS WAF works best as part of a layered security approach, especially for handling unusual attack patterns like the one you're experiencing.
Sources
AWS WAF Rules not working | AWS re:Post
Detect and filter malicious web requests (BP1, BP2) - AWS Best Practices for DDoS Resiliency
AWS WAF - AWS Best Practices for DDoS Resiliency

answered a year ago

0

@mofaized-AWS The requests aren't going through WAF when Nginx's log shows them arriving directly from a random IP address in Korea. WAF settings will have no effect on requests not going anywhere near it.

Furthermore, even if WAF weren't used or regardless of how it was configured, CloudFront wouldn't send requests to an origin at all without one of the HTTP methods that CloudFront supports, which are GET, HEAD, OPTIONS, PUT, POST, PATCH, and DELETE (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistValuesCacheBehavior.html#DownloadDistValuesAllowedHTTPMethods).

EXPERT

answered a year ago

-1

If these requests are actually passing through your WAF, why not simply create a rule within your WebACL that blocks traffic without an expect HTTP method? Something like:

WAF-rule

AWS

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.