Jump to content

preventing Remote File Inclusion


jeff5656

Recommended Posts

That would always be true, so it's pretty pointless. What exactly are you trying to prevent? No one can just include your PHP files and get the code; if that's what you're trying to prevent.

Link to comment
Share on other sites

Ok thats good.  But then why are all these sites out there warning about "remote file inclusion"vulnerabilities and talking about functions etc to prevent it.

In my code all I do is:

 

include "file.php";

 

Are these includes not vulnerable?

Link to comment
Share on other sites

Yes, if you are including a file based on a GET parameter passed to your code, you must validate that the file name is just an allowed value (which will eliminate those cases where it is an actual URL of some raw php code on a hacker's site.)

 

Also, you must validate the file name in the context where it is being included (only allow the correct files to be included on any particular page.) This is needed to prevent someone on your site from including say an administrative file on your site when they are only a guest on your site.

 

Edit: If you are including a literal file name, as in include "file.php";, then no, that is the only file that can possibly be included by that line of code.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.