Subchapter 96.5
references/forwarding-signals-with-dynamic-label-interpolation.mdMarkdown9 KBView on GitHub
Domain expertise for forwarding AWS WAF signals to the origin with a single rule using dynamic label
interpolation, instead of one custom rule per label. Covers the ${namespace:} placeholder syntax
that resolves at evaluation time, the synthetic values for client IP and TLS fingerprints, the
10-placeholder-per-string limit and the fully-qualified-namespace rule, and the mandatory
inbound-header-stripping companion.
Does not cover turning Bot Control on, collapsing labels into a confidence signal (its own reference), or the application’s response. Those are separate references.
Execute commands using the AWS MCP server when connected (sandboxed execution, audit logging, observability). Fall back to the AWS CLI otherwise.
To forward signals with interpolation end to end, follow the procedure exactly. See the Procedure section below.
The procedure covers:
The one-rule-per-label approach is unmaintainable; every new managed label means another web ACL edit. Interpolation forwards an entire namespace in a single custom header.
Constraints:
${namespace:} placeholder, which resolves at evaluation time, to forward a
whole namespace in one rule rather than adding a rule per labelInterpolation exposes values that resolve from request context, not the label store, so the customer does not have to reconstruct them downstream.
Constraints:
${awswaf:ip:} (client IP), ${awswaf:ja3:} and ${awswaf:ja4:} (TLS
fingerprints), and ${awswaf:request_id:} through interpolation when the origin needs them,
rather than parsing them by handTwo traps cause interpolation to not resolve as expected.
Constraints:
The forwarded values arrive as x-amzn-waf-* headers, which an attacker can set inbound unless
they are stripped first.
Constraints:
x-amzn-waf-* signals only to an HTTPS-only origin, and the application MUST
validate the origin’s TLS certificate, so the signals are 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 renewedThe short name was used. Use the fully qualified namespace (Limits and the fully-qualified-namespace rule).
The string exceeds 10 placeholders. Split the forwarding across values (Limits and the fully-qualified-namespace rule).
No inbound stripping rule is in place. Add it before the forwarding rule (Strip inbound headers).
This procedure adds an interpolation-based forwarding rule, strips spoofed inbound headers, and surfaces the console link.
Constraints for parameter acquisition:
Constraints:
aws sts get-caller-identityConstraints:
You MUST add a custom-header rule that interpolates the namespace with ${namespace:}, staying
within 10 placeholders per string and using the fully qualified namespace for custom labels
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, a Count rule that
interpolates the namespace into a custom header sent to the origin:
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":"ForwardBotCategory","Priority":10,"Action":{"Count":{"CustomRequestHandling":{"InsertHeaders":[{"Name":"x-amzn-waf-bot-category","Value":"${awswaf:managed:aws:bot-control:bot:category:}"}]}}},"Statement":{"LabelMatchStatement":{"Scope":"NAMESPACE","Key":"awswaf:managed:aws:bot-control:bot:category:"}},"VisibilityConfig":{"SampledRequestsEnabled":true,"CloudWatchMetricsEnabled":true,"MetricName":"ForwardBotCategory"}}]' \
--visibility-config SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true,MetricName={web_acl_name} \
--region {region}Constraints:
You MUST add the inbound x-amzn-waf-* stripping rule before the forwarding rule
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",
"namespace": "awswaf:managed:aws:bot-control:bot:category:",
"synthetic_values": ["ip", "ja4"]
}Added one rule forwarding the bot-category namespace plus ${awswaf:ip:} and ${awswaf:ja4:} to the origin.
Added an inbound x-amzn-waf-* strip rule before it.
Open the web ACL and confirm the rule order:
https://us-east-1.console.aws.amazon.com/wafv2/homev2/web-acls?region=us-east-1Use the fully qualified namespace (Step 2).
The string exceeds 10 placeholders. Split across values (Step 2).
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.