Malicious actors have compromised thousands of WordPress websites and are randomly redirecting their visitors to sites that host malware and scams.
According to Sucuri, attackers injected 10-12 lines of malicious code into the header.php file of the WordPress theme. The code checks the user agent and if the visitor is not a crawler, they are taken to various types of malicious websites via a redirect chain that involves the default7(dot)com, test246(dot)com, test0(dot)com, distinctfestive(dot)com and ableoccassion(dot)com domains.
Interestingly, not all users are redirected to malicious websites. The code injected into WordPress websites is designed for random redirects, with a 15 percent chance of a user being redirected. The attack sites also set a cookie to track returning visitors.
If the hacked website is accessed via Internet Explorer, the redirect chain is different and the user is served a malware downloader disguised as a Java or Flash update. Jérôme Segura, lead malware intelligence analyst at Malwarebytes, reported seeing tech support scam websites delivered via this attack.
A bug in the malicious code causes PHP to display the following notice: “Undefined index: 6FoNxbvo73BHOjhxokW3.” Searching for this string on Google returns more than 6,000 results — although the actual number of compromised websites is likely much higher considering that PHP notices are disabled on many servers.
Searching for this string on Google revealed that the malicious code had also been injected into the footer.php file of WordPress websites. The attackers appear to have switched to targeting the header.php file in April, but researchers discovered that the footer.php injections were more sophisticated as the malicious code was designed not only to redirect visitors, but also to push pop-ups, and the redirect URL could be easily updated by the attacker by sending a request to the infected website.
“In most cases, the infected sites had multiple vulnerabilities. The infection itself was part of a number of other infections in the environment (it wasn’t an isolated event). In some cases, the infection was the only infection and found within the active theme’s header.php file. This is a typical infection scenario when attackers have access to WordPress admin interface and can edit the current theme’s files directly from there,” explained Denis Sinegubko, senior malware researcher at Sucuri.
It’s worth noting that the same malicious code has been injected into the administrator/includes/help.php file of some Joomla websites, but there only appear to be a handful of affected sites.
Last month, IBM Security warned WordPress website owners about an increase in attacks involving the C99 webshell. The company reported seeing nearly 1,000 attacks in February and March.