Jump to content


PHP Doc System 1.5.1 Security Patch


No replies to this topic

#1 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 04 April 2006 - 12:30 PM

Note (April 6,2006): A new patched version of Php Doc System has been released. I recommend that you upgrade to version 1.5.2 instead of applying my patch.



Quote

Vulnerability description:
Input passed to the "show" parameter in "index.php" isn't properly verified, before it is used to include files . This can be exploited to include arbitrary files from local resources or to view files from local resource.

http://pridels.blogspot.com/2005/11/php-do...local-file.html
My patch...


FIND in index.php:
if (!empty($_REQUEST["show"])) {
	$module = stripslashes($_REQUEST["show"]);
	require_once($content_dir.$module.'.php');
	$title = $application_name.': '.$$module->title;
}
else {
	$title = $application_name;
}
REPLACE WITH:
if (!empty($_REQUEST["show"])) {
  //filter
  if (preg_match('/^[0-9a-z_-]+$/i', $_REQUEST["show"])) {

	  $module = stripslashes($_REQUEST["show"]);
	  require_once($content_dir.$module.'.php');
	  $title = $application_name.': '.$$module->title;
  }
  else {
	$err_msgs[] = '<b>Error: No suitable input data.</b>';
  }
}
else {
	  $title = $application_name;
}
FIND in index.php:
if ($type == "static") {
	$file = fopen($output_dir.$_REQUEST["show"].'.html','w');
	if (!fwrite($file, $page)) {
		print('Error writing to '.$output_dir.$_REQUEST["show"].'.html');
	}
	fclose($file);
}
REPLACE WITH:
if ($type == "static") {
  //filter
  if (preg_match('/^[0-9a-z_-]+$/i', $_REQUEST["show"])) {  
	  $file = fopen($output_dir.$_REQUEST["show"].'.html','w');
	  if (!fwrite($file, $page)) {
		  print('Error writing to '.$output_dir.$_REQUEST["show"].'.html');
	  }
	  fclose($file);
  }
}
It may also be good to turn off error reporting in the top of index.php.
ini_set('display_errors', 0);
-=DKC=-


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users