Skip to content

Commit 5c5e9d8

Browse files
committed
Sanitize ScoringDownload getFile parameter. Fixes bug #3793
1 parent eef53f7 commit 5c5e9d8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/WeBWorK/ContentGenerator/Instructor/ScoringDownload.pm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ sub pre_header_initialize {
3434
my $scoringDir = $ce->{courseDirs}->{scoring};
3535
my $file = $r->param('getFile');
3636
my $user = $r->param('user');
37-
37+
38+
# the parameter 'getFile" needs to be sanitized. (see bug #3793 )
39+
# See checkName in FileManager.pm for a more complete sanitization.
3840
if ($authz->hasPermissions($user, "score_sets")) {
39-
$self->reply_with_file("text/comma-separated-values", "$scoringDir/$file", $file, 0); # 0==don't delete file after downloading
41+
if ($file =~ m!/!) { #
42+
$self->addbadmessage("Your file name may not contain a path component");
43+
} else {
44+
$self->reply_with_file("text/comma-separated-values", "$scoringDir/$file", $file, 0);
45+
# 0==don't delete file after downloading
46+
}
4047
} else {
4148
$self->addbadmessage("You do not have permission to access scoring data.");
4249
}

0 commit comments

Comments
 (0)