Tuesday June 13, 2006 Cross Site Scripting Prevention in Sun Java System Web Server 7.0
"<"
and ">" characters. In ModSecurity in Apache server
you have SecFilter like|
SecFilterEngine On SecFilterScanPOST On SecFilter "<(.|\n)+>" |
| Input
fn="insert-filter" method="POST" filter="sed-request" sed="s/(<|%3c)/\\</gi" sed="s/(>|%3e)/\\>/gi" |
|
SecRuleEngine On SecRequestBodyAccess On SecRule REQUEST_BODY "<(.|\n)+>" |
|
$cat https-test/docs/cgi-bin/test.pl
#!/tools/ns/bin/perl5 binmode(STDOUT); binmode(STDIN); if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } else { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } foreach $pair (@pairs) { ($key, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/\cM/\n/; eval("\$$key = \"$value\""); $FORM{$key} = $value; } print "Content-Type: text/html\n\n"; print "CGI values passed\n\n"; if ($#pairs < 0) { print "No CGI Variables\n"; } else { foreach $var (keys(%FORM)) { print "$var $FORM{$var}\n"; } } exit; |
| $telnet 0 3333 POST /cgi-bin/test.pl HTTP/1.0 Content-length: 10 abcde12345 HTTP/1.1 200 OK Server: Sun-Java-System-Web-Server/7.0 Date: Wed, 16 Jul 2008 07:56:47 GMT Content-type: text/html Connection: close CGI values passed abcde12345 |
| $telnet 0 3333 POST /cgi-bin/test.pl HTTP/1.0 Content-length: 10 ab<cd>12 HTTP/1.1 403 Forbidden Server: Sun-Java-System-Web-Server/7.0 Date: Wed, 16 Jul 2008 07:57:24 GMT Content-length: 142 Content-type: text/html Connection: close <HTML><HEAD><TITLE>Forbidden</TITLE></HEAD> <BODY><H1>Forbidden</H1> Your client is not allowed to access the requested object. </BODY></HTML> |
| $telnet 0 3333 POST /cgi-bin/test.pl HTTP/1.0 Content-length: 10 ab<cdef12345 HTTP/1.1 200 OK Server: Sun-Java-System-Web-Server/7.0 Date: Wed, 16 Jul 2008 07:58:03 GMT Content-type: text/html Connection: close CGI values passed ab<cdef123 |
This blog copyright 2009 by meena