DEV Community

Damien Gallagher
Damien Gallagher

Posted on

AWS WAF AI Security: Protecting MCP, A2A and LLM Endpoints, and What It Costs

TL;DR

  • AWS WAF now has an AI Security managed rule group that recognises LLM, MCP and A2A traffic, blocks malformed MCP/A2A messages, and (optionally) calls Bedrock Guardrails to catch prompt injection and leaked sensitive data.
  • A companion feature, API Portal in API Gateway, discovers AI endpoints (including shadow MCP servers) across an AWS Organization.
  • GA since 23 Nov 2026. AI Security runs in 7 Regions; API Portal in 32. Not available in GovCloud or China.
  • Cost: premium request fee of $5.00 per million inspected requests on top of the $0.60 base fee, plus separate Bedrock charges. Bedrock content-check pricing not stated on the pages I read.
  • My view: turn it on in count mode this week, then flip the four default-block rules on once you have seen your own traffic.

Contents


What launched

On 23 November 2026 AWS announced that AI endpoint discovery and protection are generally available. It was also covered in the 1 December AWS News Blog post on re:Invent security launches, where AWS lists new WAF capabilities for finding LLM, MCP and A2A endpoints. Two pieces matter here:

  • API Portal, a new feature in Amazon API Gateway. It builds an inventory of your APIs and flags which ones are LLM inference, MCP or A2A endpoints.
  • AWS WAF AI Security, a new managed rule group (AWSManagedRulesAISecurityRuleSet) that protects those endpoints.

The AWS Security Blog post also introduces an API Security managed rule group (BOLA, token tampering, credential stuffing, reconnaissance). I am keeping this article on the AI side. API Security is priced as a premium rule group too, so the cost section below covers both.

Item Detail Source
Status Generally available What's New, 23 Nov 2026
AI Security Regions us-east-1, us-east-2, us-west-2, eu-west-2 (London), eu-north-1 (Stockholm), ap-northeast-1 (Tokyo), ap-southeast-2 (Sydney) Rule group docs
API Portal Regions 32 (list is on the API Gateway FAQ) What's New
Protected resources CloudFront, Application Load Balancer, API Gateway REST APIs Rule group docs
Capacity 400 WCU, version 1.0 is the only version Rule group docs

How the AI Security rule group works

There are two layers, and the first one needs no Bedrock at all.

Layer 1: protocol checks inside WAF. The rule group labels each request as LLM, MCP, A2A or not recognised. For MCP and A2A it validates the message against the protocol version declared in the MCP-Protocol-Version or A2A-Version header. The security blog lists supported MCP versions 2025-06-18, 2025-11-25 and 2026-07-28, and A2A 1.0. There are two levels. Baseline catches clearly malformed messages and blocks by default. Strict catches valid-but-unusual constructs and counts by default.

The example AWS gives is a header that says tools/list while the body calls tools/call on a file-reading tool. A gateway that trusts the header treats it as read-only. WAF sees the mismatch and blocks it.

Layer 2: content checks through Bedrock Guardrails. When you enable content inspection, WAF calls Bedrock on your behalf using an IAM role you supply. You do not create a guardrail. The configuration docs say the operation carries no guardrail identifier and WAF picks the checks. Three checks exist:

Check Looks for Requests Responses
Prompt attack Jailbreaks, prompt injection, system prompt extraction Yes MCP and A2A only
Content filter Hate, insults, sexual content, violence, misconduct LLM and A2A only No
Sensitive information Card numbers, SSNs, emails, bank accounts, passwords, AWS access keys No Yes

Source: security blog, as of 2 December 2026.

Each check has a rule per tier (high, medium, low), banded by severity for prompt attack and content filter and by confidence for sensitive information. By default only four rules block: the baseline MCP and A2A compliance rules, and the high-severity prompt attack rules for requests and for responses. Everything else counts and adds a label. The rule list in the docs gives label names such as request:guardrails:prompt_attack:severity:high, all under the namespace awswaf:managed:aws:ai-security:.

There are three configuration members for BedrockGuardrails: Disable, ProtectRequestOnly and ProtectRequestAndResponse. With Disable, protocol checks still run and the baseline rules still block, and you pay the WAF fee but no Bedrock charge.


Discovery with API Portal

API Portal reads service logs and configuration records for CloudFront, ALB and API Gateway. Nothing to attach, no logs to forward, no traffic rerouting. You enable it for one account or for the whole organisation, and can exclude resources. Every endpoint starts as a shadow API, and you promote it to a managed API. It also flags zombie APIs (no traffic, no config change for a set period) and orphaned APIs (owning account closed or removed). For AI endpoints it reports the type: LLM, MCP or A2A.

The point is the hackathon MCP server somebody parked behind a load balancer. It never went through your API gateway, so it is in nobody's registry. That is the gap this closes.


What this means for you

Who should act, and what first

If you run MCP servers, A2A agents or LLM inference endpoints behind CloudFront, an ALB or API Gateway REST, this is worth an hour. If your agents only talk to AgentCore Gateway, hold on: the docs say this rule group cannot be attached to AgentCore Gateways, nor to AppSync, Cognito, App Runner, Verified Access, ELB for Envoy or Amplify. It is also not supported with Firewall Manager at the moment.

My order of work: enable API Portal discovery first (it needs no WAF), see what AI endpoints you actually have, then add AI Security in count mode.

What gets simpler

You stop hand-writing regexes for MCP and A2A message shapes. Protocol recognition and compliance, plus prompt injection checks, come as one managed rule group in the same web ACL as your other rules. Labels work with the rest of WAF, so you can combine them with Bot Control or rate-based rules.

What gets more complex

  • Data leaves the protected request path. Message text goes to Bedrock. For CloudFront, WAF sends text to Bedrock in one of the seven Regions and you cannot choose which, and each edge location uses the closest one. That can mean content assessed outside the viewer's or origin's country. If you have data residency rules, read that section before enabling content inspection on a CloudFront distribution.
  • Body limits. Only the part of the body inside the inspection limit is assessed: 8 KB for ALB, 16 KB for CloudFront and API Gateway for requests, raisable to 64 KB. Responses use the default for the resource type.
  • Fail-open default. If the Bedrock call fails, the Guardrails_CallFailed rule counts and the message passes. The security blog says to set it to Block if you want to fail closed, and notes that throttling then blocks requests too. Think about that before you do it on a busy endpoint.
  • IAM role. Same account and partition as the web ACL, and the caller needs iam:PassRole. The role needs permission for InvokeGuardrailChecks; the docs say ApplyGuardrail is not used. One naming wrinkle: the What's New post spells the operation InvokeGuardrailsCheck, the developer guide says InvokeGuardrailChecks. I would trust the developer guide when writing the policy. Separately, with ProtectRequestAndResponse the configuration docs warn that a failure in the response path returns an error to the client, and overriding rules to Count does not change that, so test it before production.

Cost

Per the WAF pricing page (read 2 December 2026), AI Security and API Security are premium protections: $5.00 per million requests the rule group inspects, on top of the base request fee. There is no subscription fee for the rule group. The page also says you are not charged the premium fee for requests that an earlier rule allowed or blocked, or that a scope-down statement excluded.

WAF billing changes on 1 February 2027: per the same page, usage from then is billed on protected resources ($0.01 per hour each, about $7.30 a month), base requests ($0.60 per million) and premium requests. Web ACL, rule, rule group, capacity and body inspection charges go away. Usage through 31 January 2027 is billed at current pricing, and I did not work through that older model here.

A worked example using only the February 2027 figures: one ALB, 100 million requests a month, AI Security scoped to /mcp/* which sees 5 million of them.

  • Resource: 730 hours x $0.01 = $7.30
  • Base requests: 100 x $0.60 = $60.00
  • Premium requests: 5 x $5.00 = $25.00
  • WAF total: $92.30 a month, before Bedrock charges for content checks

Bedrock charges the content checks separately to your account, and I did not find the per-check price on the pages I read, so I am not putting a number on it.

Cost levers from the pricing page: place the premium rule groups after your cheap rules, and scope them to the paths that serve AI traffic. Separately, the configuration docs say that Disable for content assessment avoids Bedrock charges but you still pay the WAF fee.

Sample: add it in count mode first

AWS recommends starting with the default-block rules overridden to count, then removing overrides one at a time. This is the documented rule shape with RuleActionOverrides added for the four default-block rules. It is based on the docs and was only JSON-parse checked, not deployed.

{
  "Name": "AI-Security",
  "Priority": 100,
  "Statement": {
    "ManagedRuleGroupStatement": {
      "VendorName": "AWS",
      "Name": "AWSManagedRulesAISecurityRuleSet",
      "ManagedRuleGroupConfigs": [
        {
          "AWSManagedRulesAISecurityRuleSet": {
            "BedrockGuardrails": {
              "ProtectRequestAndResponse": {
                "RoleArn": "arn:aws:iam::111122223333:role/AWSWAFAISecurityRole"
              }
            }
          }
        }
      ],
      "RuleActionOverrides": [
        { "Name": "Compliance_BaselineMCP", "ActionToUse": { "Count": {} } },
        { "Name": "Compliance_BaselineA2A", "ActionToUse": { "Count": {} } },
        { "Name": "Request_GuardrailsPromptAttackHighSeverity", "ActionToUse": { "Count": {} } },
        { "Name": "Response_GuardrailsPromptAttackHighSeverity", "ActionToUse": { "Count": {} } }
      ]
    }
  },
  "OverrideAction": { "None": {} },
  "VisibilityConfig": {
    "SampledRequestsEnabled": true,
    "CloudWatchMetricsEnabled": true,
    "MetricName": "AI-Security"
  }
}
Enter fullscreen mode Exit fullscreen mode

The role ARN is the placeholder from the docs. The trust policy and permissions are on the "IAM role for AI Security" page, which I did not read in full, so follow that page for the role.

Combine it with the rest

  • Label-driven rate limit. The security blog shows a rate-based rule scoped to a label namespace (50 requests in 300 seconds per IP). The same idea works on AI Security labels: rate-limit callers who trip prompt_attack labels at medium severity before you ever block them.
  • CloudFront in front. The blog's best practice is to put CloudFront in front of public endpoints, including MCP and A2A servers hosted elsewhere, and attach the web ACL there. Combined with the region note above, decide whether edge inspection or an ALB-level ACL fits your residency position.
  • Observability. Every label becomes a CloudWatch metric. Request-phase labels also appear in WAF logs; response-phase labels appear only in CloudWatch metrics. A CloudWatch alarm on a spike in injection labels is cheap to set up.

Getting the best out of it

Put API Portal on the whole organisation, not one account. Run in count mode until you have a baseline. Override and release the four block rules one at a time. Keep an eye on the Strict compliance level: the blog says strict hits are usually an outdated client, not an attack.

Also worth knowing: AWS frames agent security as layers it calls trust in depth. I read that as: this rule group is one layer, not a replacement for validating tokens and input in your own server.


Related posts


Sources

Drafted with AI assistance. I review and edit every post.

Top comments (1)

Collapse
 
sandscale profile image
Sandscale •

Starting in count mode and scoping the rule group to the MCP path is the right order. Two operational details from the docs are easy to miss in production: the Guardrails failure rule is fail-open unless you set it to block, and only the body inside the inspection limit is checked, so a large tools/call can put the dangerous part past the window. This layer also does not replace auth on the MCP server itself — a mismatched header is useful to catch, but a valid, authenticated call can still be a prompt injection.