Jump to content

is my code subject to Remote File Inclusion RFI ?


vin_akleh

Recommended Posts

Yes, you can be abused. How you go about it depends on what the requested file is. If they are store in a folder like "contents" of something that is part of a CMS it could be as simple as:

$page=$_REQUEST['page'];

if(file_exists("$path/to/content/folder/$page.php"))

include the page

else

redirect to index page with no notification as to what or why

 

or you may want to take the request and do a basename on it and then add the proper path and check if its alive.  You could scan all of the pages allowed into an array and if the request is in array_search then include it. There are numerous ways to do it but your present way is not one of them.

 

 

HTH

Teamatomic

Link to comment
Share on other sites

CMS= Content Management System

For what you are doing all you need to do is make sure the file exists on your site and its one you want to display. Just make sure the url/path you use is your own. For example, if you allow remote file opening. Say you have a page named about.php. If you just check that the page requested "about.php" exists on your site and you allow it to be display it does not good if you go ahead and then use _$REQUEST['page']. Instead use your own path/url. Cause if you do a basename and get "about.php" from the request then go ahead and use the request to include the page you might get something equal to:

include("http://www.mySite/about.php"). And the about.php from mySite might just be a file manager written in PHP.

 

 

HTH

Teamatomic

Link to comment
Share on other sites

is this the solution??

of course the $path should be preseted

		if (isset($_REQUEST["page"]))
	{
		$page=$_REQUEST['page'];
		if(file_exists("$path/$page.php"))
		include "*/".$_REQUEST["page"].".php";
	}
	if (isset($_REQUEST["logout"]))
	{
		$logout=$_REQUEST['logout'];
		if(file_exists("$path/$logout.php"))
		include "logout.php";
	}

Link to comment
Share on other sites

just to make sure, this is it

		if (isset($_REQUEST["page"]))
	{
		$page=$_REQUEST['page'];
		fn=basename($page)
		if(file_exists("$path/$fn.php"))
		include"$path/$fn.php";
	}
	if (isset($_REQUEST["logout"]))
	{
		$logout=$_REQUEST['logout'];
		fn=basename($page)
		if(file_exists("$path/$fn.php"))
		include"$path/$fn.php";
	}

????????????????????? :confused:

Link to comment
Share on other sites

ow ya i forgot about the

if (isset($_REQUEST["page"]))
	{
		$page=$_REQUEST['page'];
		$fn=basename($page);
		if(file_exists("$path/$fn.php"))
		include"$path/$fn.php";
	}
	if (isset($_REQUEST["logout"]))
	{
		$logout=$_REQUEST['logout'];
		$fn=basename($page);
		if(file_exists("$path/$fn.php"))
		include"$path/$fn.php";
	}

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.