(int) $state['scan_id'], 'fingerprint' => md5( 'config|' . $key ), 'category' => 'config', 'location' => '' !== $location ? $location : $key, 'line' => 0, 'severity' => $severity, 'confidence' => (int) $confidence, 'signature' => substr( 'cfg_' . preg_replace( '/[^a-z0-9_]/', '_', strtolower( $key ) ), 0, 64 ), 'title' => $title, 'description' => $description, 'snippet' => '', 'verdict' => 'suspicious', 'remediation' => $remediation, 'file_hash' => md5( $description ), 'meta' => $meta, ) ); $state['findings']++; if ( 'critical' === $severity ) { $state['critical']++; } } private static function check_versions( array &$state ) { if ( ! function_exists( 'get_core_updates' ) ) { require_once ABSPATH . 'wp-admin/includes/update.php'; } $updates = get_site_transient( 'update_core' ); if ( ! is_object( $updates ) || empty( $updates->updates ) || ( isset( $updates->last_checked ) && time() - (int) $updates->last_checked > DAY_IN_SECONDS ) ) { wp_version_check( array(), true ); } $core = get_core_updates(); if ( is_array( $core ) && ! empty( $core[0] ) && isset( $core[0]->response ) && 'upgrade' === $core[0]->response ) { self::add( $state, 'WordPress core', __( 'WordPress is not up to date', 'ai-guardwall' ), 'medium', 75, sprintf( /* translators: 1: WordPress version, 2: current */ __( 'Version %1$s is installed; %2$s is available. Updates close publicly known holes; this is the single most effective protection.', 'ai-guardwall' ), Softvolt_Ai_Bodyguard_Helpers::wp_version(), $core[0]->current ), 'update', array( 'details' => $core[0]->current ) ); } wp_update_plugins(); $plugins = get_site_transient( 'update_plugins' ); if ( is_object( $plugins ) && ! empty( $plugins->response ) ) { $installed = Softvolt_Ai_Bodyguard_Integrity::installed_plugins(); foreach ( $plugins->response as $file => $data ) { $name = isset( $installed[ $file ]['Name'] ) ? $installed[ $file ]['Name'] : $file; $from = isset( $installed[ $file ]['Version'] ) ? $installed[ $file ]['Version'] : '?'; $to = isset( $data->new_version ) ? $data->new_version : '?'; self::add( $state, 'plugin|' . $file, sprintf( /* translators: %s: name */ __( 'Plugin update available: %s', 'ai-guardwall' ), $name ), 'medium', 55, sprintf( /* translators: 1: name, 2: from, 3: to */ __( '%1$s %2$s is installed; %3$s is available. Most WordPress hacks come through outdated plugins with published vulnerabilities.', 'ai-guardwall' ), $name, $from, $to ), 'update', array( 'details' => $file ), 'wp-content/plugins/' . $file ); } } wp_update_themes(); $themes = get_site_transient( 'update_themes' ); if ( is_object( $themes ) && ! empty( $themes->response ) ) { foreach ( $themes->response as $slug => $data ) { $to = isset( $data['new_version'] ) ? $data['new_version'] : '?'; self::add( $state, 'theme|' . $slug, sprintf( /* translators: %s: slug */ __( 'Theme update available: %s', 'ai-guardwall' ), $slug ), 'low', 45, sprintf( /* translators: 1: slug, 2: to */ __( 'Theme "%1$s" can be updated to %2$s.', 'ai-guardwall' ), $slug, $to ), 'update', array( 'details' => $slug ), 'wp-content/themes/' . $slug ); } } $inactive = array(); $active = (array) get_option( 'active_plugins', array() ); foreach ( Softvolt_Ai_Bodyguard_Integrity::installed_plugins() as $file => $data ) { if ( ! in_array( $file, $active, true ) && ! is_plugin_active_for_network( $file ) ) { $inactive[] = $data['Name']; } } if ( $inactive ) { self::add( $state, 'inactive plugins', sprintf( /* translators: %d: number of inactive */ _n( '%d inactive plugin installed', '%d inactive plugins installed', count( $inactive ), 'ai-guardwall' ), count( $inactive ) ), 'info', 20, sprintf( /* translators: %s: list of inactive */ __( 'Inactive plugins still contain code attackers can reach. Delete the ones you do not use: %s', 'ai-guardwall' ), implode( ', ', array_slice( $inactive, 0, 25 ) ) ), 'manual_review' ); } $all_themes = wp_get_themes(); $extra = array(); foreach ( $all_themes as $slug => $theme ) { if ( $slug !== get_stylesheet() && $slug !== get_template() ) { $extra[] = $slug; } } if ( count( $extra ) > 1 ) { self::add( $state, 'inactive themes', sprintf( /* translators: %d: number of extra */ __( '%d inactive themes installed', 'ai-guardwall' ), count( $extra ) ), 'info', 20, sprintf( /* translators: %s: list of extra */ __( 'Keep the active theme (and its parent) plus one default theme; delete the rest: %s', 'ai-guardwall' ), implode( ', ', $extra ) ), 'manual_review' ); } $php = Softvolt_Ai_Bodyguard_Helpers::php_status(); if ( 'unsupported' === $php ) { self::add( $state, 'PHP version', __( 'PHP version is no longer supported', 'ai-guardwall' ), 'high', 80, sprintf( /* translators: %s: value */ __( 'PHP %s receives no security fixes. Switch to PHP 8.3 or newer in your hosting panel.', 'ai-guardwall' ), PHP_VERSION ), 'fix_config' ); } elseif ( 'outdated' === $php ) { self::add( $state, 'PHP version', __( 'PHP is missing security fixes', 'ai-guardwall' ), 'medium', 80, sprintf( /* translators: %s: value */ __( 'PHP %s is older than 8.2.35, the release with the latest PHP 8.2 security fixes. Ask your host for 8.2.35 or newer, or better switch to PHP 8.3 or newer in your hosting panel.', 'ai-guardwall' ), PHP_VERSION ), 'fix_config' ); } } private static function check_wp_config( array &$state ) { $path = Softvolt_Ai_Bodyguard_Wpconfig::path(); if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ( ! defined( 'WP_DEBUG_DISPLAY' ) || WP_DEBUG_DISPLAY ) ) { self::add( $state, 'WP_DEBUG', __( 'Debug output is shown to visitors', 'ai-guardwall' ), 'medium', 70, __( 'WP_DEBUG is on and WP_DEBUG_DISPLAY is not off, so error messages with file paths and database details can appear on the site. Set WP_DEBUG_DISPLAY to false (and WP_DEBUG off in production).', 'ai-guardwall' ), 'fix_config', array(), 'wp-config.php' ); } if ( ( ! defined( 'DISALLOW_FILE_EDIT' ) || ! DISALLOW_FILE_EDIT ) && ! Softvolt_Ai_Bodyguard_Settings::hardening_enabled( 'disable_file_edit' ) ) { self::add( $state, 'DISALLOW_FILE_EDIT', __( 'The theme/plugin file editor is enabled', 'ai-guardwall' ), 'low', 40, __( 'Anyone who gets an administrator login can write PHP through Appearance > Theme File Editor. Switch on "Disable the file editor" on the Hardening tab.', 'ai-guardwall' ), 'fix_config', array( 'rule' => 'disable_file_edit' ), 'wp-config.php' ); } $salts = Softvolt_Ai_Bodyguard_Wpconfig::weak_salts(); if ( $salts ) { self::add( $state, 'salts', __( 'Security keys and salts are weak or placeholders', 'ai-guardwall' ), 'high', 80, sprintf( /* translators: %s: list of salts */ __( 'These keys are missing or still the sample text: %s. Weak salts let attackers forge login cookies. Rotate them on the Tools tab.', 'ai-guardwall' ), implode( ', ', $salts ) ), 'fix_config', array( 'details' => implode( ', ', $salts ) ), 'wp-config.php' ); } global $wpdb; if ( 'wp_' === $wpdb->prefix ) { self::add( $state, 'table prefix', __( 'Database tables use the default "wp_" prefix', 'ai-guardwall' ), 'low', 20, __( 'Automated SQL-injection payloads assume wp_. A custom prefix is a small extra hurdle; change it only with a backup and a plugin made for it.', 'ai-guardwall' ), 'manual_review', array(), 'wp-config.php' ); } if ( $path && is_readable( $path ) ) { $content = (string) file_get_contents( $path ); if ( preg_match( '/\b(?:include|require)(?:_once)?\b\s*\(?\s*(?![\'"]?\s*ABSPATH\s*\.\s*[\'"]wp-settings\.php)/i', preg_replace( '~/\*.*?\*/|//[^\n]*|#[^\n]*~s', '', $content ) ) ) { self::add( $state, 'wp-config include', __( 'wp-config.php includes an extra file', 'ai-guardwall' ), 'high', 70, __( 'Besides wp-settings.php, wp-config.php loads another file. Hosts sometimes add environment files; malware hides loaders here. Open the file and check what is included.', 'ai-guardwall' ), 'manual_review', array( 'rel' => Softvolt_Ai_Bodyguard_Helpers::rel_path( $path ) ), 'wp-config.php' ); } } } private static function check_permissions( array &$state ) { if ( '\\' === DIRECTORY_SEPARATOR ) { return; // Windows reports 0777/0666 for everything; Unix permissions mean nothing here. } $items = array( 'wp-config.php' => array( Softvolt_Ai_Bodyguard_Wpconfig::path(), 'file' ), '.htaccess' => array( Softvolt_Ai_Bodyguard_Htaccess::root_file(), 'file' ), '/' => array( Softvolt_Ai_Bodyguard_Helpers::site_dir( '' ), 'dir' ), 'wp-admin/' => array( Softvolt_Ai_Bodyguard_Helpers::site_dir( '' ) . '/wp-admin', 'dir' ), 'wp-includes/' => array( Softvolt_Ai_Bodyguard_Helpers::site_dir( '' ) . '/' . WPINC, 'dir' ), 'wp-content/' => array( Softvolt_Ai_Bodyguard_Helpers::site_dir( 'wp-content' ), 'dir' ), 'wp-content/plugins/' => array( Softvolt_Ai_Bodyguard_Helpers::site_dir( 'wp-content/plugins' ), 'dir' ), 'wp-content/themes/' => array( Softvolt_Ai_Bodyguard_Helpers::site_dir( 'wp-content/themes' ), 'dir' ), 'wp-content/uploads/' => array( Softvolt_Ai_Bodyguard_Helpers::site_dir( 'wp-content/uploads' ), 'dir' ), ); foreach ( $items as $label => $info ) { list( $path, $kind ) = $info; if ( ! $path || ! file_exists( $path ) ) { continue; } $perms = @fileperms( $path ); if ( false === $perms ) { continue; } $mode = $perms & 0777; if ( $mode & 0002 ) { self::add( $state, 'perm|' . $label, sprintf( /* translators: %s: label */ __( '%s is writable by everyone', 'ai-guardwall' ), $label ), 'high', 85, sprintf( /* translators: 1: text, 2: value */ __( 'Permissions are %1$s. Any process on the server (another customer\'s site on shared hosting) can change it. Set %2$s.', 'ai-guardwall' ), sprintf( '%04o', $mode ), 'dir' === $kind ? '755' : ( 'wp-config.php' === $label ? '600' : '644' ) ), 'fix_config', array( 'details' => sprintf( '%04o', $mode ) ), $label ); } elseif ( 'wp-config.php' === $label && ( $mode & 0004 ) ) { self::add( $state, 'perm|' . $label, __( 'wp-config.php is readable by other users on the server', 'ai-guardwall' ), 'low', 35, sprintf( /* translators: %s: text */ __( 'Permissions are %s. On shared hosting, 600 or 640 keeps your database password private from other accounts (some hosts require 644; check with yours).', 'ai-guardwall' ), sprintf( '%04o', $mode ) ), 'fix_config', array( 'details' => sprintf( '%04o', $mode ) ), $label ); } } } private static function check_exposure( array &$state ) { if ( 'https' !== wp_parse_url( home_url(), PHP_URL_SCHEME ) ) { self::add( $state, 'https', __( 'The site does not use HTTPS', 'ai-guardwall' ), 'medium', 75, __( 'Logins and cookies travel in clear text. Install a free Let\'s Encrypt certificate at your host, enforce HTTPS and change both URLs under Settings > General to https://.', 'ai-guardwall' ), 'fix_config' ); } if ( ! Softvolt_Ai_Bodyguard_Settings::hardening_enabled( 'disable_xmlrpc' ) ) { self::add( $state, 'xmlrpc', __( 'XML-RPC is enabled', 'ai-guardwall' ), 'low', 30, __( 'xmlrpc.php is used for brute-force amplification (system.multicall) and pingback floods. Unless you use the WordPress mobile app or Jetpack, switch "Disable XML-RPC" on under Hardening.', 'ai-guardwall' ), 'fix_config', array( 'rule' => 'disable_xmlrpc' ), 'xmlrpc.php' ); } $probes = array( 'dir_listing' => array( includes_url(), 'GET', '/