-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
use Illuminate\Support\NamespacedItemResolver; | ||
use Illuminate\Support\Str; | ||
use Illuminate\Support\Traits\Macroable; | ||
use InvalidArgumentException; | ||
|
||
class Translator extends NamespacedItemResolver implements TranslatorContract | ||
{ | ||
|
@@ -406,6 +407,10 @@ public function getLocale() | |
*/ | ||
public function setLocale($locale) | ||
{ | ||
if (Str::contains($locale, ['.', '/', '\\'])) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mpyw
Contributor
|
||
throw new InvalidArgumentException('Invalid characters present in locale.'); | ||
} | ||
|
||
$this->locale = $locale; | ||
} | ||
|
||
|
2 comments
on commit c248521
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original vulnerability report to @taylorotwell:
Overview
Lang::setLocale()
unexpectedly accepts Directory Traversal Attack.
Files with*.php
or*.json
extension are includable.Reproduction
$request = Request::create('/', 'GET', [], [], [], [ 'HTTP_ACCEPT_LANGUAGE' => '../../composer', ]); Lang::setLocale($request->getPreferredLanguage()); dump(__('name')); // "laravel/laravel" dump(__('description')); // "The Laravel Framework."Proposal
Validate all path strings found in
Illuminate\Translation\FileLoader
methods.
loadNamespaceOverrides()
$file = "{$this->path}/vendor/{$namespace}/{$locale}/{$group}.php";
$namespace
should not contain..
.
segments.$locale
should not contain..
.
/
segments.$group
should not contain..
.
segments.
loadPath()
$full = "{$path}/{$locale}/{$group}.php"
$locale
should not contain..
.
/
segments.$group
should not contain..
.
segments.
loadJsonPaths()
$full = "{$path}/{$locale}.json"
$locale
should not contain..
.
/
segments.Target Branches
- 5.5
- 6.x
- 7.x
Hi Taylor,
I'm currently using Laravel for one of our projects and am wondering why you're checking for characters like '.', '/', '' when the default Accept-Language-Header from Mozilla and Chrome looks like this:
de,en-US;q=0.7,en;q=0.3
After an update my Project threw an InvalidArgumentException. I had to revert to an older version.
How are we expected to work with the exception? Is there a place where we have to catch it if it occurs?
Best regards