Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During my research on the
laravelmedia-library
package source I figured out that two helper/Support functions on this package making problems in real-life cases, The first one wasgetHumanReadable()
support function which if it receives a negative value or 0, the value will still be negative or it will return the (0) value as (0 KB) which is not relevant because the value of (0) means that there's no data inside a file so it should display (0 B) as it's more relevant and describe that the file has no data on it like it may be an empty .txt file, I know this may not happen in real life development as the function is being used internally, but the calculation of the function is wrong and may cause problems in future, So the function has been refactored and the mentioned bugs have been fixed you can test it inphp artisan tinker
command from both my fixes & the previous code to assure that it's a good commit.Second, the
createMultipleFromRequest()
function from theFileAdderFactory::class
seems to be vulnerable with an LFI (Local File Inclusion) vulnerability, to prove it you can execute this part of the code on thephp artisan tinker
console:I know that this command is just an execution of a malicious payload and not related to the function somehow, but I've provide that to prove that the filtration that has been done on the file is not working well and it's vulnerable to LFI, so thinking of the vulnerable function pushes me to fork the repo to make the package safer as it's the biggest one that is mostly being used on laravel applications.
And it's worth mentioning to say that if you chain the above payload mechanism you can actually bypass the filtration and force the function to upload an internal server file like
/etc[/hosts, /passwd, /shadow, ...etc]
to the storage bucket of the Laravel application that is using this file, it can be done by manipulating the HTTP POST request that accepting themultipart/formdata
header, it's doable as the user has access over thecreateMultipleFromRequest()
method using some other methods on the Traits.In the end, thanks for your time in reading my explanation, I'll be happy to be a collaborator in this repo if it finds me creative and reasonable to be.
Cheers,
Ehsan Faramarz - TheXerr0r