Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fps with id, wp_referer, nav menus and static files #36

Merged
merged 8 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 62 additions & 2 deletions plugins/wordpress-rule-exclusions-before.conf
Original file line number Diff line number Diff line change
Expand Up @@ -508,25 +508,31 @@ SecRule REQUEST_FILENAME "@endsWith /wp-admin/user-new.php" \
# _wp_http_referer and wp_http_referer are passed on a lot of wp-admin pages
SecRule REQUEST_FILENAME "@unconditionalMatch" \
"id:9507600,\
phase:2,\
phase:1,\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=920230;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=920273;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=931130;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=932150;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=932200;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=932236;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=941100;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=942130;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=942200;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=942230;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=942260;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=942430;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=942431;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=942432;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=942440;ARGS:_wp_http_referer,\
ctl:ruleRemoveTargetById=920230;ARGS:wp_http_referer,\
ctl:ruleRemoveTargetById=931130;ARGS:wp_http_referer,\
ctl:ruleRemoveTargetById=932150;ARGS:wp_http_referer,\
ctl:ruleRemoveTargetById=932200;ARGS:wp_http_referer,\
ctl:ruleRemoveTargetById=932236;ARGS:wp_http_referer,\
ctl:ruleRemoveTargetById=932370;ARGS:wp_http_referer,\
ctl:ruleRemoveTargetById=941100;ARGS:wp_http_referer,\
ctl:ruleRemoveTargetById=942130;ARGS:wp_http_referer,\
ctl:ruleRemoveTargetById=942200;ARGS:wp_http_referer,\
Expand All @@ -535,6 +541,50 @@ SecRule REQUEST_FILENAME "@unconditionalMatch" \
ctl:ruleRemoveTargetById=942431;ARGS:wp_http_referer,\
ver:'wordpress-rule-exclusions-plugin/1.0.1'"

# The ID variable is used all over wordpress
SecRule REQUEST_FILENAME "@rx /wp-admin/(?:admin|admin-ajax|edit|users)\.php$" \
"id:9507601,\
phase:1,\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=932236;ARGS_NAMES:id,\
ctl:ruleRemoveTargetById=932236;ARGS_NAMES:ids,\
ver:'wordpress-rule-exclusions-plugin/1.0.1'"

# nonces are randomly generated and are used all over WordPress
SecRule ARGS:_wpnonce "@rx ^[a-z0-9]+$" \
"id:9507602,\
phase:2,\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=932236;ARGS:_wpnonce,\
ctl:ruleRemoveTargetById=942450;ARGS:_wpnonce,\
ver:'wordpress-rule-exclusions-plugin/1.0.1'"

# nonces are randomly generated and are used all over WordPress
SecRule ARGS:nonce "@rx ^[a-z0-9]+$" \
"id:9507603,\
phase:2,\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=932236;ARGS:nonce,\
ctl:ruleRemoveTargetById=942450;ARGS:nonce,\
ver:'wordpress-rule-exclusions-plugin/1.0.1'"

# Requesting static files
SecRule ARGS:ver "@rx ^[a-z0-9\.]+$" \
"id:9507604,\
phase:2,\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=932236;ARGS:ver,\
ctl:ruleRemoveTargetById=942450;ARGS:ver,\
ver:'wordpress-rule-exclusions-plugin/1.0.1'"
EsadCetiner marked this conversation as resolved.
Show resolved Hide resolved

#
# [ Content editing ]
#
Expand Down Expand Up @@ -604,16 +654,22 @@ SecRule REQUEST_FILENAME "@endsWith /wp-admin/nav-menus.php" \
ctl:ruleRemoveTargetById=932200;ARGS,\
ctl:ruleRemoveTargetById=932150;ARGS,\
ctl:ruleRemoveTargetById=942460;ARGS:menu-name,\
ctl:ruleRemoveTargetById=920273;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=931130;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=932200;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=932240;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=941330;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=941340;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942200;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942260;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942330;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942340;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942370;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942430;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942431;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942460;ARGS:nav-menu-data"
ctl:ruleRemoveTargetById=942432;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942460;ARGS:nav-menu-data,\
ctl:ruleRemoveTargetById=942520;ARGS:nav-menu-data"

# Edit text widgets (can contain custom HTML)
SecRule REQUEST_FILENAME "@endsWith /wp-admin/admin-ajax.php" \
Expand Down Expand Up @@ -931,6 +987,10 @@ SecRule REQUEST_FILENAME "@rx /wp-admin/load-(?:scripts|styles)\.php$" \
ctl:ruleRemoveTargetById=942430;ARGS:load[chunk_1],\
ctl:ruleRemoveTargetById=942431;ARGS:load[chunk_1],\
ctl:ruleRemoveTargetById=942432;ARGS:load[chunk_1],\
ctl:ruleRemoveTargetById=932236;ARGS:load[chunk_2],\
ctl:ruleRemoveTargetById=942430;ARGS:load[chunk_2],\
ctl:ruleRemoveTargetById=942431;ARGS:load[chunk_2],\
ctl:ruleRemoveTargetById=942432;ARGS:load[chunk_2],\
ctl:ruleRemoveTargetById=920100;REQUEST_LINE,\
ver:'wordpress-rule-exclusions-plugin/1.0.1'"

Expand Down
39 changes: 39 additions & 0 deletions tests/regression/wordpress-rule-exclusions-plugin/9507600.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
meta:
author: "Esad Cetiner"
description: "Wordpress Rule Exclusions Plugin"
enabled: true
name: 9507600.yaml
tests:
- test_title: 9507600-1
desc: Creating a new user account
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: OWASP CRS
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: GET
uri: /wp-admin/user-edit.php?user_id=9&wp_http_referer=%2Fwp-admin%2Fusers.php%3Fupdate%3Dadd%26id%3D9
output:
no_log_contains: id "932236"
- test_title: 9507600-2
desc: Deleteing a user account
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: OWASP CRS
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
content-type: application/x-www-form-urlencoded
port: 80
method: POST
uri: /wp-admin/users.php?s=&_wpnonce=random&_wp_http_referer=%2Fwp-admin%2Fusers.php&action=delete&new_role=&paged=1&users%5B0%5D=9&action2=delete&new_role2=
output:
no_log_contains: |
id "(?:920230|942430|942431|942432)"
37 changes: 37 additions & 0 deletions tests/regression/wordpress-rule-exclusions-plugin/9507602.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
meta:
author: "Esad Cetiner"
description: "Wordpress Rule Exclusions Plugin"
enabled: true
name: 9507602.yaml
tests:
- test_title: 9507602-1
desc: Disable 932236 for randomly generated nonce
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: OWASP CRS
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /wp-admin/users.php?s=&_wpnonce=lsrandom&_wp_http_referer=%2Fwp-admin%2Fusers.php&action=delete&new_role=&paged=1&users%5B0%5D=9&action2=delete&new_role2=
output:
no_log_contains: id "932236"
- test_title: 9507602-2
desc: Disable 942450 for randomly generated nonce
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: OWASP CRS
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /wp-admin/users.php?s=&_wpnonce=0x0800random&_wp_http_referer=%2Fwp-admin%2Fusers.php&action=delete&new_role=&paged=1&users%5B0%5D=9&action2=delete&new_role2=
output:
no_log_contains: id "942450"
37 changes: 37 additions & 0 deletions tests/regression/wordpress-rule-exclusions-plugin/9507603.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
meta:
author: "Esad Cetiner"
description: "Wordpress Rule Exclusions Plugin"
enabled: true
name: 9507603.yaml
tests:
- test_title: 9507603-1
desc: Disable 932236 for randomly generated nonce
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: OWASP CRS
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /wp-admin/users.php?s=&nonce=lsrandom
output:
no_log_contains: id "932236"
- test_title: 9507603-2
desc: Disable 942450 for randomly generated nonce
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: OWASP CRS
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /wp-admin/users.php?s=&nonce=0x0800random
output:
no_log_contains: id "942450"
37 changes: 37 additions & 0 deletions tests/regression/wordpress-rule-exclusions-plugin/9507604.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
meta:
author: "Esad Cetiner"
description: "Wordpress Rule Exclusions Plugin"
enabled: true
name: 9507604.yaml
tests:
- test_title: 9507604-1
desc: Requesting a static file with randomly generated version
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: OWASP CRS
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /wp-admin/users.php?s=&ver=lsrandom
output:
no_log_contains: id "932236"
- test_title: 9507604-2
desc: Requesting a static file with randomly generated version
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: OWASP CRS
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /wp-admin/users.php?s=&ver=0x0800random
output:
no_log_contains: id "942450"