Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid user to go ../../ [closed]

Tags:

php

apache

lamp

I have LAMP installed in my server and I use virtualhosts to map domains to subdirectories. I need to allow my customers to upload files (including php) to their server using FTP.

The problem is that a customer using a domain xxx.com.br uploaded a file test.php and executed it like:

xxx.com.br/test.php

The content of test.php if file_put_contents("../../xxx.txt","teste") and it worked! The file xxx.txt was created 2 levels above his domain folder! How do I prevent this from happening?

like image 969
amandanovaes Avatar asked Apr 29 '26 00:04

amandanovaes


1 Answers

Don't give the PHP process access to directories it isn't meant to reach.

That's kind of the point of the whole permission system.

In Linux, PHP will generally run as its own user, just make sure that user doesn't have read or write permission to any files you don't want exposed.

like image 183
Madara's Ghost Avatar answered May 01 '26 13:05

Madara's Ghost



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!