Skip to content

Commit f276369

Browse files
committed
Fix a potential XSS vulnerability on the hardcopy page.
This is another case where a URL parameter is inserted directly into the page without being escaped. This just escapes the parameter value to prevent the possibility of an XSS attack.
1 parent 1fedbc8 commit f276369

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/WeBWorK/ContentGenerator/Hardcopy.pm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ problem sets.
1010

1111
use File::Temp qw/tempdir/;
1212
use Mojo::File;
13+
use Mojo::Util qw(xml_escape);
1314
use String::ShellQuote;
1415
use Archive::Zip qw(:ERROR_CODES);
1516
use XML::LibXML;
@@ -284,13 +285,14 @@ async sub pre_header_initialize ($c) {
284285
my $fullFilePath = "$ce->{webworkDirs}{tmp}/$courseID/hardcopy/$userID/$tempFile";
285286

286287
unless (-e $fullFilePath) {
287-
$c->addbadmessage($c->maketext('The requested file "[_1]" does not exist on the server.', $tempFile));
288+
$c->addbadmessage(
289+
$c->maketext('The requested file "[_1]" does not exist on the server.', xml_escape($tempFile)));
288290
return;
289291
}
290292

291293
unless ($baseName =~ /\.$userID\./ || $authz->hasPermissions($userID, 'download_hardcopy_multiuser')) {
292294
$c->addbadmessage($c->maketext('You do not have permission to access the requested file "[_1]".'),
293-
$tempFile);
295+
xml_escape($tempFile));
294296
return;
295297
}
296298

0 commit comments

Comments
 (0)