Hackers Weaponise WordPress Websites
WordPress is a very widely-used, free, open-source content management system (CMS) used to create and manage websites without needing to code. It allows users to build a wide range of sites, from simple blogs to complex online stores, by using customizable themes for design and plugins for added functionality.
This ubiquity means that WordPress websites long been a prime target for threat actors seeking to monetise traffic and compromise visitor security. Now, a new malvertising campaign has emerged, exploiting silent PHP code injections within theme files to serve malicious third-party scripts.
The attack seamlessly blends with legitimate site operations, delivering JavaScript that redirects visitors, displays pop-ups, and evades security tools without raising suspicion.
The initial discovery was made by a site owner who noticed unexplained script loads on their website. The intrusion originated from a small block of PHP code appended to the active theme’s file. This injection did not alter any visible page content but executed behind the scenes on every request. The infection was traced back to vulnerabilities in website configurations, mainly involving weak file permissions and outdated themes. Attackers often gain access through compromised credentials or vulnerable plugins, allowing them to insert a seemingly benign function that contacts a command-and-control server.
Once triggered via the wp_head hook, the malicious function fetches a dynamic JavaScript payload and inserts it into the page’s <head> section. This ensures the code is executed before the rest of the page loads, enabling forced redirects, pop-ups, and malicious activity that can bypass security scanners by mimicking legitimate CDN operations.
The malware often embeds itself within hidden iframes, which helps it evade detection and persist until manually removed. The injected code can silently reside on the site, executing malicious scripts on every visitor’s session.
This demonstrates how attackers abuse small modifications in theme files - such as a few extra lines in functions.php - to hijack a website’s front end and infect visitors.
Cleaning an infected WordPress site involves removing the malicious code, checking for other backdoors, and implementing measures to prevent re-infection. Regular updates, strong credentials, and vigilant monitoring are essential to defend against these types of malware campaigns. Ensuring themes and plugins are kept current and configuring permissions securely can significantly reduce the risk.
This campaign demonstrates the importance of cybersecurity best practices for WordPress users, reminding site owners to remain vigilant against evolving threats that exploit common vulnerabilities.
BitDefender | CyberPress | Cybersecurity News | Sucuri | GBHackers | Hacker News
Image: Ideogram
You Might Also Read:
The Future Of Digital Leadership Starts With The Website:
If you like this website and use the comprehensive 8,000-plus service supplier Directory, you can get unrestricted access, including the exclusive in-depth Directors Report series, by signing up for a Premium Subscription.
- Individual £5 per month or £50 per year. Sign Up
- Multi-User, Corporate & Library Accounts Available on Request
- Inquiries: Contact Cyber Security Intelligence
Cyber Security Intelligence: Captured Organised & Accessible






