![[Report] I Attended the Session on Controlling Communications by Adding WAF / Network Firewall to AgentCore #AWSreInvent #SEC352](https://devio2024-media.developers.io/image/upload/f_auto,q_auto/c_limit,w_1200/v1796065673/eyecatch/xw5jr5b9agc6qjxlknmg.png)
[Report] I Attended the Session on Controlling Communications by Adding WAF / Network Firewall to AgentCore #AWSreInvent #SEC352
This page has been translated by machine translation. View original
Introduction
Hello, this is watabo from Classmethod Operations.
At AWS re:Invent 2026, I attended a builders session titled "Build a security boundary for AI agents with WAF and Network Firewall".
In this session, we tried out controlling callers and controlling destinations hands-on.
The scenario used an AI agent exposed on the internet. You identify who is calling the published URL (ingress) and what the AI agent is calling (egress), then block unnecessary traffic.
Session Overview
The title is "[SEC352-R] Build a security boundary for AI agents with WAF and Network Firewall".
Teams deploying AI agents inherit two exposures. Any client reaching the endpoint can invoke the agent, and it can reach any destination its tools name.
When you deploy an AI agent, you take on two exposures.
Any client that can reach the endpoint can invoke the agent, and the agent can reach any destination that its tools specify.
I ran out of time, so I was unable to try Lab 4, which blocks egress traffic.
The results of the commands up to that point were all the same as the expected results in the workshop instructions.
Session Content
The Two Boundaries and the Architecture
I can't use the official diagram, so here is a drawio architecture diagram instead.

The ingress Amazon Bedrock AgentCore Gateway is a managed entry point for invoking agents and tools.
In this lab, behind this Gateway was an AgentCore Runtime agent running in a VPC.
The Gateway's authorization is IAM.
An AWS WAF Web ACL is associated with the Gateway.
The Web ACL has the following 3 rules, evaluated in ascending order of priority number.
| Priority | Rule | Role |
|---|---|---|
| 1 | KnownBadInputs | AWS managed rule that blocks known attack patterns |
| 10 | BotControlCommon | Runs Bot Control in Count mode and adds labels |
| 20 | NetperimIngressRules | Custom rule group that looks at the labels and decides how to handle requests |
AWS WAF Bot Control is a managed rule group that identifies the type of client that sent a request.
Because Count mode does not stop requests, the role of describing the caller and the role of deciding how to handle it are separated.
On the egress side, the agent's internet-bound traffic passes through AWS Network Firewall before going out through the NAT gateway.
Calling with 5 Types of Clients
First, from CloudShell, I called the Gateway as 5 types of clients that differed only in their User-Agent.
The 5 were curl, python-requests, GPTBot, ClaudeBot, and PerplexityBot.
Because the Gateway uses IAM authorization, I attached a SigV4 signature with curl.
The following is an excerpt of the key points.
# Load CloudShell's temporary credentials into environment variables
eval "$(aws configure export-credentials --format env)"
# Replace the User-Agent with -A and call with a signature
curl -s -w '%{http_code}' \
-A "python-requests/2.32.3" \
--aws-sigv4 "aws:amz:${AWS_DEFAULT_REGION}:bedrock-agentcore" \
--user "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}" \
-H "x-amz-security-token: ${AWS_SESSION_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"prompt": "fetch example.com"}' "$GATEWAY_URL"
In the Count mode state, all 5 requests reached the agent with HTTP 200.
Reading What WAF Saw
A 200 response alone doesn't tell you what WAF saw.
There are two places to check: Sampled requests and the WAF logs.
Sampled requests show which rule matched, but they don't display labels.
To read the labels, search the WAF logs in CloudWatch Logs.
filter @message like /bot-control:bot:category/
| parse @message /bot-control:bot:category:(?<category>[a-z_]+)/
| parse @message /bot-control:bot:name:(?<bot_name>[a-z0-9_]+)/
| display @timestamp, action, terminatingRuleId, category, bot_name
| sort @timestamp desc
| limit 20
The 5 requests were classified into 2 categories.
| Caller | category | bot_name |
|---|---|---|
| curl | http_library | curl |
| python-requests | http_library | python_requests |
| GPTBot | ai | gptbot |
| ClaudeBot | ai | claudebot |
| PerplexityBot | ai | perplexitybot |
The following labels are attached to the curl request.
| Label | Meaning |
|---|---|
bot:category:http_library |
Type of client |
bot:name:curl |
Client name |
bot:unverified |
Cannot confirm that the client is what it claims to be |
CategoryHttpLibrary |
Name of the matched Bot Control rule |
token:absent |
No WAF token |
captcha:absent |
No CAPTCHA response |
The fact that bot:unverified is attached to all 5 requests is the key to the next control.
Another thing I noticed is that Count rules inside a rule group do not appear in Sampled requests.
Check the count with the CloudWatch CountedRequests metric.
The custom rule that was initially provided only counted the http_library label.

Blocking Only Unverified AI Crawlers
I rewrote this rule as BlockUnverifiedAiCrawlers.
It blocks only requests that have both an AI category label and the unverified label.
{
"Statement": {
"AndStatement": {
"Statements": [
{ "LabelMatchStatement": { "Scope": "LABEL",
"Key": "awswaf:managed:aws:bot-control:bot:category:ai" } },
{ "LabelMatchStatement": { "Scope": "LABEL",
"Key": "awswaf:managed:aws:bot-control:bot:unverified" } }
]
}
},
"Action": { "Block": {} }
}
When updating with the CLI's update-rule-group, the rules you send replace all existing rules.
If you send it without including the rules you want to keep, they will be deleted, so be careful.
Until you get used to it, it is better to change the rules from the console.

The result of calling the 5 clients again was as follows.
curl HTTP 200 ALLOWED
python-requests HTTP 200 ALLOWED
GPTBot HTTP 403 Request blocked by WAF
ClaudeBot HTTP 403 Request blocked by WAF
PerplexityBot HTTP 403 Request blocked by WAF
Crawlers are rejected by WAF in front of the Gateway, so the agent does not start.
As a result, neither the agent's execution cost nor outbound traffic is incurred.
In the AI traffic screen of AWS WAF, I could see a list of bot names, organizations, and categories.

On my screen, the request counts were 2, 2, and 1, for a total of 5.
The instructions said 6, but I haven't confirmed the reason for the difference.
The calls this time were nothing more than curl with the User-Agent replaced.
Anyone can claim a crawler name, so the condition is based on whether it could be verified, not on the name.
On the other hand, clients that don't announce a bot name pass through this rule.
The instructions explained that for bots that hide their identity, you use Bot Control's Targeted protection level.
As for blocking granularity, besides category, you can also choose an organization such as bot:organization:openai or a name such as bot:name:gptbot.
Egress Stops at Observing Categories
On the egress side, the destination's content category is checked from the TLS SNI or the HTTP Host header.
Decrypting the traffic is not required.
The rule that alerts on the AI and machine learning category is the following single line.
alert tls $HOME_NET any -> $EXTERNAL_NET any (aws_domain_category:Artificial Intelligence and Machine Learning; flow:to_server; msg:"AI/ML domain category detected"; sid:202609184; rev:1;)
This firewall uses strict rule-order evaluation, so evaluation ends at the matching pass rule.
To raise an alert, this rule must be placed above the pass rules.

When I checked the alert log, chat.openai.com had 2 categories attached: Social Networking and Artificial Intelligence and Machine Learning.
The fact that one destination can have multiple categories needs to be taken into account when writing block rules.
WAF at ingress can stop requests before the agent starts.
On the other hand, the egress firewall sees the traffic only after the agent has run, so even if it rejects the traffic here, one execution still occurs.
By the way, I heard from an AWS SA that this environment was built with Network Firewall v2.
In November 2026, a next-generation firewall policy was announced, but I haven't confirmed how it corresponds to the names v2 and v3.
Conclusion
That was my report on the "Build a security boundary for AI agents with WAF and Network Firewall" session.
It let me experience the order of protecting ingress and egress with separate mechanisms, and observing both before controlling them.
The three points that left an impression on me personally were as follows.
- The order of not blocking right away, but first checking the callers with Count and then deciding
- The idea of basing conditions not on the name claimed in
User-Agent, but on whether the source could be verified - Stopping at the ingress means no agent execution cost is incurred
If you are exposing an AI agent, why not start by observing the callers in Count mode?
I hope this entry helps someone.
References
