If logged in as an administrator of any WordPress blog on a WordPress multisite, you can run arbitrary code and completely compromise the system by using the setup page for the Redirection plugin.
This is done by writing the URL to redirect to in the format file://path/to/file/here. Unfortunately the plugin executes any PHP within that file. This means that any file with any extension on the filesystem that contains a small amount of user controlled data can be turned into a back door. The plugin also has the functionality to create files and place user controlled data in them. This results in attacker controlled code running and complete compromise of the system.
When the code for handling a redirect looks at the URL to redirect to it does the following:
class Pass_Action extends Red_Action {
function process_before( $code, $target ) {
// Determine what we are passing to: local URL, remote URL, file
if ( substr( $target, 0, 7 ) === 'http://' || substr( $target, 0, 8 ) === 'https://' ) {
echo @wp_remote_fopen( $target );
die();
}
else if ( substr( $target, 0, 7 ) === 'file://' ) {
$parts = explode( '?', substr( $target, 7 ) );
if ( count( $parts ) > 1 ) {
// Put parameters into the environment $args = explode( '&', $parts[1] );
if ( count( $args ) > 0 ) {
foreach ( $args as $arg ) {
$tmp = explode( '=', $arg );
if ( count( $tmp ) === 1 )
$_GET[ $arg ] = '';
else
$_GET[ $tmp[0] ] = $tmp[1];
}
}
}
include( $parts[0] );
exit();
}
else {
$_SERVER['REQUEST_URI'] = $target;
if ( strpos( $target, '?' ) ) {
$_SERVER['QUERY_STRING'] = substr( $target, strpos( $target, '?' ) + 1 );
parse_str( $_SERVER['QUERY_STRING'], $_GET );
}
}
return true;
}
}
The above code behaves as expected if the URL to redirect to is an HTTP or HTTPS URL.
If the URL begins with file://
, it passes the path to the include function.
Its also worth mentioning that if the URL is not HTTP, HTTPS or File, then the code allows the $_GET
parameter to be contaminated with unescaped values, which may result in SQL injections.
Upgrade to version 2.8 or later.