Skip Menu |

This queue is for tickets about the HTML-Sanitizer CPAN distribution.

Report information
The Basics
Id: 2993
Status: resolved
Priority: 0/
Queue: HTML-Sanitizer

People
Owner: Nobody in particular
Requestors: nick [...] cleaton.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.01
Fixed in: (no value)



Subject: HTML::Sanitizer XSS vulnerability in example configuration
HTML::Sanitizer-0.01, tested under perl-5.008 on FreeBSD: The example configuration in the SYNOPSIS is vulnerable to cross site scripting, because the regular expression that validates an IMG SRC value is missing brackets to fix precedence, so any IMG SRC value containing the text 'ftp:' is accepted. Demonstration: #!/usr/local/perl-5.008/bin/perl -w use strict; use HTML::Sanitizer; my $safe = new HTML::Sanitizer; $safe->permit_only( qw/ strong em /, a => { href => qr/^http:|ftp:/, title => 1, }, img => { src => qr/^http:|ftp:/, alt => 1, }, ); my $evil_html = '<img src="javascript:alert(1)//ftp:">'; print $safe->filter_as_html_fragment($evil_html), "\n"; Suggested fix: Change the regular expression to: qr/^(?:http|ftp):/