Jump to content

The security of reading files?


davej

Recommended Posts

Does the presence of a Php file like this pose a security risk?

<?php   header("Content-Type: application/octet-stream");   header("Content-Disposition: attachment; filename=".$_GET['path']);    readfile($_GET['path']);?>
Link to comment
Share on other sites

If you have your database login information in a file anywhere then this is a security threat.

 

To be safe, remove any / or from the path and restrict the files to one directory that you know doesn't have sensitive information.

 

Using file_exists() first to show an error if the file isn't found would also be a good idea.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...