Welcome to Day 20 of the 30 Days AWS Security Challenge. Yesterday we covered scanning for vulnerabilities inside your own workloads. Today we look outward, at attacks coming from the public internet aimed straight at your web application, and how AWS WAF stops many of them before they ever reach your code.
Why Application Level Attacks Are Different
Everything we've covered so far in this challenge, IAM, VPCs, encryption, largely protects your infrastructure and data. But a web application listening on port 443 is still exposed to the internet by design, since that's the whole point of running one. Attackers know this, and instead of trying to break into your network, they send malicious requests directly to your application, hoping to exploit a weakness in how it processes input. AWS WAF exists specifically to catch and block that kind of traffic.
What WAF Actually Does
WAF, short for Web Application Firewall, sits in front of your application and inspects incoming HTTP and HTTPS requests before they reach it. Based on rules you define, it can allow, block, or count requests matching specific patterns. WAF attaches to services like CloudFront, an Application Load Balancer, or API Gateway, meaning it filters traffic right at the entry point, before a malicious request ever touches your actual servers.
Some of the attack types WAF commonly protects against:
- SQL injection, where an attacker tries to manipulate a database query through malicious input
- Cross site scripting (XSS), where an attacker injects malicious scripts meant to run in another user's browser
- Bad bots and scrapers, automated traffic that isn't a real user at all
- Known bad IP addresses, based on threat intelligence lists
Rules and Rule Groups
WAF works through rules, and each rule defines a condition to match and an action to take, like blocking any request whose body matches a common SQL injection pattern. Writing every rule yourself would take significant expertise, so AWS provides Managed Rule Groups, pre built collections of rules maintained by AWS and trusted third parties, covering common attack categories like the OWASP Top 10.
For most teams, starting with a managed rule group like the AWS Managed Rules Core Rule Set covers a solid baseline of common attacks without needing to write custom logic from scratch. You can then layer your own custom rules on top for anything specific to your application.
Setting Up a Web ACL
WAF rules are organized into something called a Web ACL, short for web access control list, which you attach to your CloudFront distribution, load balancer, or API Gateway. To create one, go to WAF & Shield > Web ACLs > Create web ACL, choose the resource to protect, then add rule groups, starting with a managed baseline set.
Each Web ACL also has a default action, either Allow or Block, applied to any request that doesn't match a specific rule. Most setups default to Allow, relying on specific rules to catch and block the bad traffic, rather than blocking everything by default.
Testing Before Blocking
A genuinely useful feature is Count mode, which lets a rule log matching requests without actually blocking them. This is worth using when you first turn on a new rule group, since it lets you review what would have been blocked and confirm you're not about to block legitimate traffic from your own users before switching the rule to actually enforce it.
Rate Limiting
Beyond pattern matching, WAF also supports rate based rules, which block an IP address that sends an unusually high number of requests in a short window. This is useful for slowing down brute force login attempts or basic scraping, without needing to identify the specific malicious pattern in the request content itself.
A Practical Example
Say your application sits behind an Application Load Balancer, and you attach a Web ACL with the AWS Managed Rules Core Rule Set plus a rate based rule limiting any single IP to 2000 requests over five minutes. An automated scanner probing your login page for SQL injection patterns gets blocked by the managed rule set almost immediately, and a separate bot attempting a brute force login gets slowed down by the rate limit, all before either ever reaches your actual application code.
Key Takeaways
- WAF inspects web requests at the entry point, blocking malicious traffic before it reaches your application
- Managed Rule Groups give you a solid baseline against common attacks like SQL injection and XSS without writing custom rules
- Use Count mode to test new rules before switching them to actively block traffic
- Rate based rules help slow down brute force and scraping attempts based on request volume alone
- Attach WAF to CloudFront, load balancers, or API Gateway depending on where your traffic actually enters
Tomorrow we look at a related but different kind of attack, DDoS, and how AWS Shield defends against attempts to overwhelm your application with sheer traffic volume.
Loading article