From 64d88c1f3bf400f235fa6f6229c32c24aeb90e0e Mon Sep 17 00:00:00 2001 From: Esad Cetiner <104706115+EsadCetiner@users.noreply.github.com> Date: Mon, 28 Oct 2024 20:44:02 +1100 Subject: [PATCH 1/5] fix: editing tag false positive --- plugins/wordpress-rule-exclusions-before.conf | 1 + .../9507350.yaml | 43 +++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/plugins/wordpress-rule-exclusions-before.conf b/plugins/wordpress-rule-exclusions-before.conf index accf95f..28fc5fd 100644 --- a/plugins/wordpress-rule-exclusions-before.conf +++ b/plugins/wordpress-rule-exclusions-before.conf @@ -466,6 +466,7 @@ SecRule REQUEST_FILENAME "@unconditionalMatch" \ ctl:ruleRemoveTargetById=931130;ARGS:_wp_http_referer,\ ctl:ruleRemoveTargetById=932150;ARGS:_wp_http_referer,\ ctl:ruleRemoveTargetById=932200;ARGS:_wp_http_referer,\ + ctl:ruleRemoveTargetById=932235;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,\ diff --git a/tests/regression/wordpress-rule-exclusions-plugin/9507350.yaml b/tests/regression/wordpress-rule-exclusions-plugin/9507350.yaml index 484648c..39ce340 100644 --- a/tests/regression/wordpress-rule-exclusions-plugin/9507350.yaml +++ b/tests/regression/wordpress-rule-exclusions-plugin/9507350.yaml @@ -20,7 +20,8 @@ tests: version: "HTTP/1.1" uri: /get/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" + no_log_contains: | + id "920230"|id "932235"|id "932236"|id "942430"|id "942431"|id "942432"|id "942450" - test_title: 9507350-2 desc: Deleteing a user account stages: @@ -38,7 +39,7 @@ tests: uri: /post/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"|id "942430"|id "942431"|id "942432" + id "920230"|id "932235"|id "932236"|id "942430"|id "942431"|id "942432"|id "942450" - test_title: 9507350-3 desc: Disable 932236 for randomly generated nonce stages: @@ -54,7 +55,8 @@ tests: version: "HTTP/1.1" uri: /post/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" + no_log_contains: | + id "920230"|id "932235"|id "932236"|id "942430"|id "942431"|id "942432"|id "942450" - test_title: 9507350-4 desc: Disable 942450 for randomly generated nonce stages: @@ -70,7 +72,8 @@ tests: version: "HTTP/1.1" uri: /post/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" + no_log_contains: | + id "920230"|id "932235"|id "932236"|id "942430"|id "942431"|id "942432"|id "942450" - test_title: 9507350-5 desc: Disable 932236 for randomly generated nonce stages: @@ -86,7 +89,8 @@ tests: version: "HTTP/1.1" uri: /post/wp-admin/users.php?s=&nonce=lsrandom output: - no_log_contains: id "932236" + no_log_contains: | + id "920230"|id "932235"|id "932236"|id "942430"|id "942431"|id "942432"|id "942450" - test_title: 9507350-6 desc: Disable 942450 for randomly generated nonce stages: @@ -102,7 +106,8 @@ tests: version: "HTTP/1.1" uri: /post/wp-admin/users.php?s=&nonce=0x0800random output: - no_log_contains: id "942450" + no_log_contains: | + id "920230"|id "932235"|id "932236"|id "942430"|id "942431"|id "942432"|id "942450" - test_title: 9507350-7 desc: Requesting a static file with randomly generated version stages: @@ -118,7 +123,8 @@ tests: version: "HTTP/1.1" uri: /get/example.js?ver=lsrandom output: - no_log_contains: id "932236" + no_log_contains: | + id "920230"|id "932235"|id "932236"|id "942430"|id "942431"|id "942432"|id "942450" - test_title: 9507350-8 desc: Requesting a static file with randomly generated version stages: @@ -134,4 +140,25 @@ tests: version: "HTTP/1.1" uri: /get/example.js?ver=0x0000 output: - no_log_contains: id "942450" + no_log_contains: | + id "920230"|id "932235"|id "932236"|id "942430"|id "942431"|id "942432"|id "942450" + - test_title: 9507350-9 + desc: Editing tags + stages: + - stage: + input: + dest_addr: 127.0.0.1 + headers: + Host: localhost + User-Agent: OWASP CRS test agent + 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 + version: "HTTP/1.1" + uri: /post/wp-admin/edit-tags.php + data: | + _wp_http_referer=/wp-admin/term.php?taxonomy=post_tag&tag_ID=12&post_type=post&wp_http_referer=%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dpost_tag + output: + no_log_contains: | + id "920230"|id "932235"|id "932236"|id "942430"|id "942431"|id "942432"|id "942450" From cfb12aa8be8a1b51b342894b74ee99109fe84fd0 Mon Sep 17 00:00:00 2001 From: Esad Cetiner <104706115+EsadCetiner@users.noreply.github.com> Date: Mon, 28 Oct 2024 20:56:59 +1100 Subject: [PATCH 2/5] fix: editing tag false positive --- plugins/wordpress-rule-exclusions-before.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/wordpress-rule-exclusions-before.conf b/plugins/wordpress-rule-exclusions-before.conf index 28fc5fd..3a7824d 100644 --- a/plugins/wordpress-rule-exclusions-before.conf +++ b/plugins/wordpress-rule-exclusions-before.conf @@ -457,6 +457,8 @@ SecRule REQUEST_FILENAME "@unconditionalMatch" \ pass,\ t:none,\ nolog,\ + ctl:ruleRemoveTargetById=920273;ARGS_NAMES:users[0],\ + ctl:ruleRemoveTargetById=942432;ARGS_NAMES:users[0],\ ctl:ruleRemoveTargetById=932236;ARGS:nonce,\ ctl:ruleRemoveTargetById=942450;ARGS:nonce,\ ctl:ruleRemoveTargetById=932236;ARGS:ver,\ @@ -478,6 +480,7 @@ SecRule REQUEST_FILENAME "@unconditionalMatch" \ ctl:ruleRemoveTargetById=942432;ARGS:_wp_http_referer,\ ctl:ruleRemoveTargetById=942440;ARGS:_wp_http_referer,\ 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,\ @@ -489,6 +492,7 @@ SecRule REQUEST_FILENAME "@unconditionalMatch" \ ctl:ruleRemoveTargetById=942230;ARGS:wp_http_referer,\ ctl:ruleRemoveTargetById=942260;ARGS:wp_http_referer,\ ctl:ruleRemoveTargetById=942431;ARGS:wp_http_referer,\ + ctl:ruleRemoveTargetById=942432;ARGS:wp_http_referer,\ ctl:ruleRemoveTargetById=932236;ARGS:_wpnonce,\ ctl:ruleRemoveTargetById=942450;ARGS:_wpnonce,\ ver:'wordpress-rule-exclusions-plugin/1.0.1'" From 91889ff1415dfda68bd3534a4db90b35e6b3c4ab Mon Sep 17 00:00:00 2001 From: Esad Cetiner <104706115+EsadCetiner@users.noreply.github.com> Date: Tue, 26 Nov 2024 22:56:18 +1100 Subject: [PATCH 3/5] fix: check log output correctly --- .../9507100.yaml | 4 ++-- .../9507121.yaml | 2 +- .../9507139.yaml | 2 +- .../9507140.yaml | 2 +- .../9507201.yaml | 2 +- .../9507350.yaml | 18 +++++++++--------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/regression/wordpress-rule-exclusions-plugin/9507100.yaml b/tests/regression/wordpress-rule-exclusions-plugin/9507100.yaml index 1de7220..4c65f81 100644 --- a/tests/regression/wordpress-rule-exclusions-plugin/9507100.yaml +++ b/tests/regression/wordpress-rule-exclusions-plugin/9507100.yaml @@ -20,7 +20,7 @@ tests: version: "HTTP/1.1" uri: /post/wp-login.php?pwd=