keepcalculator

06 Numbers and Powers

WordPress Site Flagged for Malware: What to Do

Card No. 06·71819 · Updated · Standard formula, shown below

If your WordPress site is flagged for malware, the first step is to stay calm and immediately take your site offline or put it in maintenance mode to prevent further damage to visitors. Then, systematically identify the infection, clean it, and secure your site against reinfection. This guide walks you through the entire process, from initial diagnosis to long-term prevention.

Understanding the Malware Flag

When a website is flagged for malware, it usually means that a security scanner (like Google Safe Browsing, Sucuri SiteCheck, or your hosting provider) has detected malicious code or behavior on your site. This can happen in several ways: a file on your server contains malicious code, your site is sending spam emails, it’s part of a phishing campaign, or it’s been injected with code that redirects visitors to harmful websites. The flag isn’t just a warning; it can cause browsers to show a “Deceptive Site Ahead” warning, which will drastically reduce your traffic and damage your reputation.

Immediate Steps to Take

As soon as you see the flag, act quickly but methodically. Here’s what to do first:

  • Don’t panic or delete files immediately. You’ll need evidence to understand the infection.
  • Change all your passwords immediately. This includes your WordPress admin password, FTP/SFTP credentials, and database passwords. Use strong, unique passwords for each.
  • Log out all active sessions. In WordPress, you can do this via the “Users” screen by selecting all users and choosing “Log Out” from the bulk actions dropdown. This kicks out any attacker who might be logged in.
  • Take a backup of your site files and database. Even if the backup is infected, you’ll need it for analysis and for comparing against clean versions. Store it securely on your local machine.
  • Put your site into maintenance mode. You can use a plugin or add a simple .maintenance file to your WordPress root directory. This prevents visitors from accessing the site while you work.

Identifying the Malware

Once you’ve secured your site, you need to find the malicious code. There are two main approaches: using security plugins and manual inspection.

Using Security Plugins: Install a reputable security plugin like Wordfence, Sucuri Security, or iThemes Security. These plugins can scan your files and database for known malware signatures and suspicious code. They often provide a file comparison feature that shows you what’s been modified compared to the original WordPress core files. Run a full scan and carefully review the results. Look for files that are flagged as “suspicious” or “malware.”

Manual Inspection: If you’re comfortable with code, you can manually inspect your site. Common places to look include:

  • wp-config.php – Check for any extra code or database connection details that don’t belong.
  • .htaccess – Look for redirects or strange rules that send visitors elsewhere.
  • wp-content/themes/ and wp-content/plugins/ – Check for recently modified files or files with base64-encoded strings. Malware is often hidden in theme and plugin files.
  • wp-content/uploads/ – Attackers sometimes upload PHP files disguised as images. Look for any .php files in the uploads folder.
  • Your database – Use a plugin like WP-Optimize or phpMyAdmin to search for suspicious code in the wp_options table, especially the siteurl and home options, which can be changed to redirect traffic.

Be wary of heavily obfuscated code (like eval(base64_decode(...))). This is a classic sign of malware.

Cleaning the Infection

After identifying the infected files, you need to remove the malicious code. Here’s a step-by-step approach:

  1. Reinstall WordPress core files. Go to Dashboard > Updates and click “Re-install Version X.X.X.” This replaces all core files with fresh, clean copies. If you can’t do this from the admin, download a fresh copy of WordPress from wordpress.org and overwrite your existing files (but not your wp-content folder or wp-config.php).
  2. Reinstall all themes and plugins. Delete the existing theme and plugin folders from wp-content/themes/ and wp-content/plugins/, then reinstall them from the official WordPress repository or from your original download sources. This ensures you have clean, unmodified code.
  3. Clean your database. Use a plugin like Wordfence or iThemes Security to scan for database malware. You can also use phpMyAdmin to search for suspicious entries. Look for unknown users, especially with administrator privileges, and remove them.
  4. Remove any unknown files. If you find files you didn’t create and aren’t part of WordPress, themes, or plugins, delete them. Be cautious, but if you’re unsure, you can quarantine them by renaming them with a .suspected extension.

After cleaning, run another full scan to ensure nothing is left. Then, test your site thoroughly: visit all pages, try the login, and check for any unusual redirects.

Hardening Your Site Against Future Attacks

Cleaning the malware is only half the battle. You must secure your site to prevent reinfection. Here are essential hardening steps:

  • Keep everything updated. Regularly update WordPress core, themes, and plugins. Outdated software is the #1 cause of WordPress infections.
  • Use strong passwords and two-factor authentication (2FA). Enable 2FA for all admin accounts. Consider using a password manager to generate and store complex passwords.
  • Limit login attempts. Use a plugin to limit the number of failed login attempts to prevent brute-force attacks.
  • Change your WordPress database prefix. The default prefix is wp_. Changing it to something unique makes SQL injection attacks more difficult.
  • Disable file editing. Add define('DISALLOW_FILE_EDIT', true); to your wp-config.php file. This prevents attackers from editing theme and plugin files from the admin dashboard.
  • Use a Web Application Firewall (WAF). A WAF can block malicious traffic before it reaches your site. Many security plugins offer this feature.
  • Regular backups. Schedule automatic backups of your files and database. Store them off-site (e.g., in cloud storage) so you can restore your site quickly if needed.

Requesting a Malware Review

Once your site is clean, you need to remove the flag from search engines and browsers. This is a crucial step that many people forget.

For Google: Go to Google Search Console, verify your site, and then use the “Security Issues” section to request a review. Google will re-scan your site and, if it’s clean, remove the warning. This process can take anywhere from a few hours to a few days.

For other browsers and security companies: If your site was flagged by Norton Safe Web, McAfee SiteAdvisor, or others, you’ll need to submit a review request to each of them. Their websites have dedicated forms for this.

While waiting for the review, make sure your site is fully functional and clean. If Google finds any remaining issues, the review will be rejected, and you’ll have to start again.

Common Problems and Misconceptions

There are a few common pitfalls and myths when dealing with malware flags:

  • “I can just restore a backup and be fine.” Not necessarily. If the backup was made after the site was infected, you’ll just be restoring the malware. Always scan your backups before restoring.
  • “Deleting the infected file is enough.” Often, the malware has a backdoor that allows the attacker to re-infect the site. You need to find and close the vulnerability, not just remove the symptom.
  • “Free security plugins are enough.” While free plugins are helpful, they may not catch everything. For comprehensive protection, consider a premium security service or a managed WordPress host with built-in security.
  • “The flag will go away automatically.” No. You must actively request a review after cleaning your site. The flag will persist until then.

Frequently Asked Questions

Q: How did my site get malware in the first place?
Most WordPress infections happen through outdated plugins or themes, weak passwords, or vulnerable third-party code. Attackers also exploit known vulnerabilities in popular plugins. Keeping everything updated and using strong passwords is your best defense.

Q: Can I clean the malware myself, or should I hire a professional?
If you’re comfortable with code and server management, you can clean it yourself using the steps above. However, if you’re unsure or the infection is complex, hiring a professional security service is safer. They can thoroughly clean your site and harden it against future attacks.

Q: Will cleaning the malware affect my SEO?
Cleaning the malware itself doesn’t hurt your SEO. In fact, removing the malware and getting the flag lifted will help your SEO because the warning will no longer scare away visitors. However, if your site was offline for a long time, you might see a temporary dip in rankings.

Q: How long does it take to get the malware flag removed?
After you submit a review request to Google, it typically takes a few days to a week. Other security companies may take longer. The key is to ensure your site is completely clean before requesting a review.

Q: What if my host has already suspended my site?
Contact your hosting provider immediately. They may have suspended your site to prevent further damage. Explain that you are cleaning it and ask what steps they recommend. They may require you to provide a clean scan report before reactivating your site.

Q: Is it safe to use a backup that was made before the infection?
Yes, if you are sure the backup was made before the infection occurred. However, it’s wise to scan the backup with a security plugin before restoring it, just to be safe.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →