Cloud/ Google Cloud / Identity & Security / Cloud Armor: DDoS Protection and WAF Rules for GCP Applications

GCP Google Cloud Platform Guide 7 of 10 54 guides ยท updated 2026

Guides to BigQuery, Vertex AI, GKE, Dataflow, and the rest of Google's data- and AI-first cloud โ€” written for engineers shipping real workloads.

Cloud Armor: DDoS Protection and WAF Rules for GCP Applications

A web application firewall (WAF) and DDoS protection sound like two separate concerns, but theyโ€™re solving the same underlying problem from opposite directions โ€” one filters malicious individual requests (SQL injection, XSS payloads), the other filters malicious volume (a flood of otherwise-legitimate-looking requests designed to overwhelm your infrastructure). Cloud Armor is Googleโ€™s answer to both, implemented at the edge of Googleโ€™s global network, in front of your load balancer, before traffic ever reaches your actual application servers.

The โ€œat the edgeโ€ part matters more than it sounds. Googleโ€™s network absorbs attack traffic at points of presence distributed globally, geographically close to where the traffic originates โ€” by the time a volumetric attack would reach your actual backend infrastructure in a traditional single-datacenter setup, Cloud Armor has already filtered or absorbed most of it using Googleโ€™s own globally distributed network capacity, not yours.


Where Cloud Armor Sits in the Request Path

Internet traffic (legitimate + attack traffic mixed)
โ”‚
โ–ผ
Google's global edge network (points of presence worldwide)
โ”‚
โ–ผ
Cloud Armor
(WAF rules + rate limiting + DDoS filtering)
โ”‚
โ–ผ
HTTP(S) Load Balancer
โ”‚
โ–ผ
Backend service (Compute Engine, GKE, Cloud Run)

This placement is only available for traffic passing through Googleโ€™s external HTTP(S) Load Balancer โ€” Cloud Armor is not a general-purpose firewall for arbitrary traffic; it specifically protects load-balanced HTTP(S) and, with backend service extensions, TCP/SSL proxy traffic. Traffic that bypasses the load balancer entirely doesnโ€™t get Cloud Armorโ€™s protection, which is a common point of confusion during initial setup.


Security Policies and Rules

A Cloud Armor security policy is an ordered list of rules, each with a priority, a match condition, and an action:

Terminal window
gcloud compute security-policies create my-security-policy \
--description="Baseline WAF policy"
# Block a specific malicious IP range
gcloud compute security-policies rules create 1000 \
--security-policy=my-security-policy \
--src-ip-ranges="198.51.100.0/24" \
--action=deny-403
# Enable a pre-configured OWASP rule for SQL injection detection
gcloud compute security-policies rules create 2000 \
--security-policy=my-security-policy \
--expression="evaluatePreconfiguredExpr('sqli-stable')" \
--action=deny-403
# Default rule โ€” allow everything not explicitly matched above
gcloud compute security-policies rules create 2147483647 \
--security-policy=my-security-policy \
--src-ip-ranges="*" \
--action=allow

Rules evaluate in priority order (lowest number first), and the first match wins โ€” this ordering is worth being deliberate about, because a broad allow rule placed before a narrow deny rule silently defeats the deny rule entirely, a mistake thatโ€™s easy to make and non-obvious to debug from the outside.


Pre-Configured WAF Rules

Rather than writing custom detection logic for common attack patterns, Cloud Armor ships pre-configured rule sets mapped to the OWASP Top 10 and other known attack signatures:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Rule set โ”‚ Detects โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ sqli-stable โ”‚ SQL injection patterns โ”‚
โ”‚ xss-stable โ”‚ Cross-site scripting payloads โ”‚
โ”‚ lfi-stable โ”‚ Local file inclusion attempts โ”‚
โ”‚ rfi-stable โ”‚ Remote file inclusion attempts โ”‚
โ”‚ rce-stable โ”‚ Remote code execution patterns โ”‚
โ”‚ scannerdetection-stable โ”‚ Known vulnerability scanner signatures โ”‚
โ”‚ protocolattack-stable โ”‚ Protocol-level anomalies โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Each rule set has a sensitivity level (1-4), trading detection breadth for false-positive rate โ€” a higher sensitivity catches more attack variants but also flags more legitimate traffic incorrectly. Starting at a lower sensitivity in โ€œpreviewโ€ mode (logging matches without blocking) and reviewing what actually triggers before enforcing is the responsible rollout pattern, rather than enabling maximum sensitivity in blocking mode from day one and discovering false positives in production.


Rate Limiting: Handling Abusive but Not-Quite-Attack Traffic

A lot of real-world abuse doesnโ€™t look like a classic DDoS attack โ€” itโ€™s a scraper hitting an API too aggressively, or a misconfigured client retrying in a tight loop. Rate limiting rules address this middle ground:

Terminal window
gcloud compute security-policies rules create 3000 \
--security-policy=my-security-policy \
--expression="true" \
--action=rate-based-ban \
--rate-limit-threshold-count=100 \
--rate-limit-threshold-interval-sec=60 \
--ban-duration-sec=600 \
--conform-action=allow \
--exceed-action=deny-429 \
--enforce-on-key=IP

This configuration allows up to 100 requests per IP per 60-second window; exceeding it triggers a temporary 10-minute ban, returning HTTP 429 for the duration. The enforce-on-key setting is worth understanding โ€” keying by raw IP is the simplest option, but for traffic behind shared corporate NATs or CDNs, keying by a more specific signal (a session cookie, an API key header) avoids collateral-damage bans against legitimate users who happen to share an egress IP with an abusive one.


Adaptive Protection: ML-Based Anomaly Detection

Beyond static rules, Cloud Armorโ€™s Adaptive Protection uses machine learning trained on your applicationโ€™s normal traffic patterns to detect and alert on Layer 7 DDoS attacks that donโ€™t match any predefined signature โ€” a volumetric pattern thatโ€™s anomalous specifically for your traffic baseline, even if each individual request looks legitimate in isolation. It surfaces a suggested rule to mitigate the detected pattern, which a human reviews and can apply โ€” a genuinely useful middle ground between fully manual rule-writing and blind automated blocking that risks false positives during a legitimate traffic spike (a product launch, a viral social media mention).


How a Rate-Limit Decision Actually Gets Made

Itโ€™s useful to see the decision path a single request goes through against a rate-limiting rule, since the โ€œconformโ€ vs โ€œexceedโ€ distinction trips people up in configuration reviews.

Under threshold, e.g. < 100/min

Over threshold

Yes

No

Incoming request

Identify enforcement key

e.g. client IP or API key

Requests from this key

in current window?

Conform action: allow

Exceed action: deny-429 or ban

Request forwarded to backend

Ban duration configured?

Key banned for N seconds โ€”

even conforming requests denied

Only this request denied,

next request re-evaluated fresh

The distinction between a plain โ€œdeny the exceeding requestโ€ and a โ€œbanโ€ action matters operationally: a ban punishes every subsequent request from that key for the configured duration, even ones that would otherwise be well within limits, while a non-ban rate limit simply rejects requests over the threshold and re-evaluates fresh on the next window. Bans are the right tool for clearly abusive, sustained traffic; a simple threshold-deny is usually better for legitimate clients that occasionally burst over a limit and shouldnโ€™t be locked out entirely for it.


Real-World Use Case: Protecting a Public API During a Launch

A company launching a public-facing API anticipates both legitimate traffic spikes and the increased attack surface that comes with public visibility. A practical Cloud Armor setup layers: geographic restriction rules if the API only serves specific regions, rate limiting scoped per API key rather than per IP (since legitimate high-volume customers share the same rate-limit concerns as abusive ones, but shouldnโ€™t be penalized identically), OWASP rule sets in blocking mode for known injection patterns, and Adaptive Protection running in monitoring mode to catch anything the static rules miss. This layered approach reflects how real production security policies actually look โ€” no single rule type covers every threat category, and treating Cloud Armor as โ€œone WAF rule set to enableโ€ undersells what the service is actually capable of.


Pricing Model

Cloud Armor charges per security policy and per rule, plus a per-request fee for requests evaluated against a policy โ€” which means the cost scales with both configuration complexity and traffic volume. For high-traffic public applications, this is usually a small fraction of overall infrastructure cost relative to the value of avoiding a successful DDoS or injection attack, but itโ€™s worth modeling explicitly rather than assuming itโ€™s negligible at genuinely large scale.


Best Practices


Common Mistakes

Placing a broad allow rule before a specific deny rule. Because Cloud Armor evaluates in priority order with first-match-wins, rule ordering mistakes silently neutralize intended protections without any error or warning.

Enabling maximum WAF sensitivity in blocking mode immediately. This reliably generates false positives against legitimate traffic โ€” starting in preview mode and tuning sensitivity based on real traffic is the safer path.

Assuming Cloud Armor protects traffic that bypasses the load balancer. Direct connections to a Compute Engine external IP, or traffic to a service not fronted by Googleโ€™s HTTP(S) Load Balancer, doesnโ€™t receive Cloud Armorโ€™s protection โ€” architecture needs to route all public traffic through a protected load balancer for the coverage to be complete.


Frequently Asked Questions

Does Cloud Armor protect against all types of DDoS attacks? Itโ€™s strongest against volumetric and Layer 7 application-layer attacks, leveraging Googleโ€™s global network capacity. Google also offers Cloud Armorโ€™s โ€œManaged Protection Plusโ€ tier with additional DDoS response support and financial protection guarantees for qualifying attacks.

Can Cloud Armor block traffic based on country of origin? Yes, geographic-based rules are a standard configuration, commonly used when an application legitimately only serves specific regions and traffic from elsewhere is almost certainly not a real customer.

Is Cloud Armor a replacement for application-level input validation? No โ€” itโ€™s a strong additional layer, not a substitute for validating and sanitizing input in your own application code. Defense in depth means both layers matter; relying entirely on a WAF to catch every injection attempt is a fragile assumption.

How does Cloud Armor handle encrypted (HTTPS) traffic inspection? Because Cloud Armor sits at the load balancer, which terminates TLS, it inspects the decrypted request content at that point โ€” the WAF rules operate on the actual request data, not blindly on encrypted traffic.

Can I test a new ruleโ€™s impact before it affects real traffic? Yes โ€” preview mode logs what a rule would have matched without actually blocking anything, which is the recommended way to validate a ruleโ€™s real-world false-positive rate against production traffic before flipping it to enforcement.

Does Cloud Armor work with internal (non-public) load balancers? Cloud Armorโ€™s protection is specifically designed for external-facing load balancers, since its purpose is defending against internet-originated attacks. Internal traffic protection relies on different mechanisms โ€” VPC firewall rules and IAM-based access control rather than a WAF.


Summary

Cloud Armorโ€™s real value is operating at a layer individual application servers structurally canโ€™t match โ€” Googleโ€™s global edge network absorbing and filtering traffic before it ever reaches infrastructure youโ€™re paying to scale. Getting real protection out of it means treating it as a layered system (WAF rules, rate limiting, adaptive detection) rather than a single switch, rolling new rules out in preview mode before enforcing, and remembering that it only protects traffic actually routed through a Cloud Armor-enabled load balancer. Skipping any of those three practices is how teams end up with a false sense of security from a service thatโ€™s technically enabled but not actually doing the job they assumed it was โ€” a gap that usually only becomes visible during the incident it was supposed to prevent.