Threat Intelligence

How TRUST#GRAFT uses a WordPress admin session to install a backdoor

(Adobe Stock)

COMMENTARY: WordPress administrators often move between the dashboard and public pages while working on a site. They might update a page, check how it looks, and return to make another change. Staying logged in makes that work easier. It also leaves the browser able to perform administrative tasks while the user reviews content that may contain malicious code.

TRUST#GRAFT -- a JavaScript-to-WordPress attack chain that turns a trusted administrator browser into the deployment path for a persistent WordPress backdoor -- takes advantage of that overlap. In the attack chain analyzed by our researchers, JavaScript running on a WordPress site checks whether the visitor is logged in with permission to install plugins. If so, it attempts to use that session to install a backdoor. The administrator does not have to choose a plugin or approve its installation.

[SC Media Perspectives columns are written by a trusted community of SC Media cybersecurity subject matter experts. Read more Perspectives here.]

This creates a problem for security teams reviewing the activity afterward. The installation can come from the administrator’s browser, through the same WordPress features used for routine maintenance. Finding it requires looking beyond failed logins and unfamiliar accounts to changes an authorized user never meant to make.

What happens behind the verification screen

The script covers the page with a fake Cloudflare-style verification screen. While the visitor waits, it collects information about the browser and contacts an attacker-controlled server for further content.

The code also supports a ClickFix-style lure, which can attempt to copy a command to the visitor’s clipboard. These lures typically try to persuade people to paste and run a command under the pretext of fixing a problem or completing verification. The recovered code does not establish that a victim actually ran one.

The WordPress installation attempt does not depend on someone following those instructions. The script requests the plugin-upload page and retrieves a nonce, a security token WordPress uses to help validate the request. It then downloads a ZIP file containing the malicious plugin, uploads it and attempts to activate it.

For this to work, the malicious script has to run on the WordPress site while the visitor is logged in with permission to install plugins. Visiting an unrelated malicious website would not be enough. The code uses that existing login rather than bypassing WordPress authentication. Researchers have not confirmed how the script first reached the site.

The loader also searches browser storage for authentication tokens and other sensitive values the page can access. HttpOnly cookies are protected from this kind of reading, although the browser can still include them in authenticated requests. Investigators need to consider both possible data theft and actions performed through the session.

Why removing the plugin may leave the site compromised

The recovered plugin calls itself Web Media Optimizer, a name that could pass for a routine performance tool. Its code adds remote JavaScript to public pages and hides the plugin from normal listings. It also contains a function that can give someone with a hardcoded token administrator access without entering the administrator’s password.

Once the backdoor is active, ending the original browser session will not remove the attacker’s way back in. A password reset alone will not resolve it either.

The plugin attempts to copy itself into the WordPress must-use plugin directory under the filename wmedia-recovery.php. WordPress loads files in that directory automatically, and they cannot be disabled through the standard plugin controls. A responder who removes only the original plugin could leave the copy running.

That makes checking the server directly essential. The Plugins page cannot deliver a reliable inventory when the malicious code has been designed to hide from it. Responders should inspect both plugin directories and review the stored settings that tell the backdoor where to retrieve remote scripts.

Where to start an investigation

An unexpected plugin installation is a useful starting point, even when the account involved belongs to a known administrator. Check whether anyone planned the change and compare the timing with requests for the upload page, the upload itself, and activation. Unfamiliar script traffic around the same time can help connect the browser activity to what appeared on the server.

Preserve the relevant evidence before removing files. Browser and proxy records, server logs, and the affected page’s source may help explain how the JavaScript got there. Without that work, teams risk cleaning up the backdoor while leaving the original delivery route unresolved.

Recovery should include removing the malicious plugin and any must-use copy, invalidating administrator sessions and changing administrator passwords. Review accounts for unauthorized changes and assess whether any tokens or other secrets accessible to the page must get replaced. Check public pages for injected scripts and WordPress options and transients, which store settings and temporary data, for suspicious remote addresses.

Administrators can reduce their exposure by keeping privileged work in a dedicated browser profile and using a separate, logged-out profile to review public pages. Separation helps only if the administrative profile stays out of ordinary browsing. Plugin-installation rights should also be limited to the people who need them, with a way to identify installations outside approved maintenance.

For teams responsible for WordPress, it's worth verifying whether these practices actually hold up during an ordinary site update. By mapping out who stays logged in while reviewing pages, auditing plugin-installation permissions, and ensuring unexpected installations are actively monitored, teams can practically reduce the opportunity TRUST#GRAFT relies on.

Sina Chehreghani, head of threat intelligence and threat research, Securonix

SC Media Perspectives columns are written by a trusted community of SC Media cybersecurity subject matter experts. Each contribution has a goal of bringing a unique voice to important cybersecurity topics. Content strives to be of the highest quality, objective and non-commercial.

Get daily email updates

SC Media's daily must-read of the most current and pressing daily news

By clicking the Subscribe button below, you agree to SC Media Terms of Use and Privacy Policy.

You can skip this ad in 5 seconds