Last active
March 1, 2019 19:31
-
-
Save BlakeGardner/9183948 to your computer and use it in GitHub Desktop.
Security vulnerability in Laravel’s URL validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Imagine if this came from the request or a database entry editable by the user. | |
* The Laravel URL validator relies on PHP's filter_var() method which considers | |
* file:// and php:// valid URLs. The vast majority of Laravel users probably | |
* expect this validator to only validate http:// & https:// | |
* @link http://www.php.net/manual/en/wrappers.php | |
*/ | |
Route::get('/', function () { | |
$url = 'file:///etc/hosts'; | |
$validator = \Validator::make | |
( | |
['url' => $url], | |
['url' => 'url'] | |
); | |
if ($validator->passes()) { | |
return file_get_contents($url); | |
} | |
}); |
Has this been patched in any recent Laravel updates?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very very bad :/