问题描述

我使用的是 WordPress v.4.1,所有的插件和主题都是最新的。

我在日志文件中看到太多这些…

xxx.xxx.xxx.xxx - - [02/Jan/2015:13:30:27 +0200] "POST /wp-cron.php?doing_wp_cron=1420198227.5184459686279296875000 HTTP/1.0" 200 - "-" "WordPress/217; http://www.example.com"

其中 xxx.xxx.xxx.xxx 是网站托管的服务器的 IP 地址,「http://www.example.com」 是我的网站。

是否有一个已知的影响 wp-cron.php 的漏洞 (漏洞)?有没有办法”protect” 的文件?

谢谢!

最佳解决方案

wp-includes/default-filters.php 中,我们可以找到一个回调注册:

// WP Cron
if ( !defined( 'DOING_CRON' ) )
    add_action( 'init', 'wp_cron' );

如果我们现在去功能 wp_cron(),我们看到:

$schedules = wp_get_schedules();
foreach ( $crons as $timestamp => $cronhooks ) {
    if ( $timestamp > $gmt_time ) break;
    foreach ( (array) $cronhooks as $hook => $args ) {
        if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
            continue;
        spawn_cron( $gmt_time );
        break 2;
    }
}

spawn_cron()发送您在日志中看到的 POST 请求:

$doing_wp_cron = sprintf( '%.22F', $gmt_time );
set_transient( 'doing_cron', $doing_wp_cron );

/**
 * Filter the cron request arguments.
 *
 * @since 3.5.0
 *
 * @param array $cron_request_array {
 *     An array of cron request URL arguments.
 *
 *     @type string $url  The cron request URL.
 *     @type int    $key  The 22 digit GMT microtime.
 *     @type array  $args {
 *         An array of cron request arguments.
 *
 *         @type int  $timeout   The request timeout in seconds. Default .01 seconds.
 *         @type bool $blocking  Whether to set blocking for the request. Default false.
 *         @type bool $sslverify Whether SSL should be verified for the request. Default false.
 *     }
 * }
 */
$cron_request = apply_filters( 'cron_request', array(
    'url'  => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ),
    'key'  => $doing_wp_cron,
    'args' => array(
        'timeout'   => 0.01,
        'blocking'  => false,
        /** This filter is documented in wp-includes/class-http.php */
        'sslverify' => apply_filters( 'https_local_ssl_verify', false )
    )
) );

wp_remote_post( $cron_request['url'], $cron_request['args'] );

在这里,您还可以看到浮点数来自哪里:它作为参数传递以识别瞬态。

完全不用担心。

参考文献

注:本文内容整合自 Google/Baidu/Bing 辅助翻译的英文资料结果。如果您对结果不满意,可以加入我们改善翻译效果:薇晓朵技术论坛。