Short answer: do not disable the WordPress REST API entirely, because the block editor and many plugins depend on it. Instead, keep WordPress and plugins updated (most REST API risk comes from badly coded plugin endpoints), block anonymous access to the users endpoint to reduce username enumeration, require authentication for endpoints that do not need to be public, manage application passwords carefully, and add rate limiting or firewall rules for login-related routes.
The REST API, available at /wp-json/, lets applications read and write WordPress data using HTTP requests. It powers the block editor, mobile apps, headless sites and countless plugins. By design, it exposes publicly available information such as published posts and pages to anyone, and allows changes only to authenticated users with the right permissions.

What the REST API exposes by default
Anonymous visitors can read anything that is already public on your site: published posts, pages, categories, tags, media details and comments. They cannot read drafts, private posts, settings or email addresses, and they cannot make changes without authentication. One endpoint attracts most attention: /wp-json/wp/v2/users, which lists users who have published posts, including their usernames (the “slug”). Attackers use this for user enumeration, collecting usernames to target with password-guessing attacks.
Exposing usernames is not a vulnerability in itself; strong passwords and two-factor authentication make the information far less useful. But limiting it removes an easy step for attackers.
The real risk: plugin endpoints
Plugins register their own REST routes. When a developer forgets a proper permission_callback, or sets it to allow everyone, an endpoint meant for administrators can be called by anyone. Many serious WordPress vulnerabilities disclosed in recent years, including privilege escalation and data exposure issues, came from exactly this mistake. WordPress now shows a notice to developers if a route is registered without a permission callback, but the safest defence for site owners is keeping plugins updated and removing ones you do not need. See WordPress plugin vulnerabilities.
Step 1: Reduce user enumeration
You can restrict the users endpoint to logged-in users with a small code snippet in a site-specific plugin or your theme’s functions.php, using the rest_endpoints filter to remove /wp/v2/users routes for anonymous requests, or with a reputable security plugin that offers this option. Also consider that usernames can be discovered through author archive URLs (/?author=1), so security plugins often block both. Make sure display names differ from login usernames.
Step 2: Require authentication where possible
If your site does not serve REST data to the public, for example a brochure site with no headless front end or public apps, you can require authentication for all REST requests from non-logged-in users using the rest_authentication_errors filter. Test carefully: contact forms, caching, SEO and e-commerce plugins sometimes call the REST API from the front end, and blocking anonymous access can break them. Some security plugins offer this with exceptions for specific plugins.
Step 3: Manage application passwords
Since WordPress 5.6, users can create application passwords for REST API and XML-RPC access. They bypass two-factor authentication by design, so they are powerful. Review them under Users > Profile > Application Passwords for every administrator, revoke any you do not recognise, and give integrations dedicated users with the lowest role needed. If you do not use them, you can disable the feature with the wp_is_application_passwords_available filter. Attackers who gain admin access sometimes create application passwords as a persistent backdoor, so check this after any incident.

Step 4: Rate limit and firewall
A web application firewall (WAF), whether a plugin, your host’s firewall or a service such as Cloudflare, can rate limit requests to /wp-json/, block known malicious patterns and stop scanning bots. Pay particular attention to plugin routes that perform logins, password resets or form submissions, and to XML-RPC (xmlrpc.php), which is a separate API often abused for brute-force attacks. Disable XML-RPC if you do not use it.
Step 5: Use HTTPS and review CORS
Always serve the API over HTTPS so cookies and credentials are encrypted. If you build headless or cross-domain applications, set Cross-Origin Resource Sharing (CORS) headers to allow only the domains you trust rather than any origin.
Step 6: Monitor
Review server logs for heavy traffic to /wp-json/ endpoints, especially POST requests to plugin routes. Spikes often indicate scanning for a newly disclosed plugin vulnerability. Combine this with file-change monitoring and alerts for new administrator accounts.
Frequently asked questions
Should I disable the REST API completely?
No. The block editor and many plugins need it. Restrict sensitive parts instead.
Is user enumeration a vulnerability?
It is information disclosure that helps attackers. WordPress does not treat it as a vulnerability, but limiting it is sensible hardening.
Do application passwords weaken security?
They are safe when used carefully, but they bypass two-factor authentication, so revoke unused ones and limit who can create them.
How do I test what my API exposes?
Visit yoursite.com/wp-json/ and /wp-json/wp/v2/users in a private browser window while logged out.
Related: stop WordPress brute force attacks, add 2FA to WordPress.



