AWS Builder Center

Configuring AWS WAF to Allow AWS Security Agent Traffic

This guide explains how to configure AWS WAF to allow AWS Security Agent penetration test traffic through to your application layer, addressing a common deployment failure pattern. It covers two approaches: using a custom User-Agent header (recommended) for header-based WAF bypass, and a VPC-based static IP method for environments requiring IP allowlisting or internal application testing.

Co-Author:  Sejal Kotian 

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:

  1. You define a unique User-Agent value
  1. You configure Security Agent to send this value in the User-Agent header with every request
  1. You create a WAF rule that allows requests containing this specific header value
  1. 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

  1. Open the AWS Security Agent WebApp
  1. Navigate to your Penetration Test configuration
  1. Under Penetration testing scope, find the Custom HTTP Headers section
  1. Add an HTTP header with name:  User-Agent 
  1. Set the value to your chosen string e.g.,  securityagent-0623 
  1. Save the configuration


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

  1. Create a new rule with the following settings:
  • Rule type: Regular rule Rule builder
  • Match condition: Matches the statement
  • Inspect: Single header
  • Header field name: User-Agent
  • Match type: Contains string
  • String to match: Your custom value e.g.,  securityagent-0623 
  • Action: ALLOW
  1. 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:
  1. Navigate to the AWS WAF Shield Console
  1. Go to Web ACLs
  1. Select your Web ACL
  1. Go to the Logging and metrics tab
  1. Choose Enable beside the Logging header
  1. Select CloudWatch Logs log group as the destination
  1. Save
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

  1. Configure Security Agent to use a VPC
  1. All pentest traffic routes through that VPC
  1. Attach a NAT Gateway with an Elastic IP
  1. 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
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article