Skip to content

Commit 7599c7a

Browse files
committed
Fixed: parameter false check for specific matching types.
Fixed: padding in readme.md for JSON rules. Added: additional firewall rule in examples.
1 parent 8bb57e5 commit 7599c7a

3 files changed

Lines changed: 57 additions & 26 deletions

File tree

README.md

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ Check if an array ($_POST['usernames'][]) contains any values from given array.
100100
"match":{
101101
"type":"array_in_array",
102102
"value":[
103-
"test",
104-
"admin"
103+
"test",
104+
"admin"
105105
]
106106
}
107107
}
@@ -116,7 +116,7 @@ Check if a value ($_GET['user']) is not in an array
116116
"match":{
117117
"type":"not_in_array",
118118
"value":[
119-
"admin"
119+
"admin"
120120
]
121121
}
122122
}
@@ -203,8 +203,8 @@ Check if $_POST['payload'] contains a base64(json()) encoded payload with user_r
203203
"type":"array_key_value",
204204
"key":"user_role",
205205
"match":{
206-
"type":"equals",
207-
"value":"administrator"
206+
"type":"equals",
207+
"value":"administrator"
208208
}
209209
}
210210
}
@@ -218,24 +218,24 @@ Check if $_GET['action'] or $_POST['action'] contains a value part of an array o
218218
"parameter":"rules",
219219
"rules":[
220220
{
221-
"parameter":"get.action",
222-
"match":{
223-
"type":"in_array",
224-
"value":[
225-
"restaurant_system_customize_button",
226-
"restaurant_system_insert_dialog"
227-
]
228-
}
221+
"parameter":"get.action",
222+
"match":{
223+
"type":"in_array",
224+
"value":[
225+
"restaurant_system_customize_button",
226+
"restaurant_system_insert_dialog"
227+
]
228+
}
229229
},
230230
{
231-
"parameter":"post.action",
232-
"match":{
233-
"type":"in_array",
234-
"value":[
235-
"restaurant_system_customize_button",
236-
"restaurant_system_insert_dialog"
237-
]
238-
}
231+
"parameter":"post.action",
232+
"match":{
233+
"type":"in_array",
234+
"value":[
235+
"restaurant_system_customize_button",
236+
"restaurant_system_insert_dialog"
237+
]
238+
}
239239
}
240240
],
241241
"inclusive":true
@@ -260,7 +260,7 @@ Note that the server.ip parameter is a special computed property and retrieves t
260260
"match":{
261261
"type":"in_array",
262262
"value":[
263-
"127.0.0.1"
263+
"127.0.0.1"
264264
]
265265
}
266266
}
@@ -291,10 +291,33 @@ Check if an uploaded file ($_FILES['img']) contains the PHP opening tag in the c
291291
"match":{
292292
"type":"file_contains",
293293
"match":{
294-
"type":"contains",
295-
"value":"<?php"
294+
"type":"contains",
295+
"value":"<?php"
296296
}
297297
}
298298
}
299299
]
300+
```
301+
302+
Check if the swp_debug parameter is set to load_options and the current user is not an administrator.
303+
https://patchstack.com/database/vulnerability/social-warfare/wordpress-social-warfare-plugin-3-5-2-unauthenticated-remote-code-execution-rce-vulnerability
304+
```json
305+
[
306+
{
307+
"parameter":"get.swp_debug",
308+
"match":{
309+
"type":"equals",
310+
"value":"load_options"
311+
},
312+
"inclusive":true
313+
},
314+
{
315+
"parameter":false,
316+
"match":{
317+
"type":"current_user_cannot",
318+
"value":"administrator"
319+
},
320+
"inclusive":true
321+
}
322+
]
300323
```

src/Processor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function launch($mustExit = true)
132132
return true;
133133
}
134134

135-
// Determine if we have a valid configuration passed.
135+
// Determine if the firewall and whitelist rules were parsed properly.
136136
if (!is_array($this->firewallRules) || !is_array($this->whitelistRules)) {
137137
return true;
138138
}
@@ -220,7 +220,7 @@ public function executeFirewall($rules)
220220

221221
// Extract the value of the paramater that we want.
222222
$value = $this->request->getParameterValue($rule['parameter']);
223-
if (is_null($value)) {
223+
if (is_null($value) && $rule['parameter'] !== false) {
224224
continue;
225225
}
226226

tests/data/Rules.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,13 @@
126126
"cat":"TEST",
127127
"type":"BLOCK",
128128
"type_params":null
129+
},
130+
{
131+
"id":17,
132+
"title":"Block Social Warfare Vulnerability",
133+
"rules":[{"parameter":"get.swp_debug","match":{"type":"equals","value":"load_options"},"inclusive":true},{"parameter":false,"match":{"type":"current_user_cannot","value":"administrator"},"inclusive":true}],
134+
"cat":"TEST",
135+
"type":"BLOCK",
136+
"type_params":null
129137
}
130138
]

0 commit comments

Comments
 (0)