Nexura WordPress Security Plugin Logo
Download Free

100% Free · No credit card required

WordPress Self-Healing Malware & Persistence Root Cause Solution

WordPress Malware Keeps Coming Back?
Find What Is Recreating It.

Deleting a malicious file doesn't always remove the mechanism that recreates it. Nexura Security analyzes file writers, scheduled tasks, MU-plugins, drop-ins and configuration paths to help identify the persistence source.

Evidence-Based Detection
WordPress Plugin & Theme Aware
1-Click Root Quarantine
100% Free Core Engine
Quick Answer Root Cause Analysis

Why Does WordPress Malware Keep Coming Back After Deletion?

WordPress malware can return after deletion when another compromised component is still able to recreate it. The persistence mechanism may be a malicious PHP file, scheduled task, MU-plugin, drop-in, database-stored payload, compromised credential, or server configuration.

Deleting the visible malware removes the symptom, but the site can become reinfected if the mechanism that recreated it remains active. Attackers typically rely on 5 common persistence vectors:

1. Malicious File Writers:

A secondary script invoking file_put_contents(), fwrite(), or base64 decoding that writes fresh payloads to disk.

2. WP-Cron or Server Cron Jobs:

An orphaned or stealth cron event in the wp_options table or hosting crontab that triggers recurring writer scripts.

3. MU-Plugins & Disguised Drop-ins:

Scripts in wp-content/mu-plugins/ or rogue drop-ins (db.php, advanced-cache.php) executing before normal plugins.

4. Modified Configuration Directives:

Stealth auto_prepend_file instructions inside .user.ini, .htaccess, or wp-config.php executing code before WordPress boots.

5. Compromised Accounts or External Access:

Hidden administrator accounts, compromised database credentials, or external access keys allowing automated re-infection from outside.

The Solution: Identify and isolate the persistent trigger or file writer rather than only deleting the regenerated file.
How Nexura Investigates →

Anatomy of the Self-Healing Malware Loop

Why file deletion alone leaves the site vulnerable to recurring reinfection.

01

The Hidden Anchor

Attacker plants an innocent-looking script in mu-plugins, a fake drop-in, or disguised inside .user.ini.

→ Invisible to basic scanners
02

The Heartbeat

A scheduled wp_cron job or linux crontab executes periodically in the background every 10 to 60 minutes.

→ Fires autonomously
03

The File Writer

The anchor executes file_put_contents() or fetches a remote base64 payload to write cache.php.

→ Payload deployed
04

The Illusion

Webmaster or antivirus spots cache.php and deletes it. The site appears clean for 5 minutes.

→ False sense of safety
05

The Resurrector

The cron fires again. The anchor sees cache.php is missing and instantly regenerates it!

∞ Reinfection Loop Repeats
Interactive Diagnostic Tool

Select Your Reinfection Symptom

Click the exact issue you are facing to uncover the hidden mechanism behind it.

Remediation Playbook

If Malware Comes Back, Follow This Order

A systematic, 12-step incident investigation sequence to locate the persistence source before wiping or restoring.

1
Record the Exact File

Document the exact file path and name that reappears (e.g. wp-content/uploads/cache.php).

2
Note the Return Timestamp

Record how long after deletion the file reappears (minutes, hours, or during specific traffic/cron windows).

3
Do Not Prematurely Delete Everything

Premature deletion removes timestamps and execution relationships needed to trace the parent writer.

4
Check File Modification Times

Inspect files modified around the same window to spot coordinated secondary payloads.

5
Inspect WP-Cron & Scheduled Tasks

Examine recurring hooks in wp_options for orphaned or obfuscated scheduled triggers.

6
Inspect MU-Plugins & Drop-ins

Check wp-content/mu-plugins/ and files like db.php or object-cache.php.

7
Search for File-Writing Code

Analyze PHP code invoking file_put_contents(), touch(), or remote downloaders.

8
Check .user.ini / .htaccess Directives

Audit configuration files for auto_prepend_file or rogue rewrite rules.

9
Rotate Admin & Hosting Credentials

Change WordPress admin passwords, database user credentials, SFTP/SSH keys, and security salts.

10
Quarantine the Persistence Source

Isolate the generator script rather than only the file it continually recreates.

11
Replace Core & Plugin Files

Reinstall WordPress core and plugins with pristine checksum-verified copies from official sources.

12
Verify Remediation Over Time

Monitor file integrity and scheduled hooks over subsequent 24-to-72 hour operational cycles.

Remediation Perspectives Industry & Community Insights

What Security Communities Commonly Recommend for Recurring WordPress Malware

Community discussions across forums like Reddit r/Wordpress and Stack Overflow often start with: “Restore from a clean backup or rebuild the site.” That advice can help, but it does not address every persistence mechanism on its own.

The Backup Challenge

Restoring a backup can fail when the backup snapshot already contains the dormant persistence mechanism or modified database hook planted weeks before spam symptoms became visible.

The Rebuild Complexity

Rebuilding a site from scratch can be time-consuming, particularly for complex WooCommerce, membership, or customized enterprise installations where data loss is unacceptable.

Effective Remediation Combines:

Restoring verified pre-infection backups
Rotating WordPress & hosting credentials
Replacing modified core and plugin files
Auditing scheduled tasks, MU-plugins & drop-ins
Manual Investigation Toolkit

Sysadmin CLI Diagnostic Cheatsheet

If you have SSH / Terminal access to your server (Nginx, GridPane, RunCloud, cPanel), run these commands to manually inspect common persistence paths.

1. Find Recently Modified PHP Files in wp-content (Last 48 Hours)
find wp-content/ -type f -name "*.php" -mtime -2

Useful for spotting newly regenerated files or hijacked legitimate plugin files.

2. Search for File-Writing Code Across Plugins & Themes
grep -rnEi "(file_put_contents|fwrite|touch)\s*\(" wp-content/mu-plugins/ wp-content/themes/

Finds PHP code that uses common file-writing functions. Review the results in context because legitimate plugins may also use these functions.

3. Audit Scheduled Cron Events with WP-CLI
wp cron event list --fields=hook,next_run_gmt,recurrence

Look for suspicious hook names with random characters or orphaned hooks from deleted plugins.

4. Check for Pre-Boot auto_prepend_file Directives
grep -Rni --exclude-dir=vendor --exclude-dir=node_modules "auto_prepend_file\|auto_append_file" .user.ini .htaccess wp-config.php 2>/dev/null

Checks user and directory configuration for pre-boot includes. On servers with CLI access, you can also run: php -i | grep -E "auto_prepend_file|auto_append_file"

Automate Persistence Investigation with Nexura

Nexura Security inspects these persistence layers systematically inside the WordPress environment, tracing likely writers and scheduled hooks without manual terminal digging.

Run Auto Scan Free
Multi-Vector Persistence Analysis Engine

How Nexura Investigates Recurring Malware

Nexura doesn't just scan static files. It conducts an evidence-based investigation starting from the returning file and inspects the 6 critical vectors commonly leveraged for persistence.

1. PHP Token-Based Writer Analysis

Scans your codebase using PHP token-based analysis (token_get_all) to identify scripts executing file_put_contents(), fwrite(), touch(), or remote downloading routines.

Identifies Potential Writers

2. Stealth MU-Plugin Audit

Must-Use (wp-content/mu-plugins) load before standard plugins and never appear in the WordPress admin plugin list. Nexura deep-scans every MU-plugin for persistence hooks.

Inspects Hidden Plugins

3. WP-Cron & Hook Persistence

Inspects scheduled cron jobs using dynamic reflection. Legitimate crons from active plugins are verified, while orphaned hooks or those invoking unverified files in uploads/ or root directories are flagged.

Sever Background Triggers

4. Disguised Drop-ins

Inspects db.php, object-cache.php, and advanced-cache.php. Verifies whether active caching plugins (LiteSpeed, Redis, WP Rocket) own them or if they are rogue hijackers.

Protects Boot Flow

5. Server Config Directives

Audits .user.ini, .htaccess, and wp-config.php for stealth auto_prepend_file or auto_append_file directives that execute malware before index.php.

Blocks Pre-Boot Execution

6. Visual Relationship Graph

Renders an interactive canvas mapping the relationship between the returning file, candidate writer scripts, trigger cron events, and remote downloaders in clear visual context.

Visual Evidence Chain
Nexura Reinfection Investigation Interface

Inside the Reinfection Investigation Interface

Nexura Reinfection Guard Interactive Persistence Map Dashboard
Red Hexagon

The returning malware target being investigated (e.g., cache.php).

Orange Nodes

Detected persistence candidates, potential file writers, and cron hooks linked to the target.

1-Click Neutralize

Safely isolates and quarantines persistence scripts with encrypted backup and verification.

Technical Transparency

What Nexura Can and Cannot Detect

Clear boundaries of what is covered inside WordPress versus investigations that require hosting-level or credential intervention.

Persistence Vector / Investigation Area Detection Capability Availability & Prerequisites
PHP File Writers & Downloaders Scripts calling file_put_contents, fwrite, touch, or remote downloaders. Full Token Analysis Included in Free Core
MU-Plugins & Disguised Drop-ins Code in wp-content/mu-plugins/ and drop-in files (db.php, advanced-cache.php). Deep Inspection Included in Free Core
WordPress Scheduled Cron (WP-Cron) Orphaned hooks, suspicious recurrences, and rogue cron schedules in database. Hook Registry Audit Included in Free Core
Pre-Boot Directives (.user.ini / .htaccess / wp-config) auto_prepend_file or auto_append_file directives executing before WordPress boots. Config File Audit Included in Free Core
Server-Level Linux Crontab (/etc/cron*) System crontabs executing external PHP CLI scripts outside WordPress. Permission-Dependent Pro (Requires server read access)
Nginx & PHP-FPM Vhost Directives Web server directives pointing fastcgi_param to malicious prepends. Permission-Dependent Pro (Requires vhost config read access)
Compromised Database / Hosting Accounts Attacker accessing phpMyAdmin, cPanel, or external database port directly. External Investigation Required Requires hosting credential rotation
Malware Outside WordPress Web Root Files placed in parent server directories above the open_basedir boundary. Filesystem Boundary Dependent Depends on PHP isolation rules
Transparent Feature Gating

Nexura Free vs. Nexura Pro

Nexura Free gives you full diagnostic visibility to discover why malware keeps returning. Nexura Pro gives you automated root-cause isolation and server-level investigation capabilities.

Capability / Security Feature Free Core Pro Edition
Full-Site Persistence & Self-Healing Audit Scans all files, crons, and configurations for persistence vectors. Included Included
PHP Token-Based File Writer Analysis Detects file_put_contents, fwrite, and string obfuscation. Included Included
WP-Cron & Hook Reflector Dynamic reflection across active WordPress plugins and themes. Included Included
Interactive Relationship Network Graph Visual canvas mapping target and persistence vector relationships. Included Included
Exact Evidence & File Location Paths Reveals exact file paths and line numbers without masking. Masked (•••••) Fully Unmasked
1-Click Root-Cause Neutralization Automatically isolates and quarantines the persistent scripts safely. Manual Editing Required 1-Click Automated
Runtime File-Change Monitoring Monitors WordPress filesystem events for unauthorized modifications. WordPress-Level Monitoring
Server Crontab & Server Config Audit Server-level persistence checks. Available when the hosting environment grants required file access. Pro & Agency
Priority Emergency Cleanup Assistance Direct hands-on triage from senior Nexura security engineers. Community Support Priority Support

Why Upgrade to Nexura Pro?

Hunting down multiple cross-linked persistence scripts manually can be time-consuming and risks breaking legitimate site functionality. Nexura Pro isolates the persistence chain and moves quarantined files into an encrypted vault with 1-click restore.

Instant License Key Plans from $7/mo or $67/yr 7-Day Money-Back Guarantee

Frequently Asked Questions

Technical answers to help you understand and defeat persistent WordPress infections.

Why does malware keep coming back after I delete it in WordPress?

Malware returns because deleting the malicious file (such as cache.php or an infected index.php) only removes the visible symptom. Attackers install persistence mechanisms—such as hidden file writer scripts, scheduled WP-Cron hooks, rogue MU-plugins, or server directives in .user.ini—that automatically recreate the deleted file shortly after.

What is WordPress self-healing malware?

Self-healing malware is an attack pattern where two or more malicious scripts or hooks monitor each other. If one file is deleted, a secondary process detects its absence and immediately generates a fresh copy using base64-encoded strings, remote servers, or file_put_contents. Standard file cleaners can struggle when they only evaluate files in isolation.

Why can malware return even after a security scan?

A file scan can identify and remove a malicious file without necessarily identifying every mechanism that could recreate it. Persistent infections may involve scheduled tasks, must-use plugins, modified configuration files, compromised credentials, or other execution paths. For recurring infections, the investigation needs to examine both the malicious file and the mechanism that recreated it.

Will restoring from a clean backup fix recurring malware?

Restoring a backup can fail when the backup already contains the persistence mechanism. In many persistent infections, dormant backdoors, rogue cron entries, or modified user roles were planted weeks before visible symptoms appeared. Restoring an older backup often restores the dormant backdoor, allowing reinfection to continue.

Does Nexura work on Nginx, Apache, LiteSpeed, and managed WordPress hosting?

Yes. Nexura is designed for WordPress sites running on Apache, Nginx, LiteSpeed, OpenLiteSpeed, and common managed hosting environments (including GridPane, RunCloud, Kinsta, and Cloudways). Core WordPress-layer checks operate in all environments, while server-level crontab and web server configuration audits require elevated hosting permissions.

What happens if I quarantine a file by mistake?

Nexura never deletes files permanently without an encrypted backup. Quarantined files are safely encrypted and moved into a protected vault. You can restore any quarantined file with 1 click from the Nexura dashboard at any time.

Stop the Reinfection Cycle Today

Don't waste another weekend manually deleting recurring files. Run Nexura Security right now to analyze persistence mechanisms and isolate the root cause.

7-Day Free Trial · Plans from $7/mo or $67/yr · Use code: NEXURA20 (20% OFF eligible plans)

100% Free Core on WordPress.org · Cancel Anytime · Instant License Activation

Stay Ahead of Hackers

Join our growing community of site owners who receive our weekly WordPress security alerts, vulnerability reports, and hardening tips.

SSL Secured
Privacy-focused
WP.org Verified
Proactive Defense
Secure Your Infrastructure Today