forked from NagiosEnterprises/nagioscore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path618cgisecurity.t
25 lines (17 loc) · 984 Bytes
/
618cgisecurity.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl
#
# Check that you CGI security errors are fixed
use warnings;
use strict;
use Test::More;
use FindBin qw($Bin);
chdir $Bin or die "Cannot chdir";
my $topdir = "$Bin/..";
my $cgi_dir = "$topdir/cgi";
plan 'no_plan';
my $output = `NAGIOS_CGI_CONFIG=etc/cgi.cfg REQUEST_METHOD=GET QUERY_STRING="layer=' style=xss:expression(alert('XSS')) '" $cgi_dir/statusmap.cgi`;
unlike( $output, qr/' style=xss:expression\(alert\('XSS'\)\) '/, "XSS injection not passed straight through" );
# Is this correct? Nothing weird happens anyway, so let's assume so
like( $output, qr/' style=xss:expression(alert('XSS')) '/, "Expected escaping of quotes" ) || diag $output;
$output = `REMOTE_USER=nagiosadmin NAGIOS_CGI_CONFIG=etc/cgi.cfg REQUEST_METHOD=GET QUERY_STRING="type=command&expand=<body onload=alert(666)>" $cgi_dir/config.cgi`;
unlike( $output, qr/<body onload=alert\(666\)>/, "XSS injection not passed through" ) || diag ($output);