Subchapter 96.12
references/turning-bot-control-labels-into-a-confidence-signal.mdMarkdown11 KBView on GitHub
Domain expertise for collapsing the many Bot Control Targeted labels into a single
application-facing confidence signal. Covers overriding the Targeted rules to the non-terminating
Challenge action, mapping many TGT_* labels into one header with
label-match rules, defining the mapping in the web ACL so the application contract stays fixed, and
the mandatory inbound-header-stripping companion.
x-amzn-waf-bot-confidenceDoes not cover turning Bot Control on (that is the protecting-against-bots reference), forwarding a whole namespace with interpolation (its own reference), or the application’s response (the adaptive mitigation reference).
Execute commands using the AWS MCP server when connected (sandboxed execution, audit logging, observability). Fall back to the AWS CLI otherwise.
To turn Bot Control labels into a confidence signal end to end, follow the procedure exactly. See the Procedure section below.
The procedure covers:
x-amzn-waf-bot-confidence header to the originBlock or CAPTCHA terminate evaluation, so later rules that forward the signal never run. Challenge is non-terminating with a valid token.
Constraints:
Targeted produces hundreds of TGT_* labels. The application cannot act on all of them, so map
groups of labels to a small set of confidence levels.
Constraints:
If the application keys on specific label names, it has to change whenever AWS adds or renames a label. Defining the mapping in the web ACL keeps the application contract fixed.
Constraints:
x-amzn-waf-bot-confidence), so the application contract does not change as labels evolveThe confidence header is an x-amzn-waf-* header, which an attacker can set inbound unless it is
stripped first.
Constraints:
x-amzn-waf-bot-confidence only to an HTTPS-only origin and SHOULD have the
application set HSTS, so the confidence signal is not exposed in cleartext. You SHOULD use
AWS Certificate Manager (ACM) to provision and manage the origin’s TLS certificate (for example on
an Application Load Balancer), so the certificate is validated and automatically renewedA terminating action on an earlier rule stopped evaluation. Override the Targeted rules to Challenge (Override Targeted rules to Challenge).
They are at a lower priority number than the Bot Control group. Move them after it (Collapse labels into one confidence header).
No inbound stripping rule is in place. Add it before the forwarding rules (Strip inbound headers).
This procedure overrides the Targeted rules to Challenge, maps labels to a confidence header, strips spoofed inbound headers, and surfaces the console link.
Constraints for parameter acquisition:
Constraints:
aws sts get-caller-identityConstraints:
You MUST override the Targeted rules to Challenge so evaluation continues to the forwarding rules
You MUST fetch the current LockToken before update-web-acl and pass the full rule set
You MUST preserve the web ACL’s existing DefaultAction from the get-web-acl response and pass
it back as {default_action}; do not assume Allow={}, since that would silently open all
unmatched traffic on a web ACL whose default action is Block. For example, the Bot Control group
with RuleActionOverrides setting Targeted rules to Challenge:
aws wafv2 get-web-acl --name {web_acl_name} --scope {scope} --id {web_acl_id} --region {region}
aws wafv2 update-web-acl --name {web_acl_name} --scope {scope} --id {web_acl_id} \
--lock-token {lock_token} --default-action {default_action} \
--rules '[{"Name":"AWS-BotControl","Priority":1,"Statement":{"ManagedRuleGroupStatement":{"VendorName":"AWS","Name":"AWSManagedRulesBotControlRuleSet","ManagedRuleGroupConfigs":[{"AWSManagedRulesBotControlRuleSet":{"InspectionLevel":"TARGETED"}}],"RuleActionOverrides":[{"Name":"TGT_VolumetricSession","ActionToUse":{"Challenge":{}}}]}},"OverrideAction":{"None":{}},"VisibilityConfig":{"SampledRequestsEnabled":true,"CloudWatchMetricsEnabled":true,"MetricName":"AWS-BotControl"}}]' \
--visibility-config SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true,MetricName={web_acl_name} \
--region {region}Constraints:
You MUST add OR label-match rules that map label groups to low, medium, and high, at a higher priority number than the Bot Control group
You MUST forward one x-amzn-waf-bot-confidence header via custom request handling. For example,
a Count rule that matches a label group and inserts the header (insert this rule with a fresh
LockToken alongside the rest of the rule set):
--rules '[{"Name":"ConfidenceHigh","Priority":10,"Action":{"Count":{"CustomRequestHandling":{"InsertHeaders":[{"Name":"x-amzn-waf-bot-confidence","Value":"high"}]}}},"Statement":{"LabelMatchStatement":{"Scope":"LABEL","Key":"awswaf:managed:aws:bot-control:targeted:aggregate:volumetric:session:maximum"}},"VisibilityConfig":{"SampledRequestsEnabled":true,"CloudWatchMetricsEnabled":true,"MetricName":"ConfidenceHigh"}}]'Constraints:
You MUST add the inbound x-amzn-waf-* stripping rule before the forwarding rules
You MUST present the web ACL console link and tell the customer to confirm the rule order:
https://us-east-1.console.aws.amazon.com/wafv2/homev2/web-acls?region={region}{
"web_acl_name": "example-webacl",
"web_acl_id": "abc",
"scope": "REGIONAL",
"confidence_mapping": {"low": ["TGT_VolumetricSession"], "high": ["TGT_VolumetricSessionMaximum"]}
}Overrode Targeted rules to Challenge so evaluation continues.
Mapped label groups to x-amzn-waf-bot-confidence (low/medium/high) and added an inbound strip rule first.
Open the web ACL and confirm the rule order:
https://us-east-1.console.aws.amazon.com/wafv2/homev2/web-acls?region=us-east-1An earlier terminating action stopped evaluation. Use Challenge (Step 2).
Priority order is wrong. Move the label-match rules after the Bot Control group (Step 3).
This procedure modifies a security control, so misconfiguration directly weakens the application’s defenses.
wafv2: actions a task needs (for example wafv2:GetWebACL and wafv2:UpdateWebACL) rather than wafv2:* or the AWSWAFFullAccess managed policy.aws sts assume-role) rather than long-lived IAM user access keys when running these WAF CLI commands.wafv2 management events and set CloudWatch alarms on critical web ACL configuration changes (such as DeleteWebACL and UpdateWebACL rule removals) and on the web ACL’s BlockedRequests and CountedRequests metrics, so rule changes and sudden spikes in blocked or counted traffic are detected.x-amzn-waf-* signal forwarded to the origin can be forged inbound. You MUST add the inbound-header-stripping rule whenever a signal or client IP is forwarded (see stripping-inbound-waf-headers-before-trusting-them); without it the origin trusts a spoofable value.