Skip to content

Network_security


AWS provides multiple layers of network security to protect your applications from common web exploits and DDoS attacks.

AWS Network Security Overview
+------------------------------------------------------------------+
| |
| +------------------------+ |
| | Network Security | |
| +------------------------+ |
| | |
| +---------------------+---------------------+ |
| | | | |
| v v v |
| +----------+ +----------+ +----------+ |
| | WAF | | Shield | | Firewall | |
| | | | | | Manager | |
| | - Web | | - DDoS | | - Central| |
| | Attacks| | Protect| | Manage | |
| | - Rules | | - Shield | | - Rules | |
| | - Bot | | Advanced| | - Policies| |
| | Control| | | | | |
| +----------+ +----------+ +----------+ |
| |
+------------------------------------------------------------------+
FeatureWAFShield StandardShield AdvancedFirewall Manager
Protection TypeWeb exploitsDDoSDDoS + SupportCentral management
CostPer rule + requestFree$3,000/monthBased on policies
LayerLayer 7Layer 3/4Layer 3/4/7Management
ScopeWeb appsAll AWSProtected resourcesOrganization-wide

AWS WAF Architecture
+------------------------------------------------------------------+
| |
| Internet |
| | |
| v |
| +----------------+ |
| | CloudFront | |
| | or ALB | |
| +----------------+ |
| | |
| v |
| +----------------+ |
| | AWS WAF | |
| +----------------+ |
| | |
| +-------------------+-------------------+ |
| | | | |
| v v v |
| +----------+ +----------+ +----------+ |
| | Web ACL | | Rule | | IP Set | |
| | | | Groups | | | |
| | - Default| | | | - Allow | |
| | Action | | - Managed| | - Block | |
| | - Rules | | - Custom | | Lists | |
| +----------+ +----------+ +----------+ |
| |
+------------------------------------------------------------------+
WAF Components
+------------------------------------------------------------------+
| |
| Web ACL (Access Control List) |
| +------------------------------------------------------------+ |
| | - Central resource for WAF configuration | |
| | - Contains rules and rule groups | |
| | - Has default action (allow or block) | |
| | - Associated with CloudFront, ALB, or API Gateway | |
| +------------------------------------------------------------+ |
| |
| Rules |
| +------------------------------------------------------------+ |
| | - Define matching criteria and actions | |
| | - Can be custom or managed | |
| | - Actions: Allow, Block, Count, Captcha | |
| +------------------------------------------------------------+ |
| |
| Rule Groups |
| +------------------------------------------------------------+ |
| | - Collection of rules | |
| | - Managed rule groups (AWS, AWS Marketplace) | |
| | - Custom rule groups | |
| +------------------------------------------------------------+ |
| |
| IP Sets |
| +------------------------------------------------------------+ |
| | - List of IP addresses/ranges | |
| | - Used for allow/block lists | |
| | - Up to 10,000 IP addresses per set | |
| +------------------------------------------------------------+ |
| |
| Regex Patterns |
| +------------------------------------------------------------+ |
| | - Regular expression patterns | |
| | - Used for complex matching | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
WAF Rule Types
+------------------------------------------------------------------+
| |
| Managed Rule Groups |
| +------------------------------------------------------------+ |
| | | |
| | AWS Managed Rules: | |
| | +------------------------------------------------------+ | |
| | | - AWSManagedRulesCommonRuleSet (Core rule set) | | |
| | | - AWSManagedRulesAnonymousIpList (Anonymous IP) | | |
| | | - AWSManagedRulesSQLiRuleSet (SQL injection) | | |
| | | - AWSManagedRulesLinuxRuleSet (Linux specific) | | |
| | | - AWSManagedRulesUnixRuleSet (Unix specific) | | |
| | | - AWSManagedRulesWindowsRuleSet (Windows specific) | | |
| | +------------------------------------------------------+ | |
| | | |
| | Vendor Managed Rules (AWS Marketplace): | |
| | +------------------------------------------------------+ | |
| | | - Fortinet, Imperva, Trend Micro, etc. | | |
| | +------------------------------------------------------+ | |
| | | |
| +------------------------------------------------------------+ |
| |
| Custom Rules |
| +------------------------------------------------------------+ |
| | | |
| | Rate-based Rules: | |
| | +------------------------------------------------------+ | |
| | | - Limit requests from IP address | | |
| | | - Configurable rate (100-2,000,000 requests/5min) | | |
| | +------------------------------------------------------+ | |
| | | |
| | Regular Rules: | |
| | +------------------------------------------------------+ | |
| | | - IP match (IP sets) | | |
| | | - Geographic match (country codes) | | |
| | | - String match (query string, headers, body) | | |
| | | - Regex match (pattern matching) | | |
| | | - Size constraint (request size) | | |
| | | - SQL injection match | | |
| | | - XSS match | | |
| | +------------------------------------------------------+ | |
| | | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
WAF Rule Evaluation Flow
+------------------------------------------------------------------+
| |
| Incoming Request |
| | |
| v |
| +------------------------+ |
| | Check Web ACL Rules | |
| +------------------------+ |
| | |
| +------------------+------------------+ |
| | | | |
| v v v |
| +--------+ +--------+ +--------+ |
| | Rule 1 | | Rule 2 | | Rule N | |
| | Match? | | Match? | | Match? | |
| +--------+ +--------+ +--------+ |
| | | | |
| v v v |
| +--------+ +--------+ +--------+ |
| | Action | | Action | | Action | |
| +--------+ +--------+ +--------+ |
| | | | |
| +------------------+------------------+ |
| | |
| v |
| +------------------------+ |
| | Any Block Action? | |
| +------------------------+ |
| | | |
| Yes No |
| | | |
| v v |
| +----------+ +------------------+ |
| | BLOCK | | Default Action | |
| | (403) | | (Allow/Block) | |
| +----------+ +------------------+ |
| |
+------------------------------------------------------------------+
Terminal window
# Create IP set
aws wafv2 create-ip-set \
--name "BlockedIPs" \
--scope REGIONAL \
--ip-address-version IPV4 \
--addresses "192.0.2.0/24" "203.0.113.0/24"
# Create web ACL
aws wafv2 create-web-acl \
--name "MyWebACL" \
--scope REGIONAL \
--default-action Allow={} \
--rules file://rules.json
# List web ACLs
aws wafv2 list-web-acls \
--scope REGIONAL
# Get web ACL
aws wafv2 get-web-acl \
--name "MyWebACL" \
--scope REGIONAL \
--id "abc123"
# Associate web ACL with ALB
aws wafv2 associate-web-acl \
--web-acl-arn "arn:aws:wafv2:..." \
--resource-arn "arn:aws:elasticloadbalancing:..."
# Create rule group
aws wafv2 create-rule-group \
--name "MyRuleGroup" \
--scope REGIONAL \
--capacity 500

AWS Shield Overview
+------------------------------------------------------------------+
| |
| +------------------------+ |
| | AWS Shield | |
| +------------------------+ |
| | |
| +---------------------+---------------------+ |
| | | |
| v v |
| +----------+ +----------+ |
| | Shield | | Shield | |
| | Standard | | Advanced | |
| | | | | |
| | - FREE | | - $3,000/mo| |
| | - Layer | | - Layer | |
| | 3/4 | | 3/4/7 | |
| | - Auto | | - DDoS | |
| | Enabled| | Response| |
| +----------+ | - Support| |
| +----------+ |
| |
+------------------------------------------------------------------+
Shield Standard vs Advanced
+------------------------------------------------------------------+
| |
| Feature | Standard | Advanced |
| -----------------------|-----------------|---------------------- |
| Cost | FREE | $3,000/month + usage |
| Layer 3/4 Protection | Yes | Yes |
| Layer 7 Protection | No | Yes (with WAF) |
| DDoS Response Team | No | Yes (24/7) |
| Cost Protection | No | Yes |
| Visibility | Basic | Advanced |
| Proactive Engagement | No | Yes |
| Auto Enrollment | Yes (all AWS) | Manual |
| |
+------------------------------------------------------------------+
Shield Advanced Architecture
+------------------------------------------------------------------+
| |
| Internet |
| | |
| v |
| +----------------+ |
| | AWS Shield | |
| | Advanced | |
| +----------------+ |
| | |
| +-------------------+-------------------+ |
| | | | |
| v v v |
| +----------+ +----------+ +----------+ |
| |CloudFront| | ALB | | Route 53 | |
| +----------+ +----------+ +----------+ |
| | | | |
| +-------------------+-------------------+ |
| | |
| v |
| +----------------+ |
| | DDoS Response | |
| | Team (DRT) | |
| +----------------+ |
| | |
| v |
| +----------------+ |
| | AWS Support | |
| | Center | |
| +----------------+ |
| |
+------------------------------------------------------------------+
Shield Advanced Protected Resources
+------------------------------------------------------------------+
| |
| Supported Resources |
| +------------------------------------------------------------+ |
| | | |
| | +------------------+ +------------------+ | |
| | | Amazon CloudFront| | Route 53 | | |
| | | (Global) | | (Global) | | |
| | +------------------+ +------------------+ | |
| | | |
| | +------------------+ +------------------+ | |
| | | Application Load | | Global Accelerator| | |
| | | Balancer | | | | |
| | +------------------+ +------------------+ | |
| | | |
| | +------------------+ +------------------+ | |
| | | Network Load | | AWS Elastic IP | | |
| | | Balancer | | | | |
| | +------------------+ +------------------+ | |
| | | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
Terminal window
# Create protection (Shield Advanced)
aws shield create-protection \
--name "MyProtection" \
--resource-arn "arn:aws:cloudfront::..."
# List protections
aws shield list-protections
# Describe protection
aws shield describe-protection \
--protection-id "abc123"
# Describe DDoS attack
aws shield describe-attack \
--attack-id "attack-123"
# List attacks
aws shield list-attacks \
--start-time From=2024-01-01T00:00:00Z,To=2024-01-31T23:59:59Z
# Engage DRT (DDoS Response Team)
aws shield create-drt-access \
--role-arn "arn:aws:iam::..." \
--log-s3-bucket "my-ddos-logs"

AWS Firewall Manager Architecture
+------------------------------------------------------------------+
| |
| +------------------------+ |
| | Firewall Manager | |
| +------------------------+ |
| | |
| +---------------------+---------------------+ |
| | | | |
| v v v |
| +----------+ +----------+ +----------+ |
| | WAF | | Shield | | Security | |
| | Policies | | Advanced | | Groups | |
| | | | Policies | | | |
| +----------+ +----------+ +----------+ |
| | | | |
| v v v |
| +----------+ +----------+ +----------+ |
| | Apply to | | Apply to | | Apply to | |
| | All | | Protected| | VPCs | |
| | Accounts | | Resources| | | |
| +----------+ +----------+ +----------+ |
| |
+------------------------------------------------------------------+
Firewall Manager Policy Types
+------------------------------------------------------------------+
| |
| WAF Policy |
| +------------------------------------------------------------+ |
| | - Deploy WAF rules across accounts | |
| | - Ensure consistent web protection | |
| | - Automatic remediation of non-compliant resources | |
| +------------------------------------------------------------+ |
| |
| Shield Advanced Policy |
| +------------------------------------------------------------+ |
| | - Auto-enroll resources in Shield Advanced | |
| | - Apply protection to new resources | |
| | - Ensure DDoS protection across organization | |
| +------------------------------------------------------------+ |
| |
| Security Group Policy |
| +------------------------------------------------------------+ |
| | - Manage security groups across accounts | |
| | - Enforce common security group rules | |
| | - Audit and remediate non-compliant rules | |
| +------------------------------------------------------------+ |
| |
| Network Firewall Policy |
| +------------------------------------------------------------+ |
| | - Deploy AWS Network Firewall rules | |
| | - Centralized network traffic inspection | |
| | - Intrusion prevention and detection | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
Firewall Manager Policy Workflow
+------------------------------------------------------------------+
| |
| 1. Create Policy |
| +------------------------------------------------------------+ |
| | - Define policy type (WAF, Shield, Security Group) | |
| | - Configure rules and settings | |
| | - Set remediation action | |
| +------------------------------------------------------------+ |
| | |
| v |
| 2. Define Scope |
| +------------------------------------------------------------+ |
| | - Select accounts (all or specific) | |
| | - Select resources (by tags or types) | |
| | - Exclude specific resources | |
| +------------------------------------------------------------+ |
| | |
| v |
| 3. Apply Policy |
| +------------------------------------------------------------+ |
| | - Automatic deployment to matching resources | |
| | - Continuous compliance monitoring | |
| | - Automatic remediation of violations | |
| +------------------------------------------------------------+ |
| | |
| v |
| 4. Monitor and Audit |
| +------------------------------------------------------------+ |
| | - View compliance status | |
| | - Review violations | |
| | - Update policy as needed | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+

AWS Network Firewall Architecture
+------------------------------------------------------------------+
| |
| Internet |
| | |
| v |
| +----------------+ |
| | Internet | |
| | Gateway | |
| +----------------+ |
| | |
| v |
| +----------------+ |
| | Network | |
| | Firewall | |
| | Endpoint | |
| +----------------+ |
| | |
| +-------------------+-------------------+ |
| | | |
| v v |
| +----------+ +----------+ |
| | Public | | Private | |
| | Subnets | | Subnets | |
| +----------+ +----------+ |
| |
+------------------------------------------------------------------+
Network Firewall Components
+------------------------------------------------------------------+
| |
| Firewall Policy |
| +------------------------------------------------------------+ |
| | - Collection of rule groups | |
| | - Stateless and stateful rule groups | |
| | - Default actions | |
| +------------------------------------------------------------+ |
| |
| Rule Groups |
| +------------------------------------------------------------+ |
| | | |
| | Stateless Rule Groups: | |
| | +------------------------------------------------------+ | |
| | | - Process first, before stateful rules | | |
| | | - Use 5-tuple matching (src, dst, port, protocol) | | |
| | | - Actions: Pass, Drop, Forward to stateful | | |
| | +------------------------------------------------------+ | |
| | | |
| | Stateful Rule Groups: | |
| | +------------------------------------------------------+ | |
| | | - Deep packet inspection | | |
| | | - Suricata-compatible rules | | |
| | | - Domain list filtering | | |
| | | - Intrusion prevention (IPS) | | |
| | +------------------------------------------------------+ | |
| | | |
| +------------------------------------------------------------+ |
| |
| Firewall Endpoint |
| +------------------------------------------------------------+ |
| | - Deployed in subnet | |
| | - Processes traffic | |
| | - Scales automatically | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+

WAF Security Best Practices
+------------------------------------------------------------------+
| |
| 1. Start with managed rule groups |
| +------------------------------------------------------------+ |
| | - Use AWS managed rules as baseline | |
| | - Add custom rules for specific needs | |
| +------------------------------------------------------------+ |
| |
| 2. Use COUNT mode for testing |
| +------------------------------------------------------------+ |
| | - Test rules in COUNT mode first | |
| | - Analyze logs before blocking | |
| | - Switch to BLOCK after validation | |
| +------------------------------------------------------------+ |
| |
| 3. Implement rate limiting |
| +------------------------------------------------------------+ |
| | - Protect against brute force attacks | |
| | - Set appropriate thresholds | |
| +------------------------------------------------------------+ |
| |
| 4. Enable logging |
| +------------------------------------------------------------+ |
| | - Send logs to S3, CloudWatch, or Kinesis | |
| | - Analyze for threats and tuning | |
| +------------------------------------------------------------+ |
| |
| 5. Use CAPTCHA for suspicious requests |
| +------------------------------------------------------------+ |
| | - Challenge suspicious traffic | |
| | - Reduce false positives | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
Shield Best Practices
+------------------------------------------------------------------+
| |
| 1. Enable Shield Advanced for critical applications |
| +------------------------------------------------------------+ |
| | - Get 24/7 DDoS response team support | |
| | - Protect against large-scale attacks | |
| +------------------------------------------------------------+ |
| |
| 2. Configure proactive engagement |
| +------------------------------------------------------------+ |
| | - DRT can respond during attacks | |
| | - Enable access to your environment | |
| +------------------------------------------------------------+ |
| |
| 3. Set up health checks |
| +------------------------------------------------------------+ |
| | - Route 53 health checks for automatic failover | |
| | - CloudWatch alarms for monitoring | |
| +------------------------------------------------------------+ |
| |
| 4. Enable DDoS detection metrics |
| +------------------------------------------------------------+ |
| | - Monitor DDoSAttackIO and DDoSAttackPackets | |
| | - Set up alerts for attack detection | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+

Integrated Security Architecture
+------------------------------------------------------------------+
| |
| Internet |
| | |
| v |
| +----------------+ |
| | AWS Shield | |
| | Standard | |
| | (Layer 3/4) | |
| +----------------+ |
| | |
| v |
| +----------------+ |
| | CloudFront | |
| | Distribution | |
| +----------------+ |
| | |
| v |
| +----------------+ |
| | AWS WAF | |
| | (Layer 7) | |
| +----------------+ |
| | |
| v |
| +----------------+ |
| | Application | |
| | Load Balancer | |
| +----------------+ |
| | |
| v |
| +----------------+ |
| | EC2 / ECS / | |
| | Lambda | |
| +----------------+ |
| |
+------------------------------------------------------------------+

Common WAF Issues
+------------------------------------------------------------------+
| |
| Issue 1: Legitimate traffic being blocked |
| +------------------------------------------------------------+ |
| | Cause: Overly restrictive rules | |
| | Solution: Use COUNT mode to test, adjust rules | |
| +------------------------------------------------------------+ |
| |
| Issue 2: WAF not blocking expected traffic |
| +------------------------------------------------------------+ |
| | Cause: Rule order or default action misconfigured | |
| | Solution: Check rule priority and default action | |
| +------------------------------------------------------------+ |
| |
| Issue 3: High latency after WAF deployment |
| +------------------------------------------------------------+ |
| | Cause: Too many rules or complex regex patterns | |
| | Solution: Optimize rules, use simpler patterns | |
| +------------------------------------------------------------+ |
| |
| Issue 4: Shield Advanced not protecting resources |
| +------------------------------------------------------------+ |
| | Cause: Resources not enrolled in protection | |
| | Solution: Create protection for each resource | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+

Exam Tip

Key Exam Points
+------------------------------------------------------------------+
| |
| 1. WAF operates at Layer 7 (Application layer) |
| |
| 2. Shield Standard is FREE and automatically enabled |
| |
| 3. Shield Advanced costs $3,000/month + includes DRT support |
| |
| 4. WAF can be attached to CloudFront, ALB, and API Gateway |
| |
| 5. Managed rule groups provide pre-configured protection |
| |
| 6. Rate-based rules limit requests per IP address |
| |
| 7. Firewall Manager centralizes security policy management |
| |
| 8. Network Firewall provides VPC-level protection |
| |
| 9. WAF default action determines behavior when no rules match |
| |
| 10. Use COUNT mode to test rules before blocking |
| |
+------------------------------------------------------------------+

Chapter 28 Summary
+------------------------------------------------------------------+
| |
| AWS WAF |
| +------------------------------------------------------------+ |
| | - Web Application Firewall for Layer 7 protection | |
| | - Managed and custom rules | |
| | - IP sets, regex patterns, rate limiting | |
| | - Actions: Allow, Block, Count, Captcha | |
| +------------------------------------------------------------+ |
| |
| AWS Shield |
| +------------------------------------------------------------+ |
| | - Standard: Free, Layer 3/4, auto-enabled | |
| | - Advanced: $3,000/mo, Layer 3/4/7, DRT support | |
| | - DDoS protection for all AWS services | |
| +------------------------------------------------------------+ |
| |
| AWS Firewall Manager |
| +------------------------------------------------------------+ |
| | - Centralized security policy management | |
| | - Works with WAF, Shield, Security Groups | |
| | - Organization-wide deployment | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+

Previous Chapter: Chapter 27: AWS KMS, Secrets Manager & Parameter Store Next Chapter: Chapter 29: AWS Security Hub & Detective