AWS Security Interview Questions and Answers
aws security interview questions and answers
π‘οΈ AWS WAF β Complete Interview & Implementation Guide for AWS Cloud and DevOps Engineer
Ans: AWS WAF (Web Application Firewall) is a managed firewall service that helps protect web applications from common web exploits and bots that may affect availability, compromise security, or consume excessive resources.
Key components:
- Web ACL (Access Control List) β The top-level container that holds rules and is associated with a resource.
- Rules β Conditions that inspect requests (IP, header, body, URI, query string, etc.).
- Rule Groups β Reusable collections of rules.
- Actions β
Allow,Block,Count,CAPTCHA,Challenge.
Supported resources to protect:
- Application Load Balancer (ALB)
- Amazon CloudFront
- Amazon API Gateway (REST API)
- AWS AppSync (GraphQL API)
- Amazon Cognito User Pool
- AWS App Runner service
Ans:
Use AWS Managed Rules β Enable the
AWSManagedRulesSQLiRuleSetrule group. It detects patterns like' OR 1=1,UNION SELECT,DROP TABLE, etc.Create a Custom Rule for targeted protection on
/loginpath:- Inspect:
URI pathcontains/loginANDBodycontains SQL patterns - Action: Block
- Inspect:
Enable body inspection β Ensure the Web ACL has body size limit configured (default is 8 KB, can be raised to 64 KB).
Start with Count mode before switching to Block β This avoids false positives during testing.
Enable WAF logging to S3/CloudWatch to monitor blocked requests.
Rule Priority (recommended order):
1. IP Allow-list (whitelist your admin IPs) β Allow
2. Rate-based rule (prevent brute force) β Block
3. AWS SQLi Managed Rule Group β Block
4. Custom SQL rule on /login endpoint β Block
5. Default action β Allow
Ans:
Rate-Based Rule in WAF:
- Aggregate by
IP address - Set threshold: e.g.,
2000 requests per 5-minute window - Action:
Block(auto-unblocks when rate drops)
- Aggregate by
AWS Shield Advanced β For volumetric DDoS (Layer 3/4), WAF alone isn’t enough. Shield Advanced handles SYN floods, UDP floods at network layer.
CloudFront in front of ALB β Absorbs global traffic, applies geo-restriction, reduces origin load.
Scope-down statement β Narrow rate-based rules to specific URIs:
Rate-based rule: Scope-down: URI path starts with /api/checkout Threshold: 100 per 5 minutes per IP Action: BlockDynamic IP blocking via Lambda β Parse WAF logs in near real-time; add aggressive IPs to an IP set and update the WAF rule automatically.
Ans:
Create a Geo-Match Rule in WAF:
- Match condition:
Originates from a countryNOT IN[IN, US] - Action:
Block
- Match condition:
Rule configuration:
Rule type: Regular rule Statement: Geographic match Country codes: NOT IN β IN (India), US (United States) Action: BlockAlternative using CloudFront β CloudFront also has built-in geo-restriction under Distribution β Security β Restrictions but WAF gives more granular control (you can combine geo + other conditions).
Edge case: VPN users can bypass geo-blocking. To handle:
- Enable AWS WAF Bot Control which can identify VPN/proxy traffic.
- Or integrate with a third-party IP reputation list.
Caveat: Geo-match is based on IP geolocation, not the user’s actual location. Accuracy is ~99% for country-level.
Ans:
Enable AWS WAF Bot Control Managed Rule Group:
CommonBotControlβ blocks known bots (scrapers, crawlers), allows verified bots (Googlebot).TargetedBotControlβ more advanced detection (TGT_VolumetricIpTokenAbsent, etc.)
CAPTCHA action β For suspected bots (not verified bad bots), use
CAPTCHAaction instead of Block to challenge users.Challenge action β Silent browser challenge (JavaScript challenge) to verify the client is a real browser.
Rate-based rule per IP β Add a secondary layer: if same IP hits
/productsmore than 500 times/5min β Block.Custom rules using request fingerprinting:
- Block requests without
User-Agentheader - Block requests with known scraping tool signatures (
python-requests,scrapy,curl)
Rule: Header "user-agent" contains "python-requests" β Block- Block requests without
robots.txt β Not a WAF feature, but complement WAF by defining scraping rules for good bots.
Ans:
| OWASP Threat | WAF Managed Rule Group |
|---|---|
| SQL Injection (A03) | AWSManagedRulesSQLiRuleSet |
| XSS - Cross-Site Scripting (A03) | AWSManagedRulesKnownBadInputsRuleSet |
| Command Injection (A03) | AWSManagedRulesLinuxRuleSet, AWSManagedRulesUnixRuleSet |
| Log4Shell / Known exploits (A06) | AWSManagedRulesKnownBadInputsRuleSet |
| Broken Access Control (A01) | Custom rules + Shield |
| Security Misconfiguration (A05) | AWSManagedRulesCommonRuleSet |
| SSRF (A10) | Custom rules on internal IPs |
Step-by-step:
- Enable
AWSManagedRulesCommonRuleSet(CRS) β covers a broad range of OWASP threats. - Add domain-specific rule sets (Linux, Windows, PHP, WordPress as applicable).
- Set all groups to Count mode first, review false positives.
- Switch to Block mode after tuning.
- Enable WAF logging to S3, then use Athena to query blocked requests.
- Set up CloudWatch alarms on
BlockedRequestsmetric.
Ans:
Immediate: AWS released an emergency managed rule update for Log4Shell within hours. Enable:
AWSManagedRulesKnownBadInputsRuleSetβ includesLog4JRCE_HEADERandLog4JRCE_BODYrules.
Custom rule for defense-in-depth:
Inspect: All headers + body + URI Match: Contains "${jndi:" Action: BlockCount first, switch to Block β Even in an emergency, briefly run in Count (5-10 min) to confirm the rule triggers correctly and assess false positive rate.
Scope: If only certain endpoints are vulnerable, scope the rule to those endpoints only to reduce false positive risk.
Monitor CloudWatch β Set alarm if
CountedRequestsfor the emergency rule spikes, which means active exploitation attempts.Communicate: WAF is a virtual patch (temporary), not a fix. Coordinate with dev team to patch the actual dependency.
Ans:
AWS WAF auto-decodes common encoding types before matching:
- URL decoding
- HTML entity decoding
- Lowercase transformation
- Command line transformation But only if you configure text transformations in your rules.
Add transformations in custom rules:
Transformations (apply in order): 1. URL_DECODE 2. HTML_ENTITY_DECODE 3. LOWERCASE 4. COMPRESS_WHITE_SPACEStack multiple transformations β WAF applies them in sequence before matching, catching double-encoded payloads.
Use managed rules β AWS keeps managed rule groups updated against known bypass techniques.
Payload obfuscation examples WAF handles:
%27 OR %271%27%3D%271β decoded to' OR '1'='1' OR 1=1β HTML entity decodedSeLeCt * FrOmβ lowercased toselect * from
For Base64 bypass β Add a custom rule that base64-decodes the body:
- This requires a Lambda@Edge or custom application-layer check, as WAF doesn’t natively base64-decode arbitrary request bodies.
Ans:
Identify the blocking rule:
- Enable WAF logging β logs show
ruleGroupId,terminatingRuleId, and matchedfieldToMatch. - Query logs in Athena or CloudWatch Logs Insights.
- Enable WAF logging β logs show
Switch to Count mode for the offending rule temporarily to stop the block while investigating.
Analyze the request:
- What field matched? (Header? Body? URI?)
- What was the actual value that triggered the rule?
Options to fix:
- Scope-down statement β Narrow the rule to only apply to specific paths, not the one causing false positives.
- Rule exclusion (Label match exception) β Exclude specific rules within a managed rule group.
- IP allow-list β Add known-good IP ranges (corporate office, CDN IPs) to an IP set with
Allowand place it at the top priority. - Override rule action β Change a specific rule within a managed rule group from
BlocktoCount.
Example β Managed rule false positive fix:
AWSManagedRulesCommonRuleSet β Rule: SizeRestrictions_BODY Problem: Large legitimate file uploads are blocked. Fix: Override SizeRestrictions_BODY to Count, Create a custom rule to block only on /upload-malicious path.
Ans:
AWS Firewall Manager β Central management service for WAF policies across AWS Organizations.
- Define a WAF policy in the Firewall Manager admin account.
- Automatically applies to all accounts/OUs in the organization.
- Ensures new accounts are automatically protected.
Managed rule groups in Firewall Manager policy:
- Baseline rules (common rule set, SQLi, XSS) applied to all.
- BU-specific rules managed locally.
Architecture:
AWS Organizations (Management Account) βββ Firewall Manager Admin Account βββ WAF Policy: Baseline Rules β All OUs βββ WAF Policy: PCI Compliant Rules β Finance OU βββ WAF Policy: HIPAA Rules β Healthcare OUAWS Config β Use Config rules to detect Web ACLs that are not compliant (e.g., missing required rules).
Centralized logging β All WAF logs β central S3 bucket in security account β Athena/Security Lake for analysis.
Ans:
Enable WAF logging:
- Destination options: S3 bucket, CloudWatch Logs, Kinesis Data Firehose
- For long-term retention + querying β use Kinesis Firehose β S3.
S3 bucket configuration:
- Enable S3 Object Lock (WORM) for compliance.
- Set S3 lifecycle policy: Standard β S3 Glacier after 90 days β delete after 365 days.
- Enable S3 server-side encryption (SSE-KMS).
Log filtering β By default, WAF logs ALL requests. To reduce cost, filter to log only:
- Blocked requests
- Requests matching specific rules
CloudWatch Alarms β Alarm on
BlockedRequestsmetric > threshold.Athena queries β Create a table over S3 WAF logs with partitioning by date for cost-effective querying.
Security Lake integration β AWS Security Lake can ingest WAF logs in OCSF format for centralized security analysis.
Ans:
- Rule action β Applied when a request matches a specific rule (
Allow,Block,Count,CAPTCHA,Challenge). - Default action β Applied to requests that don’t match any rule in the Web ACL. Options:
AlloworBlock. - Best practice: Default action should be
Allowif you’re using a blocklist approach (block known bad), orBlockif using an allowlist approach (only allow known good).
Ans:
| Feature | Count | Block |
|---|---|---|
| Stops request? | β No, request passes through | β Yes, returns 403 |
| Increments CloudWatch metric? | β Yes | β Yes |
| Logs the match? | β Yes | β Yes |
| Use case | Testing/monitoring rules | Production enforcement |
Best practice: Always test new rules in Count mode before switching to Block.
Answer: Labels are metadata tags added to requests by WAF rules as they evaluate. Subsequent rules can match on labels added by earlier rules.
Use case example:
Rule 1: If IP is from a Tor exit node β Add label "network:tor"
Rule 2: If label "network:tor" exists AND URI contains "/admin" β Block
This enables chained/contextual rule logic without complex AND conditions in a single rule.
Ans: A scope-down statement narrows the set of requests that a rate-based rule applies to.
Example: Rate-limit only login attempts, not all traffic:
Rate-based rule:
Scope-down: URI path = /api/login
Aggregate by: IP
Threshold: 10 requests / 5 minutes
Action: Block
Without scope-down, the rate limit counts ALL requests from an IP. With scope-down, it only counts requests to /api/login.
Ans:
- Regular rules β Match conditions evaluated as true/false. If match β apply action.
- Rate-based rules β Track request rate per IP (or other dimension). If threshold exceeded β apply action. Auto-resets when rate drops.
- Rule groups β Containers of multiple rules. Can be:
- Managed rule groups (AWS or Marketplace)
- Custom rule groups (your own)
Q: What are the inspectable components of an HTTP request in WAF?
Answer: WAF can inspect any of the following:
- URI path β
/api/v1/users - Query string β
?id=1&name=test - HTTP method β GET, POST, PUT, DELETE
- Headers β Specific headers or all headers
- Cookies β Specific cookies or all
- Body β Raw body (first 8 KB by default, up to 64 KB)
- Source IP β Origin IP address
- JSON body β Parse and inspect JSON keys/values
- HTTP version
Answer:
| Rule Group | Protection |
|---|---|
AWSManagedRulesCommonRuleSet | General OWASP threats, core rule set |
AWSManagedRulesSQLiRuleSet | SQL injection patterns |
AWSManagedRulesKnownBadInputsRuleSet | Log4Shell, SSRF, path traversal |
AWSManagedRulesLinuxRuleSet | Linux-specific exploits |
AWSManagedRulesWindowsRuleSet | Windows/PowerShell exploits |
AWSManagedRulesPHPRuleSet | PHP-specific attacks |
AWSManagedRulesWordPressRuleSet | WordPress vulnerabilities |
AWSManagedRulesAmazonIpReputationList | Known malicious IPs (botnets, scanners) |
AWSManagedRulesBotControlRuleSet | Bot detection & management |
Each rule group consumes WCU (WAF Capacity Units). A Web ACL has a maximum of 5000 WCU.
Answer:
| Feature | AWS WAF | AWS Shield |
|---|---|---|
| Layer | Layer 7 (Application) | Layer 3/4 (Network/Transport) |
| Protects against | SQLi, XSS, bots, OWASP | DDoS β SYN floods, UDP floods, volumetric |
| Pricing | Pay per Web ACL, rule, request | Shield Standard: Free; Shield Advanced: $3,000/month |
| Configuration | Rules-based (user-defined) | Automatic |
| Works with | ALB, CloudFront, API GW | CloudFront, ALB, EC2, Route 53 |
Best practice: Use WAF + Shield Advanced together for comprehensive protection.
Ans: Partially. WAF can mitigate Layer 7 DDoS (application-layer floods) using:
- Rate-based rules (block IPs exceeding request threshold)
- Bot Control (identify and block automated traffic)
However, WAF cannot protect against Layer 3/4 DDoS (network floods). For that, use:
- AWS Shield Standard (free, always on)
- AWS Shield Advanced (paid, with DDoS response team)
Ans:
The CAPTCHA action presents an AWS-managed CAPTCHA puzzle to the user. If passed, WAF allows the request. If failed, it’s blocked.
Use cases:
- Suspected bot traffic that might be legitimate users (gray area bots)
- Login pages to prevent credential stuffing
- Form submission pages to prevent spam
How it works:
- WAF intercepts the request.
- Returns a 405 response with a CAPTCHA challenge page.
- User solves CAPTCHA β receives a token.
- Subsequent requests carry the token β WAF allows them (token valid for a configurable time).
Challenge vs CAPTCHA:
Challengeβ Silent JavaScript browser challenge (no user interaction, detects headless browsers)CAPTCHAβ Visible puzzle requiring user interaction
Ans: WCU measures the processing cost of a Web ACL’s rules. Each rule type consumes a different amount of WCU:
| Rule Type | WCU Cost |
|---|---|
| IP set match | 1 WCU |
| String match (exact) | 2 WCU |
| String match (contains) | 10 WCU |
| Regex match | 3β25 WCU |
| Rate-based rule | 2 WCU + scope-down WCU |
| Managed rule group | Varies (e.g., CommonRuleSet = 700 WCU) |
Maximum per Web ACL: 5000 WCU. Exceeding this limit requires removing or optimizing rules.
Ans: WAF inspects decrypted HTTP traffic after TLS termination. The TLS termination happens at:
- ALB β Terminates TLS, then WAF inspects plaintext HTTP.
- CloudFront β Terminates TLS at the edge, then WAF inspects before forwarding to origin.
WAF does not decrypt traffic itself. It relies on the associated service (ALB/CloudFront) to handle TLS.
Add More Questions to This Guide
Know questions that should be here? Share them and help the community!
Open Google Form