Updated Answer
As you can see below, it is definitely possible to perform malicious actions on Laravel routes. Given the setting of your function, the likelihood that someone will do something you donβt want is small because he can only change the $name variable.
You can still write additional code (see viblo.asia ):
$basepath = '/foo/bar/baz/'; // Path to xml file $realBase = realpath($basepath); $userpath = $basepath . $_GET['path']; $realUserPath = realpath($userpath); if ($realUserPath === false || strpos($realUserPath, $realBase) !== 0) { //Directory Traversal! } else { //Good path! }
To prevent users from accessing files, they are not allowed.
Old but relevant answer
Just tried this in Homestead:
Route::get( '/', function () { dump(exec('ls ' . storage_path() . '/../../../')); } );
And this perfectly prints the corresponding folder:

So, I would say that it is definitely possible to do things outside of the specified folder. Try this for yourself, for example:
Route::get( '/', function () { for ($i = 0; $i < 10; $i++) { $path = str_repeat('/..', $i); dump(exec('ls ' . storage_path() . $path)); } } );
And you will see that your folders appear on the screen when you click the route / .
source share