Ticket #4759 (closed enhancement: duplicate)

Opened 4 years ago

Last modified 4 years ago

Blank index.php in wp-content subdirs

Reported by: ozh Owned by: anonymous
Priority: normal Milestone:
Component: Security Version:
Severity: normal Keywords: index opendir security
Cc:

Description

Ola

Directory /wp-content has had its "Silence is golden" blank index page for years now, why not add this file by default to /plugins & /themes ?

It would greatly reduce script kiddies ability to find exploitable plugins ( example)

Change History

+1 I concur.

Not sure whether it's worth making "diffs" in this circumstance, really.

Would index.html be better than index.php? There would be no risk of any code executing *ever* by accident.

Either way, there should be a comment explaining why the file is blank and that it should be kept that way.

Alternatively, rewrite rules might be better, since you could redirect the user to a legit page (like the root) in case they were walking up a URL.

Ciao!

comment:3   Ozh4 years ago

  • Keywords has-patch added
  • Type changed from enhancement to defect
  • Component changed from Security to Administration
  • Severity changed from trivial to normal
  • Summary changed from Blank index.php in wp-content subdirs to Blank index.php in wp-content subdirs (proposal + bug patch)

As of now there is a bug (feature?) making the Dashboard default page display the content of any 'index.php' that might exist in /wp-content/plugins/ I think this is a bug because index.php might not be a plugin

Here is a proposal for a fix of this behavior (sorry, I have nothing like svn or patch on the machine I'm on right now).

1) A new function (in wp-admin/includes/plugins.php would be appropriate)

/**
 * Checks if a file is (seems to be) a plugin - Ozh
 * @param	string	$plugin_file	full path to a file
 * @return 	boolean
 */
function is_pluginfile($plugin_file) {
	if ( !is_readable( $plugin_file ) or substr($plugin_file, -4) != '.php' )
		return false;
		
	$plugin_data = get_plugin_data( $plugin_file );

	if ( empty ( $plugin_data['Name'] ) )
		return false;

	return true;
}

2) Changes to /wp-admin/menu-header.php

Replace every file_exists with is_pluginfile

3) If this patch is accepted, function get_plugins() from /wp-admin/includes/plugins.php could use is_pluginfile() as well with an improved test on line 73:

line 73 -- 		if ( !is_readable( "$plugin_root/$plugin_file" ) )
line 73 ++ 		if ( !is_pluginfile( "$plugin_root/$plugin_file" ) )

comment:4   Ozh4 years ago

  • Keywords has-patch removed
  • Type changed from defect to enhancement
  • Component changed from Administration to Security
  • Summary changed from Blank index.php in wp-content subdirs (proposal + bug patch) to Blank index.php in wp-content subdirs

Sorry for the mess, the previous reply & patch was incomplete. See #4787 for a more complete problem analysis & patch. Ticket changed to be just a blank index.php proposal, as an easy and trivial "security" enhancement

  • Status changed from new to closed
  • Resolution set to duplicate
  • Milestone 2.3 deleted

Closing as dup of #4787.

Note: See TracTickets for help on using tickets.