Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit e761ae6

Browse files
authored
Merge pull request #1591 from theMiddleBlue/bkp-extension-and-more
New rule 920500: block backup extensions
2 parents c92aa4a + 50255f7 commit e761ae6

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,31 @@ SecRule REQUEST_BASENAME "@rx \.([^.]+)$" \
10301030
"t:none,t:urlDecodeUni,t:lowercase,\
10311031
setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
10321032

1033+
#
1034+
# Backup or "working" file extension
1035+
# example: index.php~, /index.php~/foo/
1036+
#
1037+
SecRule REQUEST_FILENAME "@rx \.[^.~]+~(?:/.*|)$" \
1038+
"id:920500,\
1039+
phase:2,\
1040+
block,\
1041+
t:none,t:urlDecodeUni,\
1042+
msg:'Attempt to access a backup or working file',\
1043+
logdata:'%{TX.0}',\
1044+
tag:'application-multi',\
1045+
tag:'language-multi',\
1046+
tag:'platform-multi',\
1047+
tag:'attack-protocol',\
1048+
tag:'paranoia-level/1',\
1049+
tag:'OWASP_CRS',\
1050+
tag:'OWASP_CRS/POLICY/EXT_RESTRICTED',\
1051+
tag:'WASCTC/WASC-15',\
1052+
tag:'OWASP_TOP_10/A7',\
1053+
tag:'PCI/6.5.10',\
1054+
ver:'OWASP_CRS/3.2.0',\
1055+
severity:'CRITICAL',\
1056+
setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
1057+
10331058
#
10341059
# Restricted HTTP headers
10351060
#
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
meta:
3+
author: "Andrea Menin"
4+
enabled: true
5+
name: "920500.yaml"
6+
description: "Tests for backup or working file extensions"
7+
tests:
8+
- test_title: 920500-1
9+
desc: "Check request filename ends with ~"
10+
stages:
11+
- stage:
12+
input:
13+
dest_addr: "127.0.0.1"
14+
port: 80
15+
method: "GET"
16+
uri: "/index.php~"
17+
headers:
18+
User-Agent: "ModSecurity CRS 3 Tests"
19+
Host: "localhost"
20+
output:
21+
log_contains: "id \"920500\""
22+
- test_title: 920500-2
23+
desc: "Check request filename contains file that ends with ~ but not at end of string (bypass)"
24+
stages:
25+
- stage:
26+
input:
27+
dest_addr: "127.0.0.1"
28+
port: 80
29+
method: "GET"
30+
uri: "/index.php~/foo/bar/"
31+
headers:
32+
User-Agent: "ModSecurity CRS 3 Tests"
33+
Host: "localhost"
34+
output:
35+
log_contains: "id \"920500\""
36+
- test_title: 920500-3
37+
desc: "Rules 920500 should not block user dir such as /~user/"
38+
stages:
39+
- stage:
40+
input:
41+
dest_addr: "127.0.0.1"
42+
port: 80
43+
method: "GET"
44+
uri: "/~user/"
45+
headers:
46+
User-Agent: "ModSecurity CRS 3 Tests"
47+
Host: "localhost"
48+
output:
49+
no_log_contains: "id \"920500\""

0 commit comments

Comments
 (0)