Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative path security issue #91

Closed
nickgardos opened this issue Mar 16, 2015 · 2 comments
Closed

Relative path security issue #91

nickgardos opened this issue Mar 16, 2015 · 2 comments

Comments

@nickgardos
Copy link
Contributor

Hello,

I am using simple-ajax-uploader for a big project and as usual before I push 3rd party code on production I inspect the code. Sadly I found a big security issue with this one...

A user is able to upload a file using the XHR uploader and set a filename of this type: ../../test.txt
All you have to do is to open your browser dev tools and go to the network tab. First upload the test.txt as you would normaly do, and after the upload finishes, click on the logged connection and select Edit and resend. Then, simply change the filename to something like this: ../../test.txt. From my tests the file will be not saved in the upload dir but 2 directories up (or wherever you point it).

To fix this security hole just replace line 93 on Uploader.php with the following:

$this->fileName = str_replace(array('/','\\'),'_',$this->handler->getFileName());
@nickgardos
Copy link
Contributor Author

Version 2 is also vulnerable. All you have to do is edit the X-File-Name header to something like this: ../../test.txt

To fix v.2 simple add after line 69:

$this->fileName = str_replace(array('/','\\'),'_',$this->fileName);

@LPology
Copy link
Owner

LPology commented Mar 17, 2015

Nice catch. Just merged your pull request.

@LPology LPology closed this as completed Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants