WordPress security monitoring: which events to log, what to alert on and how to respond to a hacked site

Logins, xmlrpc.php, new admins, plugin changes, file integrity, vulnerable plugins, WAF signals and SEO spam: what to collect, which alerts matter, and a runbook for the day a WordPress site is compromised.

Obseria TeamObseria
Summary
  • WordPress security monitoring starts with a small set of high-value events: failed and successful logins, xmlrpc.php traffic, new administrators, role changes and every plugin or theme install, activation or update.
  • File integrity checks against WordPress.org checksums, a scan for PHP files in wp-content/uploads and a daily comparison of installed plugin versions with vulnerability databases catch most compromises that event logs miss.
  • Ship all of it to a central log system with defined retention and masked personal data, alert only on the few signals that need a human, and keep a written runbook for the day a site is hacked.

WordPress security monitoring is less about buying another plugin and more about knowing which handful of signals reveal an attack early. Most WordPress compromises follow a familiar path: a vulnerable plugin or a reused password gets an attacker in, a new administrator or a PHP file appears, and the site starts serving spam, redirects or malware. Each of those steps leaves traces in WordPress itself, in the file system or in the web server logs, if someone collects them.

This guide covers four layers: WordPress application events, file system changes, installed versions against vulnerability data, and HTTP traffic in front of WordPress. It adds outside-in checks for SEO spam, GDPR-aware central logging, an alert table, a checklist and a runbook for a hacked site. Performance topics are deliberately left out.

Which WordPress security events to log

WordPress fires action hooks for almost every security-relevant change. A small must-use plugin can turn them into structured log records without any third-party service. These are the events worth capturing, with the hook names from the official WordPress developer reference:

  • Failed logins: wp_login_failed receives the attempted username or email and, since WordPress 5.4, a WP_Error with the reason.
  • Successful logins: wp_login receives the login name and the WP_User object. An admin login from a new country right after a burst of failures is a top signal.
  • New users: user_register. An administrator account that nobody on your team created is a strong indicator of compromise.
  • Role changes: set_user_role passes the user ID, the new role and the previous roles. Escalation from subscriber to administrator should always alert.
  • Plugin and theme changes: activated_plugin, deactivated_plugin, switch_theme and upgrader_process_complete, whose $hook_extra array contains the action (for example install or update) and the type (plugin, theme, translation or core).

A minimal example that writes one JSON line per event to the PHP error log, from where your log shipper picks it up:

<?php
// wp-content/mu-plugins/security-events.php (example)
function sec_log( string $event, array $data = [] ): void {
    $ip = $_SERVER['REMOTE_ADDR'] ?? '';
    error_log( wp_json_encode( [
        'ts'      => gmdate( 'c' ),
        'event'   => $event,
        'site'    => home_url(),
        'actor'   => get_current_user_id(),
        'ip_hash' => hash( 'sha256', $ip . wp_salt( 'auth' ) ),
    ] + $data ) );
}
add_action( 'wp_login_failed', function ( $username ) {
    sec_log( 'login.failed', [ 'user_hash' => hash( 'sha256', strtolower( $username ) ) ] );
} );
add_action( 'wp_login', function ( $login, $user ) {
    sec_log( 'login.success', [ 'user_id' => $user->ID, 'roles' => $user->roles ] );
}, 10, 2 );
add_action( 'set_user_role', function ( $user_id, $role, $old_roles ) {
    sec_log( 'user.role_changed', [ 'user_id' => $user_id, 'role' => $role, 'old_roles' => $old_roles ] );
}, 10, 3 );
add_action( 'upgrader_process_complete', function ( $upgrader, $extra ) {
    sec_log( 'upgrader.' . ( $extra['action'] ?? 'unknown' ), [ 'type' => $extra['type'] ?? '' ] );
}, 10, 2 );

user_register and activated_plugin follow the same pattern. Behind a proxy or CDN, REMOTE_ADDR is the proxy address; read the client IP only from a header your own proxy sets. Never log passwords, and hash usernames of failed logins, since people sometimes type their password into that field. Our article on security logging and audit logs covers event schemas and tamper resistance in more depth.

File integrity: core checksums, plugin files and PHP in uploads

Event hooks only see what happens through WordPress. An attacker who exploits a file upload vulnerability or has FTP credentials can write files directly, so the file system needs its own checks.

  • Core files: wp core verify-checksums in WP-CLI compares core files with the official WordPress.org checksums; --include-root also flags unknown files in the root directory.
  • Plugin files: wp plugin verify-checksums --all does the same for plugins from WordPress.org. Premium and custom plugins need their own baseline, such as hashes from your Git repository.
  • PHP files in uploads: the uploads directory should contain media, not code. A daily find wp-content/uploads -name "*.php" that returns anything at all deserves an alert. Additionally block PHP execution there in the web server.
  • Unexpected changes: PHP files modified outside your deployment windows are suspicious, as are changes to wp-config.php, .htaccess and wp-content/mu-plugins, which attackers like for persistence.
# nginx: no PHP execution in uploads (example)
location ~* ^/wp-content/uploads/.*\.php$ {
    deny all;
}

# daily integrity job (example, run as the site user)
wp core verify-checksums --include-root
wp plugin verify-checksums --all --format=json
find wp-content/uploads -type f -name "*.php"

Also set define( 'DISALLOW_FILE_EDIT', true ); in wp-config.php. It disables the built-in code editor; as the WordPress hardening guide notes, it does not stop uploads, but it removes an easy injection path after an admin takeover.

Monitoring vulnerable plugins, outdated core and PHP versions

Knowing that a plugin is outdated is not enough; you want to know whether the installed version has a known CVE and how urgent it is. Several public sources specialise in WordPress vulnerability data:

  • WPScan maintains a WordPress vulnerability database with an API; at the time of writing a free tier with a daily request limit is available for non-commercial use, and commercial use requires a paid plan.
  • Wordfence Intelligence offers a vulnerability data feed via API. Version 3 of the feed requires a free API key from a Wordfence account.
  • Patchstack runs a public WordPress vulnerability database; API access and virtual patching are part of its commercial offering.

Terms and limits change, so check them before you build on a feed. A daily job exports installed versions with wp plugin list --format=json and wp theme list --format=json, matches them against one of these feeds and alerts on new matches. An unauthenticated vulnerability in an active plugin is more urgent than one that needs an administrator login. Our guide to vulnerability prioritization with CVSS, EPSS and runtime context explains how to rank them.

Runtime versions belong in the same report. According to php.net, PHP 8.1 no longer receives security fixes and security support for PHP 8.2 ends on 31 December 2026. Track PHP and core versions per site and flag unsupported ones. If you use automatic updates for core, plugins or themes, check via upgrader_process_complete that they actually succeed.

Web server logs and WAF signals

Web server access logs see every request, including those blocked before WordPress loads. They are the best source for spotting attacks at volume:

  • Brute force on wp-login.php: count POST /wp-login.php per client IP and per minute. A failed login typically re-renders the form with status 200, while a successful one redirects with 302, so the status ratio is informative too.
  • xmlrpc.php abuse: XML-RPC's system.multicall lets one request carry many login attempts, and pingbacks can be abused for reflection. If you do not use XML-RPC (Jetpack and some mobile apps do), block it at the web server. Note that the xmlrpc_enabled filter only disables methods that require authentication, not pingbacks.
  • User enumeration: bursts of requests to /?author=1 or /wp-json/wp/v2/users often precede password attacks.
  • WAF events: ship block events from your CDN WAF, ModSecurity or security plugin into the same system and look at rule IDs and targets, not only totals.

Log in JSON with status, method, path, client IP and user agent; the Nginx integration parses these alongside metrics. Blocked attacks are background noise, so alert on changes: a step in login POSTs, a WAF rule firing on an authenticated path, or successful logins after a block wave.

Malware, SEO spam and defacement: outside-in checks

Compromised sites are often quietly abused rather than taken offline. Typical symptoms: spam pages (pharma, casino, counterfeit goods) that are shown only to search engine crawlers, redirects only for visitors coming from search results or on mobile, injected <script> tags loading code from unknown domains, and new sitemaps or pages you never published.

Because these tricks target specific visitors, check from the outside:

  • Synthetic content checks: fetch key pages on a schedule and assert that an expected phrase is present and known spam keywords and unknown script domains are absent. Vary user agent and referrer.
  • Uptime and certificate checks: classic availability monitoring also catches defacement that replaces the home page. Our website uptime monitoring guide covers check intervals and locations.
  • Search Console: Google Search Console reports security issues such as hacked content and malware for verified sites. Make sure its notification emails reach a monitored mailbox.
  • Database and cron: attackers also hide code in wp_options and WP-Cron; review wp cron event list for unknown hooks.

With synthetic monitoring, these content assertions run from several locations and alert like any other check.

Central logging, retention and GDPR-aware masking

Logs that live only on the compromised server are the first thing a capable attacker deletes. Ship all of these logs to a central system as they are written, for example through an OpenTelemetry Collector that buffers locally.

  • Retention: intrusions are often found weeks later. Define a retention period per log type that allows a timeline reconstruction, for example 90 days for access logs and longer for admin and role changes, subject to your own legal assessment.
  • Personal data: IP addresses, usernames and email addresses are personal data under the GDPR. Collect what security requires and mask or pseudonymise everything not needed in clear text. PII masking in the pipeline, before storage, is more reliable than cleaning up afterwards. Keep in mind that a salted hash is pseudonymisation, not anonymisation.
  • Access and integrity: restrict who can read security logs and make sure the WordPress server can write but not delete them.

Alert table and WordPress security monitoring checklist

The thresholds below are examples to start from. Tune them to your traffic and your team's on-call setup.

SignalSourceExample alert
New administrator accountuser_register + roleImmediately, every occurrence
Role escalated to administratorset_user_roleImmediately, every occurrence
Admin login after failures or from new countrywp_login, wp_login_failedImmediately; review with the account owner
Failed loginsHook or access logMore than 5x the 7-day baseline for 10 min
xmlrpc.php POST requestsAccess logAny volume if XML-RPC is supposed to be blocked
Plugin installed or activatedupgrader_process_complete, activated_pluginOutside a change window: warning to chat
Core or plugin checksum mismatchWP-CLI daily jobAny mismatch: ticket with high priority
PHP file in uploadsDaily file scanAny file: page during business hours
Installed version with known vulnerabilityVulnerability feed matchUnauthenticated and exploitable: same day
Spam keyword or unknown script on pageSynthetic content checkTwo consecutive failures

WordPress security monitoring checklist

  • Must-use plugin logs failed and successful logins, new users, role changes, plugin and theme changes as JSON
  • Daily wp core verify-checksums and wp plugin verify-checksums --all
  • Daily scan for PHP files in wp-content/uploads; PHP execution blocked there
  • Changes to wp-config.php, .htaccess and mu-plugins monitored
  • Installed plugin and theme versions matched daily against a vulnerability feed
  • PHP and core versions tracked against supported ranges; auto-update results monitored
  • Access logs in JSON; login POSTs, xmlrpc.php, user enumeration and WAF blocks counted
  • Synthetic checks for availability, expected content and absence of spam or unknown scripts
  • All logs shipped centrally, retention defined, personal data masked before storage
  • Written incident runbook tested at least once

Incident response runbook for a hacked WordPress site

A written runbook prevents the two classic mistakes: cleaning up before preserving evidence, and restoring without closing the hole. A template:

  1. Contain. Use maintenance mode or restrict access at the web server or WAF.
  2. Preserve evidence. Snapshot files, database and logs before changing anything. Note the time of the first suspicious event from your central logs.
  3. Scope. List admins with wp user list --role=administrator, run the integrity checks above and identify the entry point (vulnerable plugin, stolen password, hosting account).
  4. Eradicate. Remove unknown admins, reinstall core with wp core download --force --skip-content, reinstall plugins and themes from clean sources, remove injected files and database entries, and patch or remove the vulnerable component.
  5. Rotate secrets. Reset all administrator passwords and application passwords, change the database password, hosting, SFTP and API keys, and regenerate the salts in wp-config.php (for example with wp config shuffle-salts), which also invalidates existing login sessions.
  6. Restore and verify. Go live again, rerun all checks and watch the logs closely. If Google flagged the site, request a review in Search Console.
  7. Notify and learn. If personal data may have been affected, involve your data protection officer: under Art. 33 GDPR, a notifiable breach must be reported to the supervisory authority within 72 hours of becoming aware of it. Then document the root cause and the monitoring gap.

How Obseria helps with WordPress security monitoring

Obseria is an OpenTelemetry-native observability platform, so the security events, error logs, access logs and WAF events described here arrive through standard collectors, next to the traces and metrics of the same site. Together with our PHP monitoring setup, a suspicious admin login, a new plugin and a change in error rates show up on one timeline.

  • Obseria Pipeline masks IP addresses, usernames and emails before storage in the EU and routes security events with their own retention.
  • Alerting and incident management turn the few critical signals into pages with the runbook attached.
  • Teams without their own security operations can use the Managed Observability & Security service.

You can start collecting WordPress security events in minutes with a free Obseria trial.

Share

Observability that delivers answers.

Start for free with OpenTelemetry, no credit card required.