WordPress REST API Security: Hardening Endpoints and Preventing Data Leaks
Did you know default WordPress REST API endpoints expose usernames? Learn how to restrict public REST API access and protect sensitive data.
The WordPress REST API provides incredible flexibility for modern integrations and mobile apps. However, out-of-the-box settings expose sensitive user records—such as author usernames and user IDs via `/wp-json/wp/v2/users`—making brute-force credential attacks remarkably easy for hackers.

The Information Disclosure Vulnerability
Even if your site disables author archive pages, automated cybercrime crawlers query the public REST API user endpoint to harvest administrator usernames, eliminating 50% of the effort required for brute-force attacks.
Hardening Strategies for the REST API
- Disable the Public Users Endpoint: Restrict
/wp-json/wp/v2/usersso only authenticated requests from logged-in administrators can view user directories. - Require Authentication for REST API Calls: Enforce authentication globally using the
rest_authentication_errorsfilter if your site does not require public API access. - Implement Application Passwords Securely: Never hardcode master admin passwords in external scripts; use dedicated, revokable Application Passwords.
- Deploy Cloudflare Rate Limiting: Cap API request frequency to 20 requests per minute per IP address to thwart scrapers and DDoS scripts.
Conclusion
Hardening your REST API endpoints blocks automated user enumeration scripts while preserving API functionality for authorized applications.




