Skip to content

Commit 94b4a42

Browse files
authored
Merge pull request #748 from mgage/scoringDownloadBug
Sanitize ScoringDownload getFile parameter. Fixes bug #3793
2 parents 545fc98 + 542cb2a commit 94b4a42

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/WeBWorK/ContentGenerator/Instructor/ScoringDownload.pm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,18 @@ 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+
} elsif (($file =~ m!~!)){
44+
$self->addbadmessage("Your file name may not contain a tilde. ");
45+
} else {
46+
$self->reply_with_file("text/comma-separated-values", "$scoringDir/$file", $file, 0);
47+
# 0==don't delete file after downloading
48+
}
4049
} else {
4150
$self->addbadmessage("You do not have permission to access scoring data.");
4251
}

0 commit comments

Comments
 (0)