Skip to content

Commit 8a2d739

Browse files
committed
Add new tests - check if variable captured
1 parent 8bf1a69 commit 8a2d739

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

tests/regression/misc/25-libinjection.t

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,34 @@
2727
"some_variable=-1' and 1=1 union/* foo */select load_file('/etc/passwd')--"
2828
),
2929
},
30+
{
31+
type => "misc",
32+
comment => "libinjection SQLi - with SQLi, check capture",
33+
conf => qq(
34+
SecRuleEngine On
35+
SecDebugLog $ENV{DEBUG_LOG}
36+
SecDebugLogLevel 9
37+
SecRequestBodyAccess On
38+
39+
SecRule REQUEST_BODY "\@detectSQLi" "id:192372,log,deny,capture,chain"
40+
SecRule TX:0 "\@strEq s&1UE"
41+
),
42+
match_log => {
43+
error => [ qr/String match "s&1UE" at TX:0/, 1 ],
44+
debug => [ qr/String match "s&1UE" at TX:0/, 1 ],
45+
},
46+
match_response => {
47+
status => qr/^403$/,
48+
},
49+
request => new HTTP::Request(
50+
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/index.html",
51+
[
52+
"Content-Type" => "application/x-www-form-urlencoded",
53+
],
54+
# Args
55+
"some_variable=-1' and 1=1 union/* foo */select load_file('/etc/passwd')--"
56+
),
57+
},
3058
{
3159
type => "misc",
3260
comment => "libinjection SQLi - without SQLi",
@@ -81,6 +109,34 @@
81109
"some_variable=<a href=\"javascript:alert(1)\">"
82110
),
83111
},
112+
{
113+
type => "misc",
114+
comment => "libinjection XSS - with XSS, check capture",
115+
conf => qq(
116+
SecRuleEngine On
117+
SecDebugLog $ENV{DEBUG_LOG}
118+
SecDebugLogLevel 9
119+
SecRequestBodyAccess On
120+
121+
SecRule REQUEST_BODY "\@detectXSS" "id:192372,log,deny,capture,chain"
122+
SecRule TX:0 "\@strEq some_variable=<a href='javascript:alert(1)'>"
123+
),
124+
match_log => {
125+
error => [ qr/String match "some_variable=<a href='javascript:alert\(1\)'>" at TX:0/, 1],
126+
debug => [ qr/String match "some_variable=<a href='javascript:alert\(1\)'>" at TX:0/, 1 ],
127+
},
128+
match_response => {
129+
status => qr/^403$/,
130+
},
131+
request => new HTTP::Request(
132+
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/index.html",
133+
[
134+
"Content-Type" => "application/x-www-form-urlencoded",
135+
],
136+
# Args
137+
"some_variable=<a href='javascript:alert(1)'>"
138+
),
139+
},
84140
{
85141
type => "misc",
86142
comment => "libinjection XSS - without XSS",

0 commit comments

Comments
 (0)