The Problem
Many customers use AWS WAF to protect their web applications, and rightly so. WAF is used for filtering malicious traffic, rate-limiting requests, and blocking known attack patterns. It's a critical layer in any defense-in-depth strategy. But when you run a penetration test with AWS Security Agent, the goal is to test your application, not the effectiveness of your WAF. You want Security Agent to reach the application layer so it can identify vulnerabilities in your code, authentication flows, and business logic. This guide walks you through how to configure that access. This is a common failure pattern in Security Agent deployments. The good news: the resolution is straightforward.
The Resolution
Option 1: Custom User-Agent Header
The recommended approach is a custom HTTP User-Agent header that acts as a unique identifier between the Security Agent and your WAF.
How It Works:
- You define a unique User-Agent value
- You configure Security Agent to send this value in the User-Agent header with every request
- You create a WAF rule that allows requests containing this specific header value
- WAF lets Security Agent traffic through alongside your normal legitimate user traffic while continuing to block malicious requests
This pattern is simple, reliable, and requires no IP allowlisting.
Note: This approach works with AWS WAF as well as third-party WAFs Cloudflare, Akamai, Imperva that support header-based inspection rules, verify with your specific provider.
Step 1: Choose Your Custom Header Value
Choose a value that is unique and not easily guessable by an attacker. A straightforward approach: use a date-stamped identifier.
Example: securityagent-0623
Other formats that work fine:
-
secagent-pentest-june2026
-
pentest-bypass-yourcompany-0626
Note: For higher-security environments, a custom header name with a longer secret, combined with HTTPS, would be more robust.
Step 2: Configure in AWS Security Agent
- Open the AWS Security Agent WebApp
- Navigate to your Penetration Test configuration
- Under Penetration testing scope, find the Custom HTTP Headers section
- Add an HTTP header with name:
User-Agent
- Set the value to your chosen string e.g.,
securityagent-0623
Step 3: Create the WAF Allow Rule
In the AWS WAF console or via CloudFormation/Terraform:
- Navigate to your Web ACL to the target URL you are testing
- Create a new rule with the following settings:
- Rule type: Regular rule Rule builder
- Match condition: Matches the statement
- Header field name: User-Agent
- Match type: Contains string
- String to match: Your custom value e.g.,
securityagent-0623
- Set the rule priority: Place it at higher priority lower number than any block or rate-limit rules
Step 4: Enable WAF Logging (Optional) For Debugging
If you run into issues and need to troubleshoot, enable WAF logging:
- Navigate to the AWS WAF Shield Console
- Go to the Logging and metrics tab
- Choose Enable beside the Logging header
- Select CloudWatch Logs log group as the destination
When troubleshooting, check the WAF logs to confirm:
- Are Security Agent requests visible in the logs?
- Is the action ALLOW for those requests?
- Does the User-Agent header contain your expected value?
Option 2: When to Use a VPC
The VPC approach is valid when:
- Your WAF or security solution requires IP-based allow-listing
- You need to pentest private or internal applications not reachable from the internet
How VPC Works with Security Agent
- Configure Security Agent to use a VPC
- All pentest traffic routes through that VPC
- Attach a NAT Gateway with an Elastic IP
- Add that Elastic IP to your WAF allow-list
If your target is publicly resolvable and you're using AWS WAF, the custom header approach is simpler and faster to set up. If you select a VPC in the penetration test configuration, all traffic egresses through the VPC and subnet you chose use this when you need traffic to route through your own network path
Summary
In this blog, we demonstrated two options to allow Security Agent traffic through your WAF: a custom header approach and a VPC-based static IP approach. Both are stable, simple to configure, and let your penetration tests run continuously without reconfiguration.
📢 Published by the ES-TAM-Builder community.
Follow our ES-TAM-Builder Space for more tools, guides, and technical deep-dives from fellow TAMs
Loading article