Skip to content

Commit

Permalink
Clean $type parameter + clean, check_abs_path removes folder references
Browse files Browse the repository at this point in the history
#security
  • Loading branch information
jmontoyaa committed Jan 28, 2021
1 parent e8332fd commit eb823e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main/document/download_uploaded_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
if (empty($courseInfo)) {
$courseInfo = api_get_course_info();
}
$type = preg_replace("/[^a-zA-Z]+/", '', $type);

if (empty($courseInfo) || empty($type) || empty($file)) {
api_not_allowed(true);
}
Expand Down
2 changes: 2 additions & 0 deletions main/inc/lib/security.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public static function check_abs_path($abs_path, $checker_path)
return false;
}

// Clean $abs_path.
$abs_path = str_replace(['//', '../', './'], ['/', '', ''], $abs_path);
$true_path = str_replace("\\", '/', realpath($abs_path));
$checker_path = str_replace("\\", '/', realpath($checker_path));

Expand Down

0 comments on commit eb823e7

Please sign in to comment.