I have recently taken over maintenance for a small WP site and when I installed AOIS it told me to not make the admin username visible on the site. But there were still many failed login attempts with that username, so I removed the old admin account and added a new one (hard to guess). Now I get failed login attempts using the new login name even though I have blocked user enumeration etc. Can you spot if there is some setting I missed that allows hackers to find the admin username?
My problem was (as it is/was for many people) that the user names were coming from a known security issue with the REST API endpoints; this one in particular: /wp-json/wp/v2/users/1 as in https://wordpresssite.com/wp-json/wp/v2/users/1.
This allows either an anonymous user OR a logged-in user to enter that URL and retrieve the names and ids of users, including admin users. All they have to do is cycle through the id number at the end of the query.
Turning off the REST API endpoint through AIOS does not completely solve the problem as that only affects non-logged-in users. If a hacker gets an account on your machine and logs in, then they can just enter the same wp-json endpoint and once again retrieve the user information (I verified the operation).
The way I solved the problem was by doing this (with the disable_rest_endpoints function):
https://wordpress.org/support/topic/renamed-login-page-and-usernames-detected/
That solved my problem and I apparently am not using any plugin/feature that currently requires the REST API user endpoints.
https://security.stackexchange.com/questions/66272/wordpress-brute-force-attacker-knows-real-admin-username
Simon Guetta





Finally I found out that the problems started after upgrading the php version from 7.3 to 7.4, because my host has depreciated the .htaccess in the new php version. So I managed with the host to apply nginx rule so to block “xmlrpc.php” Now the …/xmlrpc.php returns “502 Bad Gateway” and the login attempts through the renamed login page have stopped. We have set nginx rules to block also the wp-config.php, license.txt, wp-config-sample.php, readme.html, and debug.log, but I think it was the xmlrpc which was giving the problem – just as you stated in your first reply, right?
There is also a solution to block xmlrpc with the function:
add_filter(‘xmlrpc_enabled’, ‘__return_false’);
Regarding my question about how usernames are detected I have found that although user enumeration is blocked through AIOWPS there is still a door to find the usernames through entering …/wp-json/wp/v2/users/* in the browser address bar. By replacing the * with the number of an existing user you can see next to the “name” the public name and next to the “slug” the secret username. I tried the feature of AIOWPS which stops REST API access for non-logged in requests, but this seems to interfere with my Ninja Form plugin as it stops in the processing step.
So I tested the following function:
function disable_rest_endpoints ( $endpoints ) {
if ( isset( $endpoints[‘/wp/v2/users’] ) ) {
unset( $endpoints[‘/wp/v2/users’] );
}
if ( isset( $endpoints[‘/wp/v2/users/(?P[\d]+)’] ) ) {
unset( $endpoints[‘/wp/v2/users/(?P[\d]+)’] );
}
return $endpoints;
}
add_filter( ‘rest_endpoints’, ‘disable_rest_endpoints’);
which at entering …/wp-json/wp/v2/users/1 returns
code:”rest_no_route”,
message:”No route was found matching the URL and request method”
data:“”
status:“404”
Could I have your opinion about the efficiency of the above 2 functions for disabling xmlrpc and for disabling JSON REST endpoints?
Would it be possible to ask your developers to consider using these 2 functions into the AIOWPS plugin?
Best regards,