Skip to content

Commit eb823e7

Browse files
committed
Clean $type parameter + clean, check_abs_path removes folder references
#security
1 parent e8332fd commit eb823e7

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

main/document/download_uploaded_files.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
if (empty($courseInfo)) {
1717
$courseInfo = api_get_course_info();
1818
}
19+
$type = preg_replace("/[^a-zA-Z]+/", '', $type);
20+
1921
if (empty($courseInfo) || empty($type) || empty($file)) {
2022
api_not_allowed(true);
2123
}

main/inc/lib/security.lib.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public static function check_abs_path($abs_path, $checker_path)
5858
return false;
5959
}
6060

61+
// Clean $abs_path.
62+
$abs_path = str_replace(['//', '../', './'], ['/', '', ''], $abs_path);
6163
$true_path = str_replace("\\", '/', realpath($abs_path));
6264
$checker_path = str_replace("\\", '/', realpath($checker_path));
6365

0 commit comments

Comments
 (0)