wp2shell: more than a month later. Confirm 6.8.6, 6.9.5, 7.0.2. Patched is not clean.

Read the advisory

How to Protect a WordPress Site from Malware and Hackers

Practical ways to protect WordPress from malware: updates, safe plugins, strong logins, firewall, scanning, and backups you can restore.

Topics Malware & cleanup Hardening & checklists

Lars Koudal

Lars Koudal

Updated Published

Malware on WordPress is usually boring malware: spam injectors, backdoors, redirects, and junk left behind after a vulnerable plugin got exploited. You do not need perfect defenses. You need habits that close the usual doors.

Best Ways to Protect a WordPress Site from Malware

What “malware” means here

Malicious code on the server that does something you did not ask for: redirects, spam SEO, admin backdoors, mail abuse, crypto miners, or drive-by scripts for visitors. Size of the site barely matters. Bots scan everyone.

How sites get infected

  • Outdated plugins, themes, or WordPress core
  • Nulled / pirated “premium” plugins
  • Weak or reused admin passwords
  • Abandoned software left on disk
  • Compromised admin accounts (phishing)
  • Leftover developer tools after a handoff (helpful backdoor pattern)

Protection that actually reduces risk

1. Update and delete

Keep core, plugins, and themes current. Delete what you do not use. Deactivated is not the same as gone. Run vulnerability checks after big install days.

2. Use strong logins

Unique passwords in a password manager. 2FA for administrators. Limit failed logins with login protection. Full path: login security guide.

3. Vet plugins before install

Prefer WordPress.org or known vendors. Check last update date and support. Never install nulled packages. See plugin security risks.

4. Put a firewall in front

A cloud firewall blocks a lot of exploit and brute-force traffic before WordPress handles it (Pro: 600M+ known bad IPs). Buyer context: firewall guide.

5. Scan on a schedule

Run malware scans and vulnerability checks regularly, not only after something feels wrong. Watch the video above for a walkthrough of scanning with Security Ninja, or open the malware scanner page. Types of scanners: scanner comparison.

6. Keep restore-tested backups

Automatic, off-site, retained long enough to go back before an infection started. Details: backup plan if you get attacked. Security Ninja is not a backup plugin; pair it with a real backup tool (backup vs security).

7. Watch for early signs

Odd admins, unexplained plugins, redirects, Search Console warnings. Catching it early beats a weekend cleanup. See 7 signs of a hack and common malware traits.

8. Close reinfection loops

If malware “comes back,” look for persistence: cron jobs, mu-plugins, rogue admins, leftover upload shells. Case study: malware that kept coming back.

A simple weekly pass (stores: more often)

  1. Apply pending updates
  2. Confirm last backup finished
  3. Glance at Users and Events
  4. Run or review scheduled scan results

If you are already infected

  1. Put the site in maintenance / block public abuse if needed
  2. Restore clean if you can, or clean carefully
  3. Close the entry point (plugin, password, leftover file)
  4. Rotate credentials
  5. Rescan before reopening

Full playbook: malware removal. Stuck or locked out? Hire cleanup. After cleanup, fix Search Console if rankings tanked: recover SEO after a hack.

Bottom line

Updates, fewer plugins, real login hardening, firewall, scanning, and backups. That stack prevents most of the malware cases we see. Security Ninja covers those jobs without forcing five overlapping security plugins. Free baseline on WordPress.org.

Related video

Watch how to scan WordPress for malware with WP Security Ninja.

Found this useful? Share it.

Larger screenshot