Skip to content

Commit

Permalink
fix pathToLogFile to only get files in log dir (#90)
Browse files Browse the repository at this point in the history
Proper check the file parameter to disallow arbitrary file downloads
  • Loading branch information
apreiml authored and rap2hpoutre committed May 25, 2017
1 parent 8da15ca commit 4129da0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ public static function setFile($file)
*/
public static function pathToLogFile($file)
{
$logsPath = storage_path('logs');
if (!starts_with('/', $file)) {
$logsPath = storage_path('logs');

if (app('files')->exists($file)) { // try the absolute path
return $file;
$file = $logsPath . '/' . $file;
}

$file = $logsPath . '/' . $file;

// check if requested file is really in the logs directory
if (dirname($file) !== $logsPath) {
if (dirname(realpath($file)) !== $logsPath) {
throw new \Exception('No such log file');
}

Expand Down

0 comments on commit 4129da0

Please sign in to comment.