Skip to content

Commit bdf8878

Browse files
authored
Merge pull request #2 from eilandert/dev
typo's
2 parents d595836 + f5ffca2 commit bdf8878

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Wordpress-hardening-plugin
1+
# Wordpress-hardening-plugin / modsecurity (CRS4.0+)
22
![Integration tests](https://github.com/eilandert/wordpress-hardening-plugin/actions/workflows/integration.yml/badge.svg) ![Integration tests](https://github.com/eilandert/wordpress-hardening-plugin/actions/workflows/lint.yml/badge.svg)
33

44
This plugin contains extra rules to enhance the security of wordpress installations with the OWASP Core Rule Set.
55
It's encouraged to install the wordpress-exclusions-rules-plugin as well, as we only add extra blocks in this plugin.
66

7-
The idea is to enhance the security of WordPress while minimizing the impact on PHP/SQL performance and eliminating the need for additional security plugins without interfering with wordpress or owasp.
7+
The idea is to enhance the security of WordPress while minimizing the impact on PHP/SQL performance and eliminating the need for additional wordpress security plugins without interfering with wordpress or owasp.
88

99
What this plugin does so far:
1010
- Block xmlrpc.php access (configurable, default: block) (PL1)
@@ -19,15 +19,15 @@ What this plugin does so far:
1919
- Block nasty files in uploads/* (PL1)
2020
- Block access to sensitive files like .db/.orig/.sql/.log/.git (PL1)
2121
- Block access to "/wp-json" (exact match, the api still works) (PL1)
22-
- Block inclusion attacks on index.php (PL2)
2322

2423
Raincheck list:
2524
- wp-login.php, lock out ip after $x failures for $y time (configurable)
25+
= wp-login.php, add geoip option
2626
- whitelist server ip to access the blocked wp-cron/wp-json/xmlrpc paths
2727

2828
## Requirements
2929
- CRS Version 4.0 or newer
30-
- ModSecurity compatoble Web Application Firewall
30+
- ModSecurity compatible Web Application Firewall
3131

3232
## How to install the plugin
3333

plugins/wordpress-hardening-before.conf

+16-16
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
# ------------------------------------------------------------------------
99

1010
# OWASP CRS Plugin
11-
# Plugin name: template-plugin
12-
# Plugin description: Example plugin. Use and adopt this for your own plugins.
11+
# Plugin name: wordpress-hardering-plugin
12+
# Plugin description: harden wordpress, minimize php/sql impact
1313
# Rule ID block base: 9,522,000-9,522,999
1414
# Plugin version: 1.0.0
1515

@@ -57,7 +57,6 @@ SecRule &TX:wphard.block_wpcron "@eq 0" \
5757
setvar:tx.wphard.block_wpcron=0"
5858

5959
# Check if xmlrpc should be blocked and if not, skip.
60-
# (regression test on default)
6160
SecRule &TX:wphard.block_xmlrpc "@eq 0" \
6261
"id:9522101,\
6362
phase:2,\
@@ -73,6 +72,7 @@ SecRule REQUEST_FILENAME "^/xmlrpc\.php" \
7372
t:lowercase,t:normalizePath,t:trim,\
7473
tag:'wordpress',\
7574
tag:'xmlrpc',\
75+
tag:'paranoia-level/1',\
7676
accuracy:'9',\
7777
maturity:'1',\
7878
severity:'NOTICE',\
@@ -86,7 +86,6 @@ SecRule REQUEST_FILENAME "^/xmlrpc\.php" \
8686
SecMarker "END_WPHARD_XMLRPC"
8787

8888
# check if user enumaration should be blocked and if not, skip
89-
# (regression test on default)
9089
SecRule TX:wphard.block_user_enumeration "@eq 0" \
9190
"phase:2,\
9291
id:9522103,\
@@ -102,6 +101,7 @@ SecRule REQUEST_URI "@rx (author\=[0-9]+)|(wp/v2/users)" \
102101
t:lowercase,t:normalizePath,t:trim,\
103102
tag:'wordpress',\
104103
tag:'enumeration',\
104+
tag:'paranoia-level/1',\
105105
accuracy:'9',\
106106
maturity:'1',\
107107
severity:'NOTICE',\
@@ -115,7 +115,6 @@ SecRule REQUEST_URI "@rx (author\=[0-9]+)|(wp/v2/users)" \
115115
SecMarker "END_WPHARD_USER_ENUMERATION"
116116

117117
# Check if restapi should be blocked and if not, skip
118-
# (regression test on default)
119118
SecRule TX:wphard.block_rest_api "@eq 0" \
120119
"phase:2,\
121120
id:9522106,\
@@ -132,6 +131,7 @@ SecRule REQUEST_FILENAME "@rx ^/wp-json/.+" \
132131
tag:'wordpress',\
133132
tag:'rest-api',\
134133
tag:'wp-json',\
134+
tag:'paranoia-level/1',\
135135
accuracy:'9',\
136136
maturity:'1',\
137137
severity:'NOTICE',\
@@ -144,8 +144,7 @@ SecRule REQUEST_FILENAME "@rx ^/wp-json/.+" \
144144

145145
SecMarker "END_WPHARD_BLOCK_REST_API"
146146

147-
# Check if admin login should be blocked and if not, skip
148-
# (regression test on default)
147+
# Check if login 'admin' should be blocked and if not, skip
149148
SecRule TX:wphard.block_admin_login "@eq 0" \
150149
"phase:2,\
151150
id:9522108,\
@@ -161,6 +160,7 @@ SecRule REQUEST_URI "@beginsWith /wp-login.php" \
161160
t:lowercase,t:normalizePath,t:trim,\
162161
tag:'wordpress',\
163162
tag:'admin-login',\
163+
tag:'paranoia-level/1',\
164164
accuracy:'9',\
165165
maturity:'1',\
166166
severity:'WARNING',\
@@ -176,7 +176,6 @@ SecRule REQUEST_URI "@beginsWith /wp-login.php" \
176176
SecMarker "END_WPHARD_BLOCK_ADMIN_LOGIN"
177177

178178
# Check if wpcron should be blocked and if not, skip
179-
# (regression test on default)
180179
SecRule TX:wphard.block_wpcron "@eq 0" \
181180
"id:9522110,\
182181
phase:2,\
@@ -192,6 +191,7 @@ SecRule REQUEST_FILENAME "^/wp-cron\.php" \
192191
t:lowercase,t:normalizePath,t:trim,\
193192
tag:'wordpress',\
194193
tag:'wpcron',\
194+
tag:'paranoia-level/1',\
195195
accuracy:'9',\
196196
maturity:'1',\
197197
severity:'NOTICE',\
@@ -205,13 +205,13 @@ SecRule REQUEST_FILENAME "^/wp-cron\.php" \
205205
SecMarker "END_WPHARD_WPCRON"
206206

207207
# No direct access to .php files except index.php/wp-admin/xmlrpc/wpcron
208-
# (regression test)
209208
SecRule REQUEST_FILENAME "@rx ^(?!.*(?:\/wp-admin\/|(?:^|\/)(index|xmlrpc|wp-cron|wp-login)\.php$)).*\.php$" \
210209
"id:9522200,\
211210
phase:2,\
212211
t:lowercase,t:normalizePath,t:trim,\
213212
tag:'wordpress',\
214213
tag:'direct-access',\
214+
tag:'paranoia-level/1',\
215215
accuracy:'9',\
216216
maturity:'1',\
217217
severity:'NOTICE',\
@@ -223,13 +223,13 @@ SecRule REQUEST_FILENAME "@rx ^(?!.*(?:\/wp-admin\/|(?:^|\/)(index|xmlrpc|wp-cro
223223
setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
224224

225225
# No direct access to these files (PL1)
226-
# (regression test)
227226
SecRule REQUEST_FILENAME "@pmFromFile wordpress-hardening-files.data" \
228227
"id:9522202,\
229228
phase:2,\
230229
t:lowercase,t:normalizePath,t:trim,\
231230
tag:'wordpress',\
232231
tag:'direct-access',\
232+
tag:'paranoia-level/1',\
233233
accuracy:'9',\
234234
maturity:'1',\
235235
severity:'NOTICE',\
@@ -241,13 +241,13 @@ SecRule REQUEST_FILENAME "@pmFromFile wordpress-hardening-files.data" \
241241
setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
242242

243243
# Don't allow other script languages. (PL2)
244-
# (no regression test yet)
245244
SecRule REQUEST_FILENAME "@rx .(pl|cgi|py|sh|lua|asp)$" \
246245
"id:9522203,\
247246
phase:2,\
248247
t:lowercase,t:normalizePath,t:trim,\
249248
tag:'wordpress',\
250249
tag:'only-allow-php-extension',\
250+
tag:'paranoia-level/2',\
251251
accuracy:'9',\
252252
maturity:'1',\
253253
severity:'NOTICE',\
@@ -259,13 +259,13 @@ SecRule REQUEST_FILENAME "@rx .(pl|cgi|py|sh|lua|asp)$" \
259259
setvar:'tx.inbound_anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
260260

261261
# Deny certain nasty stuff in uploads (PL1)
262-
# (regression test)
263-
SecRule REQUEST_FILENAME "@rx ^/wp-content/uploads/.*\.(?:s?html?|js|swf|lua)$" \
262+
SecRule REQUEST_FILENAME "@rx ^/wp-content/uploads/.*\.(?:s?html?|swf|lua)$" \
264263
"id:9522205,\
265264
phase:2,\
266265
t:lowercase,t:normalizePath,t:trim,\
267266
tag:'wordpress',\
268267
tag:'uploads',\
268+
tag:'paranoia-level/1',\
269269
accuracy:'9',\
270270
maturity:'1',\
271271
severity:'NOTICE',\
@@ -276,14 +276,14 @@ SecRule REQUEST_FILENAME "@rx ^/wp-content/uploads/.*\.(?:s?html?|js|swf|lua)$"
276276
msg:'Wordpress hardening: attempt to access wp-content/uploads nasty stuff',\
277277
setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
278278

279-
# Deny access to sensitive files (Pl1)
280-
# (regression test)
279+
# Deny access to sensitive files (PL1)
281280
SecRule REQUEST_FILENAME "@rx \.(conf|htaccess|htpass|sql|orig|bak|db|ini|md|log|git|github|swp|DS_STORE)($|/)?" \
282281
"id:9522206,\
283282
phase:2,\
284283
t:lowercase,t:normalizePath,t:trim,\
285284
tag:'wordpress',\
286285
tag:'sensitive-files',\
286+
tag:'paranoia-level/1',\
287287
accuracy:'9',\
288288
maturity:'1',\
289289
severity:'NOTICE',\
@@ -295,14 +295,14 @@ SecRule REQUEST_FILENAME "@rx \.(conf|htaccess|htpass|sql|orig|bak|db|ini|md|log
295295
setvar:'tx.inbound_anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
296296

297297
# Deny access to ^/wp-json$ while api keeps functioning (PL1)
298-
# (regression test)
299298
SecRule REQUEST_FILENAME "@rx ^/wp-json/?$" \
300299
"id:9522207,\
301300
phase:2,\
302301
t:lowercase,t:normalizePath,t:trim,\
303302
tag:'wordpress',\
304303
tag:'sensitive-files',\
305304
tag:'wp-json',\
305+
tag:'paranoia-level/1',\
306306
accuracy:'9',\
307307
maturity:'1',\
308308
severity:'NOTICE',\

plugins/wordpress-hardening-config.conf

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
# ------------------------------------------------------------------------
99

1010
# OWASP CRS Plugin
11-
# Plugin name: wordpress-hardening-plugin
12-
# Plugin description: extra security rules for wordpress installations
13-
# Rule ID block base: 9,522,000 (range is 1000, thus ID block base +1000)
11+
# Plugin name: wordpress-hardering-plugin
12+
# Plugin description: harden wordpress, minimize php/sql impact
13+
# Rule ID block base: 9,522,000-9,522,999
1414
# Plugin version: 1.0.0
1515

1616
# Generic rule to disable the plugin
@@ -23,7 +23,6 @@
2323
# nolog,\
2424
# setvar:'tx.wordpress-hardening-plugin_enabled=0'"
2525

26-
2726
#SecAction "id:9522011,phase:1,nolog,pass,t:none,setvar:tx.wphard.block_xmlrpc=1"
2827
#SecAction "id:9522013,phase:1,nolog,pass,t:none,setvar:tx.wphard.block_user_enumeration=1"
2928
#SecAction "id:9522015,phase:1,nolog,pass,t:none,setvar:tx.wphard.block_rest_api=0"

tests/regression/wordpress-hardening-plugin/9522205.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tests:
3434
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
3535
port: 80
3636
method: GET
37-
uri: /wp-content/uploads/test/test/test/test/test/test/test/test/test/test/test/test.js
37+
uri: /wp-content/uploads/test/test/test/test/test/test/test/test/test/test/test/test.php
3838
data: |
3939
text
4040
output:

0 commit comments

Comments
 (0)