How it started
Recently, while checking my site's access logs, I noticed a large number of POST requests to /xmlrpc.php.
Judging by the requesting IP — 52...64 — and the request frequency, it was clearly a malicious automated program.
By repeatedly POSTing pre-constructed payloads, it tries to brute-force the WordPress admin password.
xmlrpc.php was originally an API page WordPress left for mobile apps. Attackers use it to brute-force the backend admin password.
Let's not discuss defense yet, and not discuss whether the brute-force can succeed. First I followed this IP back to its earliest access records.
Records 1 and 2
Request: the automated attack program first made two GET requests to my site's homepage.
Purpose: presumably to check whether the site is online.
Record 3
Request: it constructed a GET to https://domain//wp-includes/wlwmanifest.xml
Purpose: presumably to determine whether you're running WordPress.
Records 4–6
Request: it constructed //?author=1 //?author=2 //?author=3
Purpose: presumably to determine your admin username through the user ID!
Record 7
Request: it constructed a GET to https://domain//wp-json/wp/v2/users/
Purpose: to re-confirm whether your admin username is correct!
Record 8
Request: it constructed a GET to //wp-json/oembed/1.0/embed?url=xxx
Purpose: my guess is this targets an old WordPress vulnerability, CVE-2017-6514.
Through these 8 requests, the automated attack program has already obtained your [admin username],
and can then keep brute-forcing your /xmlrpc.php page with constructed POST requests to guess your password.
Of course the success rate of brute-forcing is tiny — anyone who takes WordPress security even slightly seriously has long since hidden the login page or disabled xmlrpc.php entirely.
But in a default, non-hardened state, having your admin username taken by an attacker still feels bad.
You can test your own WordPress site with the URLs above and see whether sensitive information leaks:
http://your-domain/wp-includes/wlwmanifest.xml
http://your-domain/wp-json/wp/v2/users/
The fix
Add the following code to the functions.php file in your current theme directory:
// Disable wp-json/wp/v2/ when not logged in, to prevent information leakage
add_filter( 'rest_authentication_errors', function( $result ) {
if ( ! empty( $result ) ) {
return $result;
}
if ( ! is_user_logged_in() ) {
return new WP_Error( 'Access denied', 'You have no permission to handle it.', array( 'status' => 401 ) );
}
return $result;
});
Quantum Responses (0)