Since WordPress 4.7, every site has a REST API at /wp-json/. It is how the block editor saves your pages, how many plugins load data, and how apps and headless front ends read content. It is also open to anyone on the internet, by default.
Most of what it exposes is public anyway: published posts and pages. But not all of it.
What anyone can read
Open https://yoursite.com/wp-json/ in a browser and you see a list of every route the site offers. Some interesting ones:
/wp-json/wp/v2/users: the users who have published something, with their slug, which on many sites is the login name./wp-json/wp/v2/posts,/pages,/media: published content, the same as on the site.- Routes added by plugins: contact forms, shops, page builders, search. Some are well written; some expose more than they should.
The users list is the one that matters most. Login names are half of a login. A bot that knows the usernames only has to guess passwords.
What attackers do with it
- Collect usernames for password guessing.
- Guess passwords through application passwords, which log in through the API.
- Probe plugin routes for known weaknesses. Several serious plugin vulnerabilities in recent years were REST routes that forgot to check who was asking.
What not to do
Turning the REST API off completely breaks the block editor, many contact forms, WooCommerce blocks, embeds and anything headless. Plugins that “disable the REST API” usually only disable it for visitors who are not logged in, which is the right idea, but done bluntly it still breaks forms that visitors send through the API.
The balanced approach
Limit what visitors who are not logged in can reach, and keep everything open for logged-in users. In Keel › API & Headless › REST API access, switch on Limit the REST API for visitors. Visitors can then only reach the routes in Parts that stay open. The defaults keep embeds, Contact Form 7, WooCommerce blocks, Gravity Forms and Jetpack working. This is in the free version.
If a form or block stops working afterwards, the browser’s developer tools show the blocked /wp-json/ request; add the start of its route to the list.
A lighter option, if apps need to read your content: leave the API open, and switch on Hide usernames in Hardening › WordPress, which removes the user list and stops ?author=1 addresses revealing login names.
Application passwords
Application passwords let apps log in to the API without two-factor login. If nothing on your site uses them, turn them off in Hardening › WordPress. If something does, Keel Pro can count wrong application passwords as failed logins, so bots guessing them get blocked.
Headless sites
A headless front end reads everything through the API, so limiting it would break the site. Keel’s headless mode keeps the API fully open and skips the firewall for it, while protecting the login and wp-admin as usual. See Headless mode.
Checklist
- Open
/wp-json/wp/v2/userson your site in a private window. If it lists users, close it. - Limit the API for visitors, or hide usernames.
- Turn off application passwords if you do not use them.
- Keep plugins updated: REST routes are a common place for plugin holes.
Common questions
Does limiting the REST API break the block editor?
No. Logged-in users keep full access, and the editor is only used by logged-in users.
Can I just hide /wp-json/ from the page source?
Hiding the link does not close anything: the API still answers at the same address. Limit access instead.
Is the REST API a vulnerability in itself?
No. It is a normal, well-maintained part of WordPress. The risk comes from what it exposes by default and from plugin routes with mistakes.