Skip to content

Commit a08e5f5

Browse files
committed
drop standard WAF rules, ensure rate limit is applied first to all requests
1 parent edb6867 commit a08e5f5

File tree

1 file changed

+6
-136
lines changed

1 file changed

+6
-136
lines changed

infra/gcp/terraform/modules/oci-proxy/cloud-armor.tf

Lines changed: 6 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ resource "google_compute_security_policy" "cloud-armor" {
2525
rule {
2626
action = "throttle"
2727
description = "Default rule, throttle traffic"
28-
priority = "2147483647"
28+
# apply rate limit first (rules are applied sequentially by priority)
29+
# https://cloud.google.com/armor/docs/security-policy-overview#eval-order
30+
priority = "0"
2931

3032
match {
3133
config {
@@ -53,146 +55,14 @@ resource "google_compute_security_policy" "cloud-armor" {
5355
// we support "/", "/privacy", and "/v2/.*" API
5456

5557
rule {
56-
action = "deny(404)"
57-
priority = "2147483646"
58+
action = "deny(404)"
59+
# apply this broad 404 for unexpected paths second
60+
priority = "1"
5861
match {
5962
expr {
6063
expression = "!request.path.match('(?:^/$)|(?:^/privacy$)|(?:^/v2/)')"
6164
}
6265
}
6366
}
64-
65-
66-
# TODO: remove these other rules?
67-
68-
69-
rule {
70-
action = "deny(403)"
71-
priority = "910"
72-
match {
73-
expr {
74-
expression = "evaluatePreconfiguredWaf('methodenforcement-v33-stable', {'sensitivity': 1})"
75-
}
76-
}
77-
description = "Method enforcement"
78-
79-
preview = false
80-
}
81-
82-
rule {
83-
action = "deny(403)"
84-
priority = "900"
85-
match {
86-
expr {
87-
expression = "evaluatePreconfiguredWaf('protocolattack-v33-stable', {'sensitivity': 3, 'opt_out_rule_ids': ['owasp-crs-v030301-id921170-protocolattack']})"
88-
}
89-
}
90-
description = "Protocol Attack"
91-
92-
preview = false
93-
}
94-
95-
rule {
96-
action = "deny(403)"
97-
priority = "920"
98-
match {
99-
expr {
100-
expression = "evaluatePreconfiguredWaf('scannerdetection-v33-stable', {'sensitivity': 1})"
101-
}
102-
}
103-
description = "Scanner detection"
104-
105-
preview = false
106-
}
107-
108-
rule {
109-
action = "deny(403)"
110-
priority = "990"
111-
match {
112-
expr {
113-
expression = "evaluatePreconfiguredWaf('xss-v33-stable', {'sensitivity': 1})"
114-
}
115-
}
116-
description = "Cross-site scripting (XSS)"
117-
118-
preview = false
119-
}
120-
121-
rule {
122-
action = "deny(403)"
123-
priority = "960"
124-
match {
125-
expr {
126-
expression = "evaluatePreconfiguredWaf('lfi-v33-stable', {'sensitivity': 1})"
127-
}
128-
}
129-
description = "Local file inclusion (LFI)"
130-
131-
preview = false
132-
}
133-
134-
rule {
135-
action = "deny(403)"
136-
priority = "930"
137-
match {
138-
expr {
139-
expression = "evaluatePreconfiguredExpr('rce-stable')"
140-
}
141-
}
142-
143-
preview = false
144-
}
145-
146-
rule {
147-
action = "deny(403)"
148-
priority = "940"
149-
match {
150-
expr {
151-
expression = "evaluatePreconfiguredWaf('rfi-v33-stable', {'sensitivity': 2})"
152-
}
153-
}
154-
description = "Remote file inclusion (RFI)"
155-
156-
preview = false
157-
}
158-
159-
rule {
160-
action = "deny(403)"
161-
priority = "950"
162-
match {
163-
expr {
164-
expression = "evaluatePreconfiguredWaf('sessionfixation-v33-stable', {'sensitivity': 1})"
165-
}
166-
}
167-
description = "Session fixation"
168-
169-
preview = false
170-
}
171-
172-
rule {
173-
action = "deny(403)"
174-
priority = "980"
175-
match {
176-
expr {
177-
expression = "evaluatePreconfiguredWaf('php-v33-stable', {'sensitivity': 3})"
178-
}
179-
}
180-
description = "PHP"
181-
182-
preview = false
183-
}
184-
185-
rule {
186-
action = "deny(403)"
187-
priority = "1010"
188-
match {
189-
expr {
190-
expression = "evaluatePreconfiguredExpr('cve-canary')"
191-
}
192-
}
193-
description = "CVEs and other vulnerabilities"
194-
195-
preview = false
196-
}
19767
}
19868

0 commit comments

Comments
 (0)