| 开发者 | clearcomet |
|---|---|
| 更新时间 | 2026年11月11日 17:15 |
| PHP版本: | 8.3 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
mcp routes, the Abilities API, and MCP servers added by other plugins. Those routes are listed in the public /wp-json index unless something removes them.
A new install starts paused. Cloak saves that explicitly (on is false) and shows a notice, with Turn on and a link to the settings screen, until you turn it on. The switch on that screen shows Paused. Updating from an older version does not change your on/off choice. A site that was already protected stays protected, including one that never saved a settings row (on those versions, no row meant on).
Once Cloak is on, the default door mode is lights out. A stranger who requests a hidden route gets WordPress's ordinary not-found answer (rest_no_route, 404), and those routes are left off the public /wp-json index. You do not have to create a key. Who gets in:
X-WP-Nonce or _wpnonce). The block editor does this. A cookie with no nonce does not count. An application password does not count unless you turn that rule on.cloak_allow_authenticated_users filter.X-Cloak-Key header (optional, Advanced). The older X-BlindPig-Key header still works.401 and WWW-Authenticate on its first, still-anonymous request. Anyone who already knows the address can tell the route exists..well-known OAuth files are not hidden. /.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server, including path-scoped copies, can name your MCP address. Cloak leaves them up so other OAuth uses on the site keep working. The first anonymous request to the MCP address is still a 404 in the default mode. The follow-up request gets through only after WordPress has accepted the login, or you have allowed a key, an address, or Unlisted mode.
WordPress still checks its own login after Cloak lets a request through. Cloak does not replace application passwords, and an application password alone does not get past Cloak.
Why this matters
People are already scanning the internet for MCP servers:
initialize handshakes POSTed to /mcp from 49 different IP addresses, on a server that runs no MCP at all. SANS Internet Storm Center, diary 33150/wp-json route list; it is fixed in 3.1.4. Wordfence/wp-json/mcp/v1/. Rapid7 Metasploit, Packet Storm via VulnersCLOAK_DISABLED in wp-config.php still forces Cloak off.
Everyday use
Settings > Cloak for MCP shows one door-slot switch and one line telling you whether you're protected. Click the slot to pause or resume. Everything else is optional and lives on the Advanced pages: doors, the guest list, a secret key for your own apps, Cloudflare, access rules, an activity log and tools (export/import).
Secret key (optional)
You don't need a key. It's only for your own apps or scripts that connect from changing addresses. Generate a key, or paste your own (20+ characters: letters, digits, _ and -). Apps send it in the X-Cloak-Key header. Rotate keeps the old key working for 24 hours so you can update your apps; Turn off stops it. The key page has ready-made snippets for a desktop AI assistant, curl and n8n.
Cloak stores only a fingerprint of the key (a salted HMAC-SHA256), never the key itself, so a new key is shown once, right after it is made. Lost it? Make a new one. Keys are never exported and are compared in constant time.
Cloudflare
Cloak trusts the CF-Connecting-IP header only when the request really comes from one of Cloudflare's published ranges. X-Forwarded-For is never used. The plugin ships with Cloudflare's list (checked 2026-10-06); Refresh from Cloudflare on the Guest list page downloads the current official list from Cloudflare's public API over a checked HTTPS connection, and keeps the old list if anything looks wrong.
Advanced: wp-config.php overrides
These optional constants pin a setting in code. The matching field shows as locked on the settings screen. They apply once protection is on, except CLOAK_DISABLED, which always switches protection off.
define( 'CLOAK_KEY', 'your-long-random-key' ); (20+ characters; works alongside a key made on the screen)
define( 'CLOAK_GUESTS', array( '203.0.113.7', '198.51.100.0/24' ) );
define( 'CLOAK_MODES', array( '/acme/v1' => 'lights_out' ) ); (modes: open, unlisted, lights_out)
lights_out (the default) answers 404 and hides the route from the index. unlisted hides the route from the index and lets the address itself answer, which is what an OAuth client needs in order to see 401. open leaves the route unchanged.
define( 'CLOAK_DISABLED', true ); (emergency off switch)
Advanced: filters for developers
cloak_presets: change or add guest presets. Each preset is id => array( 'label' => ..., 'cidrs' => array( ... ) ). A single cidr string is still accepted. Presets stay off until an administrator adds them. The older blindpig_presets filter still runs first.cloak_cf_ranges: change the Cloudflare ranges used to trust CF-Connecting-IP.cloak_client_ip: supply the visitor address yourself if your site sits behind another trusted proxy. It must return a valid IP.cloak_allow_authenticated_users: default true. When true, a user WordPress has already logged in for this REST request may use a hidden route, unless that login is an application password or a cookie session (those keep their own rules). Return false to require a Cloak key, a guest address, or a browser nonce as well. Cloak never treats the Authorization header, by itself, as a login. The older blindpig_allow_authenticated_users filter still runs first.MCP (Model Context Protocol) is the open standard AI assistants and bots use to talk to other software. On WordPress, the MCP Adapter and the Abilities API add web addresses ("doors") that let an AI assistant read and change your site, if it has a valid login. Those doors are listed publicly by default, so anyone can see they exist and start trying them.
On a new install, nothing is hidden until you turn Cloak on. After that, a default (lights out) door returns WordPress's standard rest_no_route 404, and the route is removed from the public /wp-json index and from that namespace's listing. Pages, posts, wp-admin, and REST routes that are not hidden doors are left as they are. .well-known OAuth documents are not doors, so they stay public. OPTIONS on a hidden route can still return an empty JSON list with status 200.
No. A site updated from 4.0.7 or earlier keeps its current on/off state. If that site never saved a settings row, it stays on, because that is what the older plugin did. A brand-new install is the one that starts paused.
For the browser rule: a cookie session plus a valid WordPress REST nonce. The block editor sends this. An application password does not count as that browser session. A cookie with no nonce does not count: WordPress treats that request as logged out before Cloak runs. A login some other plugin has already accepted, such as a checked token, is a separate rule and does count unless you filter it off.
Any one of these, and then the app's normal WordPress login if the route itself requires one:
X-Cloak-Key header (Advanced > Secret key). The older X-BlindPig-Key header still works. Use this for your own scripts.401 and WWW-Authenticate instead of a 404. People who know the URL can tell the route exists.They can. Cloak does not remove /.well-known/oauth-protected-resource or /.well-known/oauth-authorization-server, including path-scoped copies under that prefix. Those files are how some AI assistants and bots discover where to go, and other OAuth software on the same site may need them. The first anonymous request to the MCP address is still a 404. A later request gets through when WordPress has accepted that login. A rejected token stays a 404.
The browser rule is on by default, so the dashboard and the block editor keep working when they send the REST nonce. If something still goes wrong, any one of these makes every door visible again:
define( 'CLOAK_DISABLED', true ); to wp-config.php. This kill switch works even if you can't reach wp-admin.No. There is no tracking, telemetry, account or license check. The only outside request is the optional, manual Cloudflare list refresh described under "External services". The activity log stays in your own database, never records headers or keys, and is deleted with the plugin.
That works out of the box. Cloak reads the visitor's real address from CF-Connecting-IP only when the request arrives from Cloudflare's own ranges, so nobody can fake it. If you use a different proxy or load balancer, use the secret key for your apps rather than address-based helpers.
Cloak stores only a salted fingerprint of a key made on the settings screen, so even someone who can read your database can't use it. That's why a key is shown once, right after it is made. If you lose it, make a new one (or Rotate under Advanced, which keeps the old key working for 24 hours).
CLOAK_KEY in wp-config.php is plain text in that file. Protect that file as you would your database password.Cloak's default doors are the mcp namespace and the Abilities API routes. Other plugins' MCP routes under /mcp are covered by that same door. Routes outside those prefixes are not hidden. Whether a given assistant can connect depends on the door mode and on how that assistant authenticates. See "How do I let an app in?" above.
The first anonymous request on the default door is still a 404, with no WWW-Authenticate header. Set the door to Unlisted if the assistant must see that header before it can log in. After WordPress has accepted the token, the same default door lets the request through. Cloak does not inspect the Authorization header: a wrong or expired token, which WordPress does not accept, is still a 404. An application password is not this kind of login. A secret key or a guest IP also lets a request through. Return false from cloak_allow_authenticated_users if you want every assistant to need a Cloak key or a guest address even after WordPress has logged it in.
Activate Cloak. Hidden routes are removed from the public /wp-json index. On the default mode, a direct request gets rest_no_route 404. Other REST routes are left as they are. .well-known OAuth documents are not removed.
No. App passwords (or any other authentication) are still checked after the door. Cloak adds a lock; it never removes one.
on as false and a setup-pending marker, and shows a notice with Turn on until you turn it on. That notice is not dismissible. After you turn it on, the dismissible "Cloak is on" notice appears.cloak_allow_authenticated_users (default true) can turn that off. Application passwords stay opt-in..well-known OAuth files can name the MCP address and are not hidden. Unlisted is how an assistant gets 401 on its first anonymous request. The default for that first request remains a 404.clearcomet-cloak-for-mcp, settings under Settings > Cloak for MCP).api.cloudflare.com/client/v4/ips); same validation and fallback.Update URI header.