CVE-2015-10043: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (CWE-22)
value: A vulnerability, which was classified as critical, was found in abreen Apollo. This affects an unknown part. The manipulation of the argument file leads to path traversal. The patch is named 6206406630780bbd074aff34f4683fb764faba71. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218307.
CWE description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
CVSS v3 base score: 8.8
Published: 2023-01-14T21:15Z
Repository: https://github.com/abreen/Apollo
Language: PHP
Files changed: delete.php, download.php, view_file.php
Commit date: 2015-01-29 21:26:42 -0500
Commit message: Patched potential file path exploit

Fixed an exploit that could have allowed users to specify file
paths elsewhere on the file system to view or delete.

Diff: diff --git a/delete.php b/delete.php
index 4c5f040..fc60cc4 100644
--- a/delete.php
+++ b/delete.php
@@ -18,10 +18,14 @@ if (!isset($_GET['type']) || !isset($_GET['num']) || !isset($_GET['file']))
 check_assignment($_GET['num'], $_GET['type']);
 
 $num = $_GET['num'];
 $type = $_GET['type'];
 
+// protects against attacks where '..' could be used in file path
+if (basename($_GET['file']) !== $_GET['file'])
+    trigger_error('invalid file path');
+
 delete_file($num, $type, $_SESSION['username'], $_GET['file']);
 
 $vars = array();
 
 $vars['assignment'] = htmlspecialchars(assignment_name($num, $type));
diff --git a/download.php b/download.php
index d0001c4..6c7696b 100644
--- a/download.php
+++ b/download.php
@@ -19,10 +19,14 @@ check_assignment($_GET['num'], $_GET['type']);
 
 $num = $_GET['num'];
 $type = $_GET['type'];
 $assignment_name = htmlspecialchars(assignment_name($num, $type));
 
+// protects against attacks where '..' could be used in file path
+if (basename($_GET['file']) !== $_GET['file'])
+    trigger_error('invalid file path');
+
 $path = submission_path($num, $type, $_SESSION['username'], $_GET['file']);
 
 if (!file_exists($path))
     trigger_error('the specified file does not exist: ' . $_GET['file']);
 
diff --git a/view_file.php b/view_file.php
index 6002720..979fcc2 100644
--- a/view_file.php
+++ b/view_file.php
@@ -19,10 +19,14 @@ check_assignment($_GET['num'], $_GET['type']);
 
 $num = $_GET['num'];
 $type = $_GET['type'];
 $assignment_name = htmlspecialchars(assignment_name($num, $type));
 
+// protects against attacks where '..' could be used in file path
+if (basename($_GET['file']) !== $_GET['file'])
+    trigger_error('invalid file path');
+
 $path = submission_path($num, $type, $_SESSION['username'], $_GET['file']);
 
 if (!file_exists($path))
     trigger_error('the specified file does not exist: ' . $_GET['file']);
 

Fixed code: // protects against attacks where '..' could be used in file path
if (basename($_GET['file']) !== $_GET['file'])
    trigger_error('invalid file path');

// protects against attacks where '..' could be used in file path
if (basename($_GET['file']) !== $_GET['file'])
    trigger_error('invalid file path');

// protects against attacks where '..' could be used in file path
if (basename($_GET['file']) !== $_GET['file'])
    trigger_error('invalid file path');