CVE-2015-1493
Description
Directory traversal vulnerability in the min_get_slash_argument function in lib/configonlylib.php in Moodle through 2.5.9, 2.6.x before 2.6.8, 2.7.x before 2.7.5, and 2.8.x before 2.8.3 allows remote authenticated users to read arbitrary files via a .. (dot dot) in the file parameter, as demonstrated by reading PHP scripts.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
moodle/moodlePackagist | < 2.6.8 | 2.6.8 |
moodle/moodlePackagist | >= 2.7.0, < 2.7.5 | 2.7.5 |
moodle/moodlePackagist | >= 2.8.0, < 2.8.3 | 2.8.3 |
Affected products
27cpe:2.3:a:moodle:moodle:*:*:*:*:*:*:*:*+ 26 more
- cpe:2.3:a:moodle:moodle:*:*:*:*:*:*:*:*range: <=2.5.9
- cpe:2.3:a:moodle:moodle:2.5.0:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.5.1:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.5.2:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.5.3:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.5.4:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.5.5:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.5.6:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.5.7:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.5.8:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.6.0:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.6.1:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.6.2:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.6.3:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.6.4:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.6.5:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.6.6:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.6.7:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.6.8:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.0:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.1:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.2:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.3:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.4:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.0:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.1:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.2:*:*:*:*:*:*:*
Patches
4cc496f5b27d3MDL-48980 Security: Always clean the result from min_get_slash_argument
2 files changed · +18 −6
lib/configonlylib.php+6 −4 modified@@ -171,15 +171,16 @@ function min_enable_zlib_compression() { * @return string */ function min_get_slash_argument() { - // Note: This code has to work in the same cases as normal get_slash_argument(), + // Note: This code has to work in the same cases as normal get_file_argument(), // but at the same time it may be simpler because we do not have to deal // with encodings and other tricky stuff. $relativepath = ''; if (!empty($_GET['file']) and strpos($_GET['file'], '/') === 0) { - // server is using url rewriting, most probably IIS - return $_GET['file']; + // Server is using url rewriting, most probably IIS. + // Always clean the result of this function as it may be used in unsafe calls to send_file. + return min_clean_param($_GET['file'], 'SAFEPATH'); } else if (stripos($_SERVER['SERVER_SOFTWARE'], 'iis') !== false) { if (isset($_SERVER['PATH_INFO']) and $_SERVER['PATH_INFO'] !== '') { @@ -197,5 +198,6 @@ function min_get_slash_argument() { $relativepath = $matches[1]; } - return $relativepath; + // Always clean the result of this function as it may be used in unsafe calls to send_file. + return min_clean_param($relativepath, 'SAFEPATH'); }
lib/tests/configonlylib_test.php+12 −2 modified@@ -89,11 +89,11 @@ public function test_min_optional_param() { /** * Test fail-safe minimalistic slashargument processing. */ - public function min_get_slash_argument() { + public function test_min_get_slash_argument() { global $CFG; $this->resetAfterTest(); - $this->assertEquals('http://www.example.com/moode', $CFG->wwwroot); + $this->assertEquals('http://www.example.com/moodle', $CFG->wwwroot); $_SERVER = array(); $_SERVER['SERVER_SOFTWARE'] = 'Apache/2.2.22 (Unix)'; @@ -140,5 +140,15 @@ public function min_get_slash_argument() { $_SERVER['SCRIPT_NAME'] = '/moodle/theme/image.php'; $_GET = array(); $this->assertSame('/standard/core/5/u/f1', min_get_slash_argument()); + + $_SERVER = array(); + $_SERVER['SERVER_SOFTWARE'] = 'Hacker server'; + $_SERVER['QUERY_STRING'] = ''; + $_SERVER['REQUEST_URI'] = '/moodle/theme/image.php/standard/core/5/u/f1'; + $_SERVER['PATH_INFO'] = '/moodle/theme/image.php/standard\\core/..\\../5/u/f1'; + $_SERVER['SCRIPT_NAME'] = '/moodle/theme/image.php'; + $_GET = array(); + // Windows dir separators are removed, multiple ... gets collapsed to one . + $this->assertSame('/standardcore/./5/u/f1', min_get_slash_argument()); } }
0289be1321baMDL-48980 Security: Always clean the result from min_get_slash_argument
2 files changed · +18 −6
lib/configonlylib.php+6 −4 modified@@ -171,15 +171,16 @@ function min_enable_zlib_compression() { * @return string */ function min_get_slash_argument() { - // Note: This code has to work in the same cases as normal get_slash_argument(), + // Note: This code has to work in the same cases as normal get_file_argument(), // but at the same time it may be simpler because we do not have to deal // with encodings and other tricky stuff. $relativepath = ''; if (!empty($_GET['file']) and strpos($_GET['file'], '/') === 0) { - // server is using url rewriting, most probably IIS - return $_GET['file']; + // Server is using url rewriting, most probably IIS. + // Always clean the result of this function as it may be used in unsafe calls to send_file. + return min_clean_param($_GET['file'], 'SAFEPATH'); } else if (stripos($_SERVER['SERVER_SOFTWARE'], 'iis') !== false) { if (isset($_SERVER['PATH_INFO']) and $_SERVER['PATH_INFO'] !== '') { @@ -197,5 +198,6 @@ function min_get_slash_argument() { $relativepath = $matches[1]; } - return $relativepath; + // Always clean the result of this function as it may be used in unsafe calls to send_file. + return min_clean_param($relativepath, 'SAFEPATH'); }
lib/tests/configonlylib_test.php+12 −2 modified@@ -89,11 +89,11 @@ public function test_min_optional_param() { /** * Test fail-safe minimalistic slashargument processing. */ - public function min_get_slash_argument() { + public function test_min_get_slash_argument() { global $CFG; $this->resetAfterTest(); - $this->assertEquals('http://www.example.com/moode', $CFG->wwwroot); + $this->assertEquals('http://www.example.com/moodle', $CFG->wwwroot); $_SERVER = array(); $_SERVER['SERVER_SOFTWARE'] = 'Apache/2.2.22 (Unix)'; @@ -140,5 +140,15 @@ public function min_get_slash_argument() { $_SERVER['SCRIPT_NAME'] = '/moodle/theme/image.php'; $_GET = array(); $this->assertSame('/standard/core/5/u/f1', min_get_slash_argument()); + + $_SERVER = array(); + $_SERVER['SERVER_SOFTWARE'] = 'Hacker server'; + $_SERVER['QUERY_STRING'] = ''; + $_SERVER['REQUEST_URI'] = '/moodle/theme/image.php/standard/core/5/u/f1'; + $_SERVER['PATH_INFO'] = '/moodle/theme/image.php/standard\\core/..\\../5/u/f1'; + $_SERVER['SCRIPT_NAME'] = '/moodle/theme/image.php'; + $_GET = array(); + // Windows dir separators are removed, multiple ... gets collapsed to one . + $this->assertSame('/standardcore/./5/u/f1', min_get_slash_argument()); } }
a72f2cca7f08MDL-48980 Security: Always clean the result from min_get_slash_argument
2 files changed · +18 −6
lib/configonlylib.php+6 −4 modified@@ -171,15 +171,16 @@ function min_enable_zlib_compression() { * @return string */ function min_get_slash_argument() { - // Note: This code has to work in the same cases as normal get_slash_argument(), + // Note: This code has to work in the same cases as normal get_file_argument(), // but at the same time it may be simpler because we do not have to deal // with encodings and other tricky stuff. $relativepath = ''; if (!empty($_GET['file']) and strpos($_GET['file'], '/') === 0) { - // server is using url rewriting, most probably IIS - return $_GET['file']; + // Server is using url rewriting, most probably IIS. + // Always clean the result of this function as it may be used in unsafe calls to send_file. + return min_clean_param($_GET['file'], 'SAFEPATH'); } else if (stripos($_SERVER['SERVER_SOFTWARE'], 'iis') !== false) { if (isset($_SERVER['PATH_INFO']) and $_SERVER['PATH_INFO'] !== '') { @@ -197,5 +198,6 @@ function min_get_slash_argument() { $relativepath = $matches[1]; } - return $relativepath; + // Always clean the result of this function as it may be used in unsafe calls to send_file. + return min_clean_param($relativepath, 'SAFEPATH'); }
lib/tests/configonlylib_test.php+12 −2 modified@@ -89,11 +89,11 @@ public function test_min_optional_param() { /** * Test fail-safe minimalistic slashargument processing. */ - public function min_get_slash_argument() { + public function test_min_get_slash_argument() { global $CFG; $this->resetAfterTest(); - $this->assertEquals('http://www.example.com/moode', $CFG->wwwroot); + $this->assertEquals('http://www.example.com/moodle', $CFG->wwwroot); $_SERVER = array(); $_SERVER['SERVER_SOFTWARE'] = 'Apache/2.2.22 (Unix)'; @@ -140,5 +140,15 @@ public function min_get_slash_argument() { $_SERVER['SCRIPT_NAME'] = '/moodle/theme/image.php'; $_GET = array(); $this->assertSame('/standard/core/5/u/f1', min_get_slash_argument()); + + $_SERVER = array(); + $_SERVER['SERVER_SOFTWARE'] = 'Hacker server'; + $_SERVER['QUERY_STRING'] = ''; + $_SERVER['REQUEST_URI'] = '/moodle/theme/image.php/standard/core/5/u/f1'; + $_SERVER['PATH_INFO'] = '/moodle/theme/image.php/standard\\core/..\\../5/u/f1'; + $_SERVER['SCRIPT_NAME'] = '/moodle/theme/image.php'; + $_GET = array(); + // Windows dir separators are removed, multiple ... gets collapsed to one . + $this->assertSame('/standardcore/./5/u/f1', min_get_slash_argument()); } }
af9a7937cc08MDL-48980 Security: Always clean the result from min_get_slash_argument
2 files changed · +18 −6
lib/configonlylib.php+6 −4 modified@@ -171,15 +171,16 @@ function min_enable_zlib_compression() { * @return string */ function min_get_slash_argument() { - // Note: This code has to work in the same cases as normal get_slash_argument(), + // Note: This code has to work in the same cases as normal get_file_argument(), // but at the same time it may be simpler because we do not have to deal // with encodings and other tricky stuff. $relativepath = ''; if (!empty($_GET['file']) and strpos($_GET['file'], '/') === 0) { - // server is using url rewriting, most probably IIS - return $_GET['file']; + // Server is using url rewriting, most probably IIS. + // Always clean the result of this function as it may be used in unsafe calls to send_file. + return min_clean_param($_GET['file'], 'SAFEPATH'); } else if (stripos($_SERVER['SERVER_SOFTWARE'], 'iis') !== false) { if (isset($_SERVER['PATH_INFO']) and $_SERVER['PATH_INFO'] !== '') { @@ -197,5 +198,6 @@ function min_get_slash_argument() { $relativepath = $matches[1]; } - return $relativepath; + // Always clean the result of this function as it may be used in unsafe calls to send_file. + return min_clean_param($relativepath, 'SAFEPATH'); }
lib/tests/configonlylib_test.php+12 −2 modified@@ -89,11 +89,11 @@ public function test_min_optional_param() { /** * Test fail-safe minimalistic slashargument processing. */ - public function min_get_slash_argument() { + public function test_min_get_slash_argument() { global $CFG; $this->resetAfterTest(); - $this->assertEquals('http://www.example.com/moode', $CFG->wwwroot); + $this->assertEquals('http://www.example.com/moodle', $CFG->wwwroot); $_SERVER = array(); $_SERVER['SERVER_SOFTWARE'] = 'Apache/2.2.22 (Unix)'; @@ -140,5 +140,15 @@ public function min_get_slash_argument() { $_SERVER['SCRIPT_NAME'] = '/moodle/theme/image.php'; $_GET = array(); $this->assertSame('/standard/core/5/u/f1', min_get_slash_argument()); + + $_SERVER = array(); + $_SERVER['SERVER_SOFTWARE'] = 'Hacker server'; + $_SERVER['QUERY_STRING'] = ''; + $_SERVER['REQUEST_URI'] = '/moodle/theme/image.php/standard/core/5/u/f1'; + $_SERVER['PATH_INFO'] = '/moodle/theme/image.php/standard\\core/..\\../5/u/f1'; + $_SERVER['SCRIPT_NAME'] = '/moodle/theme/image.php'; + $_GET = array(); + // Windows dir separators are removed, multiple ... gets collapsed to one . + $this->assertSame('/standardcore/./5/u/f1', min_get_slash_argument()); } }
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
9- github.com/advisories/GHSA-gphj-63h8-r9vqghsaADVISORY
- moodle.org/mod/forum/discuss.phpnvdVendor AdvisoryWEB
- nvd.nist.gov/vuln/detail/CVE-2015-1493ghsaADVISORY
- openwall.com/lists/oss-security/2015/02/04/15nvdWEB
- openwall.com/lists/oss-security/2015/02/09/2nvdWEB
- github.com/moodle/moodle/commit/0289be1321babfa588fb5b18ebb08a296eed9eeeghsaWEB
- github.com/moodle/moodle/commit/a72f2cca7f08c354c18a3923c3f05eee50bdd434ghsaWEB
- github.com/moodle/moodle/commit/af9a7937cc085f96bdbc4724cadec6eeae0242fcghsaWEB
- github.com/moodle/moodle/commit/cc496f5b27d36a8df4bcede997a484eb9719363bghsaWEB
News mentions
0No linked articles in our index yet.