array( 'title' => __('WordPress core is out of date', 'all-in-one-wp-content-security'), 'kind' => 'vulnerability', 'explanation' => __('WordPress publishes maintenance and security releases for the current version. Sites that do not install them keep running code with publicly documented, fixed vulnerabilities.', 'all-in-one-wp-content-security'), 'impact' => __('Known core vulnerabilities are routinely exploited by automated tools shortly after a fix is published.', 'all-in-one-wp-content-security'), 'remediation' => __('Back up the site and update WordPress from Dashboard → Updates.', 'all-in-one-wp-content-security'), 'steps' => array( __('Take a full backup (files and database).', 'all-in-one-wp-content-security'), __('Go to Dashboard → Updates and install the offered WordPress version.', 'all-in-one-wp-content-security'), __('Check the front end and the admin area, then re-run this check.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('Updating WordPress', 'all-in-one-wp-content-security'), 'https://wordpress.org/documentation/article/updating-wordpress/')), 'permission' => __('Administrator who can update WordPress (update_core)', 'all-in-one-wp-content-security'), ), ); } public function run($context) { $current = get_bloginfo('version'); $updates = get_site_transient('update_core'); if ((!is_object($updates) || empty($updates->updates)) && $context->allows('wporg')) { // WordPress' own update check (the same request WordPress makes twice a day) require_once ABSPATH . 'wp-admin/includes/update.php'; wp_version_check(array(), true); $updates = get_site_transient('update_core'); } if (!is_object($updates) || empty($updates->updates) || !is_array($updates->updates)) { return array($this->unknown('core.version_outdated', __('WordPress has not downloaded update information yet. It does so twice a day; opening Dashboard → Updates refreshes it.', 'all-in-one-wp-content-security'))); } $branch = implode('.', array_slice(explode('.', $current), 0, 2)); $latest = null; $latest_branch = null; foreach ($updates->updates as $offer) { if (!is_object($offer) || empty($offer->current) || !in_array(isset($offer->response) ? $offer->response : '', array('upgrade', 'autoupdate'), true)) { continue; } if (version_compare($offer->current, $current, '<=')) { continue; } if ($latest === null || version_compare($offer->current, $latest, '>')) { $latest = $offer->current; } if (strpos($offer->current, $branch . '.') === 0 && ($latest_branch === null || version_compare($offer->current, $latest_branch, '>'))) { $latest_branch = $offer->current; } } $checked = !empty($updates->last_checked) ? AOWPCS_Plugin::format_time(gmdate('Y-m-d H:i:s', $updates->last_checked)) : ''; if ($latest === null) { /* translators: 1: current, 2: checked */ return array($this->pass('core.version_outdated', sprintf(__('WordPress %1$s is the latest version (checked %2$s).', 'all-in-one-wp-content-security'), $current, $checked))); } $evidence = array( __('Installed version', 'all-in-one-wp-content-security') => $current, __('Latest available version', 'all-in-one-wp-content-security') => $latest, __('Update information checked', 'all-in-one-wp-content-security') => $checked, ); if ($latest_branch !== null) { $evidence[__('Latest release of your branch', 'all-in-one-wp-content-security')] = $latest_branch; /* translators: 1: current, 2: latest branch */ return array($this->issue('core.version_outdated', 'high', 'wordpress', sprintf(__('WordPress %1$s is installed; maintenance/security release %2$s of the same branch is available.', 'all-in-one-wp-content-security'), $current, $latest_branch), array( 'detected' => $current, 'expected' => $latest_branch, 'evidence' => $evidence, ))); } /* translators: 1: current, 2: latest */ return array($this->issue('core.version_outdated', 'medium', 'wordpress', sprintf(__('WordPress %1$s is installed; version %2$s is available. Only the latest version is fully supported.', 'all-in-one-wp-content-security'), $current, $latest), array( 'detected' => $current, 'expected' => $latest, 'evidence' => $evidence, ))); } } /** * Automatic background (security) updates */ class AOWPCS_Check_Core_Auto_Updates extends AOWPCS_Check { public function id() { return 'core.auto_updates'; } public function category() { return 'core'; } public function rules() { return array( 'core.auto_updates_disabled' => array( 'title' => __('Automatic security updates for WordPress are disabled', 'all-in-one-wp-content-security'), 'kind' => 'hardening', 'explanation' => __('By default WordPress installs minor (maintenance and security) releases automatically. This has been switched off on this site.', 'all-in-one-wp-content-security'), 'impact' => __('Security fixes are only installed when somebody remembers to update manually, which leaves a window in which known vulnerabilities can be exploited.', 'all-in-one-wp-content-security'), 'remediation' => __('Re-enable automatic minor updates, unless your host or deployment process installs updates for you.', 'all-in-one-wp-content-security'), 'steps' => array( __('Remove define(\'AUTOMATIC_UPDATER_DISABLED\', true); and define(\'WP_AUTO_UPDATE_CORE\', false); from wp-config.php, or set WP_AUTO_UPDATE_CORE to \'minor\'.', 'all-in-one-wp-content-security'), __('Check that no plugin or must-use plugin disables updates with the automatic_updater_disabled or allow_minor_auto_core_updates filters.', 'all-in-one-wp-content-security'), __('If your site is deployed from version control, make sure your deployment applies WordPress security releases promptly.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('Configuring automatic background updates', 'all-in-one-wp-content-security'), 'https://wordpress.org/documentation/article/configuring-automatic-background-updates/')), 'permission' => __('Access to wp-config.php (FTP, SSH or hosting file manager)', 'all-in-one-wp-content-security'), ), ); } public function run($context) { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php'; $reasons = array(); $updater = new WP_Automatic_Updater(); if ($updater->is_disabled()) { $reasons[] = __('Automatic updates are disabled (AUTOMATIC_UPDATER_DISABLED, DISALLOW_FILE_MODS or the automatic_updater_disabled filter).', 'all-in-one-wp-content-security'); } if (defined('WP_AUTO_UPDATE_CORE') && WP_AUTO_UPDATE_CORE === false) { $reasons[] = __('WP_AUTO_UPDATE_CORE is set to false in wp-config.php.', 'all-in-one-wp-content-security'); } if (!apply_filters('allow_minor_auto_core_updates', true)) { $reasons[] = __('A plugin disables minor core updates with the allow_minor_auto_core_updates filter.', 'all-in-one-wp-content-security'); } if (method_exists($updater, 'is_vcs_checkout') && $updater->is_vcs_checkout(ABSPATH)) { $reasons[] = __('WordPress is installed from a version control checkout, which disables automatic updates.', 'all-in-one-wp-content-security'); } if (empty($reasons)) { return array($this->pass('core.auto_updates_disabled', __('Automatic minor (security) updates are enabled.', 'all-in-one-wp-content-security'))); } $host = AOWPCS_Environment::managed_host(); $extra = array('evidence' => array(__('Reasons', 'all-in-one-wp-content-security') => $reasons), 'detected' => __('Disabled', 'all-in-one-wp-content-security'), 'expected' => __('Minor updates enabled', 'all-in-one-wp-content-security')); if ($host) { $extra['evidence'][__('Managed host', 'all-in-one-wp-content-security')] = $host['name']; /* translators: %s: host name */ $extra['steps'] = array(sprintf(__('Your site appears to be hosted by %s, which may install WordPress updates for you. Confirm this with your host; if so you can accept this risk.', 'all-in-one-wp-content-security'), $host['name'])); return array($this->issue('core.auto_updates_disabled', 'low', 'core-auto-updates', __('Automatic security updates are disabled, but your managed host may apply them.', 'all-in-one-wp-content-security'), $extra)); } return array($this->issue('core.auto_updates_disabled', 'medium', 'core-auto-updates', __('Automatic security updates are disabled.', 'all-in-one-wp-content-security'), $extra)); } } /** * Security-relevant wp-config.php constants (values of secrets are never read out) */ class AOWPCS_Check_Core_Config extends AOWPCS_Check { public function id() { return 'core.config'; } public function category() { return 'core'; } public function rules() { $wp_config_doc = self::doc(__('Editing wp-config.php', 'all-in-one-wp-content-security'), 'https://developer.wordpress.org/advanced-administration/wordpress/wp-config/'); $permission = __('Access to wp-config.php (FTP, SSH or hosting file manager)', 'all-in-one-wp-content-security'); return array( 'core.salts' => array( 'title' => __('Authentication keys and salts are missing, default or duplicated', 'all-in-one-wp-content-security'), 'explanation' => __('The eight keys and salts in wp-config.php sign the login cookies. When they are missing or left at the sample value, WordPress generates replacements and stores them in the database.', 'all-in-one-wp-content-security'), 'impact' => __('Anyone who obtains a copy of the database (for example from a leaked backup) also obtains the secrets needed to forge login cookies.', 'all-in-one-wp-content-security'), 'remediation' => __('Define unique random values for all eight constants in wp-config.php.', 'all-in-one-wp-content-security'), 'steps' => array( __('Open https://api.wordpress.org/secret-key/1.1/salt/ to generate eight new random values.', 'all-in-one-wp-content-security'), __('Replace the AUTH_KEY … NONCE_SALT lines in wp-config.php with the generated lines (or add them if they are missing).', 'all-in-one-wp-content-security'), __('Everyone, including you, will have to log in again.', 'all-in-one-wp-content-security'), ), 'docs' => array($wp_config_doc), 'permission' => $permission, ), 'core.file_edit' => array( 'title' => __('The built-in plugin and theme file editor is enabled', 'all-in-one-wp-content-security'), 'kind' => 'hardening', 'explanation' => __('WordPress lets administrators edit plugin and theme PHP files from the dashboard unless DISALLOW_FILE_EDIT is set.', 'all-in-one-wp-content-security'), 'impact' => __('An attacker who takes over an administrator account can immediately run their own PHP code on the server through the editor.', 'all-in-one-wp-content-security'), 'remediation' => __('Disable the editor. This plugin can do it for you (Firewall & Protection → Hardening), or add define(\'DISALLOW_FILE_EDIT\', true); to wp-config.php.', 'all-in-one-wp-content-security'), 'steps' => array( __('Use the "Apply fix" button, or add define(\'DISALLOW_FILE_EDIT\', true); to wp-config.php above the line "That\'s all, stop editing!".', 'all-in-one-wp-content-security'), __('Edit code with an SFTP client or a deployment workflow instead.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('Hardening WordPress: disable file editing', 'all-in-one-wp-content-security'), 'https://developer.wordpress.org/advanced-administration/security/hardening/#disable-file-editing')), 'permission' => __('WordPress administrator (fix) or access to wp-config.php', 'all-in-one-wp-content-security'), 'fix' => 'disable_file_edit', ), 'core.force_ssl_admin' => array( 'title' => __('Administration over HTTPS is not enforced', 'all-in-one-wp-content-security'), 'kind' => 'hardening', 'explanation' => __('The site uses HTTPS, but FORCE_SSL_ADMIN is not set, so the login page and dashboard can still be opened over plain HTTP if the server allows it.', 'all-in-one-wp-content-security'), 'impact' => __('On an untrusted network, passwords and login cookies sent over plain HTTP can be intercepted.', 'all-in-one-wp-content-security'), 'remediation' => __('Add define(\'FORCE_SSL_ADMIN\', true); to wp-config.php.', 'all-in-one-wp-content-security'), 'steps' => array(__('Add define(\'FORCE_SSL_ADMIN\', true); to wp-config.php above "That\'s all, stop editing!".', 'all-in-one-wp-content-security')), 'docs' => array(self::doc(__('Administration over SSL', 'all-in-one-wp-content-security'), 'https://developer.wordpress.org/advanced-administration/security/https/')), 'permission' => $permission, ), 'core.debug_mode' => array( 'title' => __('WordPress debug mode is enabled on a production site', 'all-in-one-wp-content-security'), 'explanation' => __('WP_DEBUG is meant for development. On a live site it increases the amount of internal information produced by warnings and notices.', 'all-in-one-wp-content-security'), 'impact' => __('Debug output and log files can reveal file paths, plugin names and internal details that help an attacker.', 'all-in-one-wp-content-security'), 'remediation' => __('Set WP_DEBUG to false on production sites; if you need logs, keep WP_DEBUG_DISPLAY false and write the log outside the web root.', 'all-in-one-wp-content-security'), 'steps' => array( __('In wp-config.php set define(\'WP_DEBUG\', false);', 'all-in-one-wp-content-security'), __('If you must debug in production: define(\'WP_DEBUG_DISPLAY\', false); and define(\'WP_DEBUG_LOG\', \'/path/outside/webroot/debug.log\');', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('Debugging in WordPress', 'all-in-one-wp-content-security'), 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/')), 'permission' => $permission, ), 'core.debug_display' => array( 'title' => __('WordPress shows PHP errors to visitors', 'all-in-one-wp-content-security'), 'kind' => 'misconfiguration', 'explanation' => __('WP_DEBUG is enabled and WP_DEBUG_DISPLAY is not false, so PHP warnings and errors are printed into the pages visitors receive.', 'all-in-one-wp-content-security'), 'impact' => __('Error messages disclose server paths, plugin internals and sometimes database details, and can break page output.', 'all-in-one-wp-content-security'), 'remediation' => __('Set WP_DEBUG_DISPLAY to false (or WP_DEBUG to false). As an immediate mitigation the plugin can hide errors at runtime.', 'all-in-one-wp-content-security'), 'steps' => array( __('In wp-config.php set define(\'WP_DEBUG_DISPLAY\', false); (or define(\'WP_DEBUG\', false);).', 'all-in-one-wp-content-security'), __('Optional immediate mitigation: use "Apply fix" to hide errors at runtime until wp-config.php is corrected.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('Debugging in WordPress', 'all-in-one-wp-content-security'), 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/')), 'permission' => $permission, 'fix' => 'hide_errors_runtime', ), 'core.debug_log_location' => array( 'title' => __('The debug log is written inside the web root', 'all-in-one-wp-content-security'), 'kind' => 'hardening', 'explanation' => __('WP_DEBUG_LOG is true, so WordPress writes errors to wp-content/debug.log, a location the web server can normally serve to anyone who knows the URL.', 'all-in-one-wp-content-security'), 'impact' => __('Debug logs collect paths, database errors and sometimes personal data; bots request /wp-content/debug.log on every WordPress site they find.', 'all-in-one-wp-content-security'), 'remediation' => __('Point WP_DEBUG_LOG to a file outside the web root, or disable it when you are not debugging. Whether the current file is publicly reachable is checked separately (Web server category).', 'all-in-one-wp-content-security'), 'steps' => array( __('Set define(\'WP_DEBUG_LOG\', \'/home/account/logs/wp-debug.log\'); (a directory that is not below the web root), or define(\'WP_DEBUG_LOG\', false);', 'all-in-one-wp-content-security'), __('Delete the old wp-content/debug.log after reviewing it.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('Debugging in WordPress', 'all-in-one-wp-content-security'), 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/')), 'permission' => $permission, ), ); } public function run($context) { $findings = array(); // Keys and salts: only whether they are defined, unique and not the sample value $names = array('AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT'); $missing = array(); $default = array(); $values = array(); foreach ($names as $name) { if (!defined($name) || constant($name) === '') { $missing[] = $name; continue; } $value = constant($name); if ($value === 'put your unique phrase here') { $default[] = $name; } $values[$name] = $value; } $counts = array_count_values($values); $duplicated = array(); foreach ($values as $name => $value) { if ($counts[$value] > 1) { $duplicated[] = $name; } } unset($values, $counts); if ($missing || $default || $duplicated) { $evidence = array(); if ($missing) { $evidence[__('Not defined in wp-config.php', 'all-in-one-wp-content-security')] = $missing; } if ($default) { $evidence[__('Still set to the sample value', 'all-in-one-wp-content-security')] = $default; } if ($duplicated) { $evidence[__('Same value used more than once', 'all-in-one-wp-content-security')] = $duplicated; } $findings[] = $this->issue('core.salts', 'medium', 'wp-config-salts', __('Some authentication keys or salts are missing, default or duplicated.', 'all-in-one-wp-content-security'), array( 'evidence' => $evidence, /* translators: %d: value */ 'detected' => sprintf(__('%d of 8 constants need attention', 'all-in-one-wp-content-security'), count(array_unique(array_merge($missing, $default, $duplicated)))), 'expected' => __('8 unique random values', 'all-in-one-wp-content-security'), )); } // File editor if (!defined('DISALLOW_FILE_EDIT') || !DISALLOW_FILE_EDIT) { if (!(defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS)) { $findings[] = $this->issue('core.file_edit', 'low', 'DISALLOW_FILE_EDIT', __('Administrators can edit plugin and theme PHP files from the dashboard.', 'all-in-one-wp-content-security'), array( 'detected' => 'DISALLOW_FILE_EDIT: ' . __('not set', 'all-in-one-wp-content-security'), 'expected' => 'DISALLOW_FILE_EDIT: true', )); } } elseif (AOWPCS_Hardening::is_enforced('disable_file_edit')) { $findings[] = $this->pass('core.file_edit', __('The file editor is disabled by this plugin (Firewall & Protection → Hardening).', 'all-in-one-wp-content-security')); } // Admin over HTTPS if (wp_is_using_https() && (!defined('FORCE_SSL_ADMIN') || !FORCE_SSL_ADMIN)) { $findings[] = $this->issue('core.force_ssl_admin', 'low', 'FORCE_SSL_ADMIN', __('The site uses HTTPS but FORCE_SSL_ADMIN is not set.', 'all-in-one-wp-content-security'), array( 'detected' => 'FORCE_SSL_ADMIN: ' . __('not set', 'all-in-one-wp-content-security'), 'expected' => 'FORCE_SSL_ADMIN: true', )); } // Debug settings $production = AOWPCS_Plugin::is_production(); $environment = array(__('Environment type', 'all-in-one-wp-content-security') => wp_get_environment_type()); if (defined('WP_DEBUG') && WP_DEBUG) { if ($production) { $findings[] = $this->issue('core.debug_mode', 'medium', 'WP_DEBUG', __('WP_DEBUG is enabled on a site whose environment type is "production".', 'all-in-one-wp-content-security'), array( 'detected' => 'WP_DEBUG: true', 'expected' => 'WP_DEBUG: false', 'evidence' => $environment, )); $display = !defined('WP_DEBUG_DISPLAY') || WP_DEBUG_DISPLAY; if ($display) { $extra = array( 'detected' => 'WP_DEBUG_DISPLAY: ' . (defined('WP_DEBUG_DISPLAY') ? var_export(WP_DEBUG_DISPLAY, true) : __('not set (defaults to true)', 'all-in-one-wp-content-security')), 'expected' => 'WP_DEBUG_DISPLAY: false', 'evidence' => $environment, ); if (AOWPCS_Hardening::is_enforced('hide_errors_runtime')) { $extra['steps'] = array(__('Errors are currently hidden at runtime by this plugin, but errors raised before plugins load are still displayed. Correct wp-config.php to remove the risk completely.', 'all-in-one-wp-content-security')); $findings[] = $this->issue('core.debug_display', 'low', 'WP_DEBUG_DISPLAY', __('WordPress is configured to display errors; this plugin currently hides them at runtime.', 'all-in-one-wp-content-security'), $extra); } else { $findings[] = $this->issue('core.debug_display', 'high', 'WP_DEBUG_DISPLAY', __('PHP errors are displayed to visitors.', 'all-in-one-wp-content-security'), $extra); } } } else { /* translators: %s: type */ $findings[] = $this->pass('core.debug_mode', sprintf(__('WP_DEBUG is enabled, which is expected for a "%s" environment.', 'all-in-one-wp-content-security'), wp_get_environment_type())); } if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG === true) { $findings[] = $this->issue('core.debug_log_location', 'low', 'WP_DEBUG_LOG', __('The debug log is written to wp-content/debug.log inside the web root.', 'all-in-one-wp-content-security'), array( 'detected' => 'WP_DEBUG_LOG: true (wp-content/debug.log)', 'expected' => __('false, or a path outside the web root', 'all-in-one-wp-content-security'), )); } elseif (defined('WP_DEBUG_LOG') && is_string(WP_DEBUG_LOG) && strpos(wp_normalize_path(WP_DEBUG_LOG), wp_normalize_path(ABSPATH)) === 0) { $findings[] = $this->issue('core.debug_log_location', 'low', 'WP_DEBUG_LOG', __('The debug log is written to a file inside the web root.', 'all-in-one-wp-content-security'), array( 'detected' => 'WP_DEBUG_LOG: ' . AOWPCS_Plugin::relative_path(WP_DEBUG_LOG), 'expected' => __('false, or a path outside the web root', 'all-in-one-wp-content-security'), )); } } return $findings; } } /** * Registration role and well-known administrator user names */ class AOWPCS_Check_Core_Users extends AOWPCS_Check { public function id() { return 'core.users'; } public function category() { return 'core'; } public function rules() { return array( 'core.registration_role' => array( 'title' => __('Anyone can register with a privileged role', 'all-in-one-wp-content-security'), 'explanation' => __('"Anyone can register" is enabled and new users receive a role that can do more than read. This combination is a frequent result of malicious option changes.', 'all-in-one-wp-content-security'), 'impact' => __('Any visitor can create an account with these privileges; with an administrator default role, anyone can take over the site.', 'all-in-one-wp-content-security'), 'remediation' => __('Set "New User Default Role" to Subscriber, or disable registration, in Settings → General.', 'all-in-one-wp-content-security'), 'steps' => array( __('Open Settings → General.', 'all-in-one-wp-content-security'), __('Set "New User Default Role" to Subscriber, or untick "Anyone can register" if you do not need registration.', 'all-in-one-wp-content-security'), __('Review Users → All Users for accounts created while the setting was active, and check the Security Events log for who changed the setting.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('Roles and capabilities', 'all-in-one-wp-content-security'), 'https://wordpress.org/documentation/article/roles-and-capabilities/')), ), 'core.admin_username' => array( 'title' => __('An administrator uses the user name "admin"', 'all-in-one-wp-content-security'), 'kind' => 'hardening', 'explanation' => __('"admin" is the first user name automated password-guessing tools try.', 'all-in-one-wp-content-security'), 'impact' => __('Attackers only need to guess the password. A strong password and login protection reduce the risk considerably.', 'all-in-one-wp-content-security'), 'remediation' => __('Create a new administrator with a different user name, log in with it, and delete "admin" (attributing its content to the new account).', 'all-in-one-wp-content-security'), 'steps' => array( __('Users → Add New: create an administrator with a unique user name and a strong password.', 'all-in-one-wp-content-security'), __('Log in as the new user and delete "admin", choosing "Attribute all content to" the new user.', 'all-in-one-wp-content-security'), __('Enable login protection in Firewall & Protection.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('Brute force attacks', 'all-in-one-wp-content-security'), 'https://developer.wordpress.org/advanced-administration/security/brute-force/')), ), ); } /** * How dangerous a role is: critical, high, medium, low or '' (read only) */ public static function role_risk($role_name) { $role = get_role($role_name); if (!$role) { return ''; } $caps = array_keys(array_filter($role->capabilities)); $critical = array('manage_options', 'edit_users', 'promote_users', 'create_users', 'delete_users', 'install_plugins', 'activate_plugins', 'edit_plugins', 'edit_themes', 'update_core', 'manage_network'); if (array_intersect($critical, $caps)) { return 'critical'; } if (array_intersect(array('unfiltered_html', 'unfiltered_upload', 'edit_others_posts', 'edit_others_pages'), $caps)) { return 'high'; } if (array_intersect(array('publish_posts', 'upload_files', 'publish_pages'), $caps)) { return 'medium'; } if (array_intersect(array('edit_posts', 'edit_pages'), $caps)) { return 'low'; } return ''; } public function run($context) { $findings = array(); $role = get_option('default_role'); if (get_option('users_can_register')) { $risk = self::role_risk($role); if ($risk !== '') { /* translators: %s: role */ $findings[] = $this->issue('core.registration_role', $risk, 'default_role', sprintf(__('Registration is open and new users get the "%s" role.', 'all-in-one-wp-content-security'), $role), array( 'kind' => $risk === 'critical' ? 'compromise' : 'misconfiguration', 'confidence' => 'confirmed', 'detected' => sprintf('users_can_register = 1, default_role = %s', $role), 'expected' => __('default_role = subscriber, or registration disabled', 'all-in-one-wp-content-security'), )); } else { /* translators: %s: role */ $findings[] = $this->pass('core.registration_role', sprintf(__('Registration is open with the low-privilege "%s" role.', 'all-in-one-wp-content-security'), $role)); } } else { $findings[] = $this->pass('core.registration_role', __('User registration is disabled.', 'all-in-one-wp-content-security')); } $admin = get_user_by('login', 'admin'); if ($admin && user_can($admin, 'manage_options')) { $findings[] = $this->issue('core.admin_username', 'low', 'user:' . $admin->ID, __('An administrator account uses the user name "admin".', 'all-in-one-wp-content-security'), array( 'detected' => 'admin', 'expected' => __('A unique user name', 'all-in-one-wp-content-security'), 'evidence' => array(__('User ID', 'all-in-one-wp-content-security') => $admin->ID), )); } return $findings; } } /** * Core files against the official checksums published by WordPress.org */ class AOWPCS_Check_Core_Checksums extends AOWPCS_Check { const MAX_FINDINGS = 100; public function id() { return 'core.checksums'; } public function category() { return 'core'; } public function cost() { return 'io'; } public function requires() { return array('wporg'); } public function is_batched() { return true; } public function rules() { $reinstall = array( __('Inspect the file (the evidence shows its size and modification time) and compare it with the official copy from wordpress.org/download.', 'all-in-one-wp-content-security'), __('If you did not change it on purpose, reinstall WordPress from Dashboard → Updates → "Re-install version …". This replaces core files only and keeps wp-content and wp-config.php.', 'all-in-one-wp-content-security'), __('If the file contained unknown code, treat the site as compromised: change all passwords, review administrator accounts and look for other modified files.', 'all-in-one-wp-content-security'), __('Run the check again to confirm.', 'all-in-one-wp-content-security'), ); $doc = self::doc(__('FAQ: My site was hacked', 'all-in-one-wp-content-security'), 'https://developer.wordpress.org/advanced-administration/security/hacking/'); return array( 'core.file_modified' => array( 'title' => __('A WordPress core file differs from the official release', 'all-in-one-wp-content-security'), 'kind' => 'integrity', 'explanation' => __('The file\'s checksum does not match the checksum WordPress.org publishes for your WordPress version and language.', 'all-in-one-wp-content-security'), 'impact' => __('Modified core files are a common place for malware and backdoors. A change may also be a harmless manual edit, which is still lost on the next update.', 'all-in-one-wp-content-security'), 'remediation' => __('Restore the official file by reinstalling the current WordPress version.', 'all-in-one-wp-content-security'), 'steps' => $reinstall, 'docs' => array($doc), ), 'core.file_missing' => array( 'title' => __('A WordPress core file is missing', 'all-in-one-wp-content-security'), 'kind' => 'integrity', 'explanation' => __('A file that is part of your WordPress version does not exist on disk.', 'all-in-one-wp-content-security'), 'impact' => __('Missing files usually indicate an incomplete update and can break features; occasionally files are removed by cleanup tools after a compromise.', 'all-in-one-wp-content-security'), 'remediation' => __('Reinstall the current WordPress version from Dashboard → Updates.', 'all-in-one-wp-content-security'), 'steps' => $reinstall, 'docs' => array($doc), ), 'core.file_unexpected' => array( 'title' => __('Unexpected PHP file in wp-admin or wp-includes', 'all-in-one-wp-content-security'), 'kind' => 'compromise', 'explanation' => __('This PHP file is not part of your WordPress version. WordPress does not create extra PHP files in wp-admin or wp-includes.', 'all-in-one-wp-content-security'), 'impact' => __('Backdoors are frequently hidden in core directories because they are rarely inspected. If the file is malicious, an attacker can run code on the server.', 'all-in-one-wp-content-security'), 'remediation' => __('Find out where the file came from; remove it if nobody can explain it (after taking a backup).', 'all-in-one-wp-content-security'), 'steps' => array( __('Check the file\'s modification time against your update history and the Security Events log.', 'all-in-one-wp-content-security'), __('Leftovers of old WordPress versions are harmless but should be removed; files with obfuscated code (eval, base64_decode, long encoded strings) indicate a compromise.', 'all-in-one-wp-content-security'), __('Take a backup, delete the file, and run the check again.', 'all-in-one-wp-content-security'), ), 'docs' => array($doc), ), 'core.root_unexpected_file' => array( 'title' => __('Unknown PHP file in the WordPress root directory', 'all-in-one-wp-content-security'), 'kind' => 'integrity', 'explanation' => __('This PHP file in the WordPress root directory is neither part of WordPress nor a known configuration file.', 'all-in-one-wp-content-security'), 'impact' => __('Leftover tools (installers, database managers, test scripts) and uploaded backdoors in the root directory can be executed by anyone who knows the URL.', 'all-in-one-wp-content-security'), 'remediation' => __('Identify the file; remove it if it is not needed.', 'all-in-one-wp-content-security'), 'steps' => array( __('Open the file over SFTP and identify its purpose (some hosts and security plugins place legitimate files here).', 'all-in-one-wp-content-security'), __('Remove files you do not need, or accept the risk for legitimate files.', 'all-in-one-wp-content-security'), ), 'docs' => array($doc), ), ); } /** * Official checksums for the installed version (cached for a week) */ public static function checksums() { $version = get_bloginfo('version'); $locale = get_locale(); $key = 'aowpcs_core_sums_' . md5($version . $locale); $cached = get_site_transient($key); if (is_array($cached)) { return $cached; } require_once ABSPATH . 'wp-admin/includes/update.php'; $sums = get_core_checksums($version, $locale); if (!is_array($sums) && $locale !== 'en_US') { $sums = get_core_checksums($version, 'en_US'); } if (!is_array($sums) || empty($sums)) { return null; } set_site_transient($key, $sums, WEEK_IN_SECONDS); return $sums; } /** * Root PHP files that are expected besides core: configuration files and well-known add-ons */ private static function known_root_files() { return apply_filters('aowpcs_known_root_files', array('wp-config.php', 'wp-config-local.php', 'local-config.php', 'wp-config-docker.php', 'wordfence-waf.php', 'wp-cli.php', 'object-cache.php')); } public function run_batch($context, $cursor) { $sums = self::checksums(); if ($sums === null) { /* translators: %s: version */ return array($this->all_unknown(sprintf(__('Official checksums for WordPress %s could not be downloaded from WordPress.org (development and pre-release versions have none).', 'all-in-one-wp-content-security'), get_bloginfo('version'))), null); } if (!is_array($cursor)) { $cursor = array('phase' => 'hash', 'index' => 0, 'counts' => array('modified' => 0, 'missing' => 0, 'unexpected' => 0, 'root' => 0), 'walk' => null); } $findings = array(); $files = array_keys($sums); $optional = array('readme.html', 'license.txt', 'wp-config-sample.php', 'wp-admin/install.php', 'wp-admin/setup-config.php', 'wp-admin/upgrade.php'); if ($cursor['phase'] === 'hash') { $total = count($files); while ($cursor['index'] < $total) { if (($cursor['index'] % 25) === 0 && $context->out_of_time()) { return array($findings, $cursor); } $file = $files[$cursor['index']++]; if (strpos($file, 'wp-content/') === 0) { continue; } $path = ABSPATH . $file; if (!file_exists($path)) { if (!in_array($file, $optional, true) && $cursor['counts']['missing']++ < self::MAX_FINDINGS) { /* translators: %s: file */ $findings[] = $this->issue('core.file_missing', 'medium', $file, sprintf(__('%s is missing.', 'all-in-one-wp-content-security'), $file), array('confidence' => 'confirmed', 'detected' => __('missing', 'all-in-one-wp-content-security'), 'expected' => __('present', 'all-in-one-wp-content-security'))); } continue; } $hash = @md5_file($path); if ($hash !== false && !hash_equals($sums[$file], $hash) && $cursor['counts']['modified']++ < self::MAX_FINDINGS) { /* translators: %s: file */ $findings[] = $this->issue('core.file_modified', 'high', $file, sprintf(__('%s does not match the official WordPress release.', 'all-in-one-wp-content-security'), $file), array( 'confidence' => 'confirmed', 'detected' => 'md5 ' . $hash, 'expected' => 'md5 ' . $sums[$file], 'evidence' => self::file_evidence($path), )); } } $cursor['phase'] = 'walk'; } if ($cursor['phase'] === 'walk') { if ($cursor['walk'] === null) { $cursor['walk'] = AOWPCS_File_Walker::start(array(ABSPATH . 'wp-admin', ABSPATH . WPINC)); } $known = array_flip($files); $self = $this; $counts = &$cursor['counts']; $cursor['walk'] = AOWPCS_File_Walker::walk($cursor['walk'], function ($path) use ($known, $self, &$findings, &$counts) { if (!preg_match('/\.(php[0-9]?|phtml|phar|pht)$/i', $path)) { return; } $relative = AOWPCS_Plugin::relative_path($path); if (!isset($known[$relative]) && $counts['unexpected']++ < AOWPCS_Check_Core_Checksums::MAX_FINDINGS) { $findings[] = $self->unexpected_finding($relative, $path); } }, $context->deadline, array('max_files' => $context->max_files())); unset($counts); if (!AOWPCS_File_Walker::is_done($cursor['walk'])) { return array($findings, $cursor); } // Root directory (not recursive) $known_root = self::known_root_files(); foreach ((array) @scandir(ABSPATH) as $name) { $path = ABSPATH . $name; if (!is_file($path) || is_link($path) || !preg_match('/\.(php[0-9]?|phtml|phar|pht)$/i', $name)) { continue; } if (!isset($known[$name]) && !in_array($name, $known_root, true) && $cursor['counts']['root']++ < self::MAX_FINDINGS) { /* translators: %s: name */ $findings[] = $this->issue('core.root_unexpected_file', 'medium', $name, sprintf(__('%s is not part of WordPress.', 'all-in-one-wp-content-security'), $name), array( 'confidence' => 'unverified', 'evidence' => self::file_evidence($path), )); } } } foreach (array('modified' => array('core.file_modified', 'high', 'confirmed'), 'missing' => array('core.file_missing', 'high', 'confirmed'), 'unexpected' => array('core.file_unexpected', 'high', 'confirmed'), 'root' => array('core.root_unexpected_file', 'medium', 'unverified')) as $type => $rule) { if (isset($cursor['counts'][$type]) && $cursor['counts'][$type] > self::MAX_FINDINGS) { /* translators: %d: number of files */ $findings[] = $this->issue($rule[0], $rule[1], '_more', sprintf(__('%d more files were not listed individually.', 'all-in-one-wp-content-security'), $cursor['counts'][$type] - self::MAX_FINDINGS), array('confidence' => $rule[2])); } } return array($findings, null); } public function unexpected_finding($relative, $path) { /* translators: 1: relative, 2: version */ return $this->issue('core.file_unexpected', 'high', $relative, sprintf(__('%1$s is not part of WordPress %2$s.', 'all-in-one-wp-content-security'), $relative, get_bloginfo('version')), array( 'confidence' => 'likely', 'evidence' => self::file_evidence($path), )); } /** * Size, modification time, owner and permissions of a file */ public static function file_evidence($path) { $stat = @stat($path); if (!$stat) { return array(); } $evidence = array( __('Size', 'all-in-one-wp-content-security') => size_format($stat['size'], 1) ?: '0 B', __('Modified', 'all-in-one-wp-content-security') => AOWPCS_Plugin::format_time(gmdate('Y-m-d H:i:s', $stat['mtime'])), __('Permissions', 'all-in-one-wp-content-security') => sprintf('%o', $stat['mode'] & 0777), ); if (function_exists('posix_getpwuid')) { $owner = @posix_getpwuid($stat['uid']); $evidence[__('Owner', 'all-in-one-wp-content-security')] = is_array($owner) ? $owner['name'] : (string) $stat['uid']; } if ($stat['size'] <= 5242880) { $evidence['SHA-1'] = (string) @sha1_file($path); } return $evidence; } } /** * What the public can see: version disclosure, user enumeration, exposed sensitive files and * directory listings — every candidate is verified with a real request */ class AOWPCS_Check_Core_Exposure extends AOWPCS_Check { public function id() { return 'core.exposure'; } public function category() { return 'core'; } public function cost() { return 'network'; } public function needs_loopback() { return true; } public function is_batched() { return true; } public function rules() { return array( 'core.version_disclosure' => array( 'title' => __('The WordPress version is published in page source', 'all-in-one-wp-content-security'), 'kind' => 'informational', 'explanation' => __('WordPress adds a "generator" meta tag with its version number to every page.', 'all-in-one-wp-content-security'), 'impact' => __('Low. The version can usually be inferred in other ways, so hiding it is not a fix. What matters is that the version is current; hiding it only removes an easy hint for automated scanners.', 'all-in-one-wp-content-security'), 'remediation' => __('Keep WordPress updated. Optionally remove the generator tag (Firewall & Protection → Hardening).', 'all-in-one-wp-content-security'), 'steps' => array(__('Use "Apply fix" to remove the generator tag, then re-run the check.', 'all-in-one-wp-content-security')), 'fix' => 'hide_generator', ), 'core.readme_disclosure' => array( 'title' => __('readme.html is publicly accessible', 'all-in-one-wp-content-security'), 'kind' => 'informational', 'explanation' => __('The readme.html file shipped with WordPress is reachable in the browser.', 'all-in-one-wp-content-security'), 'impact' => __('Low: it confirms the site runs WordPress. It is restored by every core update.', 'all-in-one-wp-content-security'), 'remediation' => __('Optional: delete readme.html after each update, or deny access to it in the web server configuration.', 'all-in-one-wp-content-security'), 'steps' => array(__('Delete readme.html from the WordPress root directory (it comes back with core updates), or add a web server rule that denies it.', 'all-in-one-wp-content-security')), 'permission' => __('File access (SFTP) or web server configuration', 'all-in-one-wp-content-security'), ), 'core.rest_user_enumeration' => array( 'title' => __('User names can be listed anonymously', 'all-in-one-wp-content-security'), 'kind' => 'informational', 'explanation' => __('The REST API endpoint /wp-json/wp/v2/users and author archive redirects (?author=1) reveal the user names (slugs) of people who published content. This is standard WordPress behaviour, not a vulnerability.', 'all-in-one-wp-content-security'), 'impact' => __('User names are not secrets, but knowing them makes password-guessing attacks more efficient. Strong passwords and login protection are the effective defence.', 'all-in-one-wp-content-security'), 'remediation' => __('Optional: restrict the users endpoint and author enumeration for anonymous visitors (Firewall & Protection → REST API).', 'all-in-one-wp-content-security'), 'steps' => array( __('Use "Apply fix" to restrict user enumeration for visitors who are not logged in.', 'all-in-one-wp-content-security'), __('Check that themes or headless front ends you use do not rely on anonymous access to /wp/v2/users.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('REST API: Users', 'all-in-one-wp-content-security'), 'https://developer.wordpress.org/rest-api/reference/users/')), 'fix' => 'rest_user_enumeration', ), 'server.sensitive_file_public' => array( 'title' => __('A sensitive file can be downloaded by anyone', 'all-in-one-wp-content-security'), 'category' => 'server', 'kind' => 'vulnerability', 'explanation' => __('A file that should never be public (log, environment file, configuration backup or version control data) exists on the server and was downloaded successfully with an anonymous request.', 'all-in-one-wp-content-security'), 'impact' => __('Such files can contain database passwords, API keys, personal data or the full source code history. Bots request these paths on every site they find.', 'all-in-one-wp-content-security'), 'remediation' => __('Remove the file from the web root (or move it outside), then rotate any credentials it contained.', 'all-in-one-wp-content-security'), 'steps' => array( __('Download the file yourself and check what it contains.', 'all-in-one-wp-content-security'), __('Delete it or move it outside the web root. For logs, change the log destination so it is not recreated in a public place.', 'all-in-one-wp-content-security'), __('If it contained passwords or keys (database, SMTP, API), change them now — assume they were copied.', 'all-in-one-wp-content-security'), __('Run the check again.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('OWASP: Review webserver metafiles for information leakage', 'all-in-one-wp-content-security'), 'https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/01-Information_Gathering/03-Review_Webserver_Metafiles_for_Information_Leakage')), 'permission' => __('File access (SFTP or hosting file manager)', 'all-in-one-wp-content-security'), ), 'server.directory_listing' => array( 'title' => __('Directory listing is enabled', 'all-in-one-wp-content-security'), 'category' => 'server', 'explanation' => __('The web server shows a list of files when a directory without an index file is requested.', 'all-in-one-wp-content-security'), 'impact' => __('Visitors and bots can browse uploaded files, including private documents, backups and files left by plugins that were never linked anywhere.', 'all-in-one-wp-content-security'), 'remediation' => __('Disable directory indexes in the web server configuration.', 'all-in-one-wp-content-security'), 'steps' => array( __('Apache / LiteSpeed: add "Options -Indexes" to the .htaccess file in the WordPress root directory.', 'all-in-one-wp-content-security'), __('Nginx: make sure "autoindex on;" is not set for the site (it is off by default).', 'all-in-one-wp-content-security'), __('Run the check again.', 'all-in-one-wp-content-security'), ), 'docs' => array(self::doc(__('Apache: Options directive', 'all-in-one-wp-content-security'), 'https://httpd.apache.org/docs/2.4/mod/core.html#options')), 'permission' => __('Web server configuration or .htaccess access', 'all-in-one-wp-content-security'), ), ); } /** * Files that are checked when they exist on disk: path => array(rule severity, label, signature) */ private function sensitive_candidates() { $candidates = array(); $log = WP_CONTENT_DIR . '/debug.log'; if (defined('WP_DEBUG_LOG') && is_string(WP_DEBUG_LOG) && WP_DEBUG_LOG !== '') { $log = WP_DEBUG_LOG; } $candidates[$log] = array('high', __('WordPress debug log', 'all-in-one-wp-content-security'), ''); $candidates[ABSPATH . 'error_log'] = array('high', __('PHP error log', 'all-in-one-wp-content-security'), ''); $candidates[ABSPATH . 'wp-admin/error_log'] = array('high', __('PHP error log', 'all-in-one-wp-content-security'), ''); $candidates[ABSPATH . '.env'] = array('critical', __('Environment file (often contains credentials)', 'all-in-one-wp-content-security'), ''); $candidates[ABSPATH . '.git/HEAD'] = array('high', __('Git repository metadata (source code and history)', 'all-in-one-wp-content-security'), 'ref:'); $candidates[ABSPATH . '.git/config'] = array('high', __('Git repository configuration', 'all-in-one-wp-content-security'), '[core]'); $candidates[ABSPATH . '.svn/wc.db'] = array('high', __('Subversion working copy database', 'all-in-one-wp-content-security'), 'SQLite'); $candidates[ABSPATH . '.DS_Store'] = array('low', __('macOS folder metadata (lists file names)', 'all-in-one-wp-content-security'), ''); foreach (array('wp-config.php.bak', 'wp-config.php.old', 'wp-config.php.orig', 'wp-config.php.save', 'wp-config.php.swp', 'wp-config.php~', 'wp-config.bak', 'wp-config.old', 'wp-config.txt', '.wp-config.php.swp', 'wp-config.php.txt', 'wp-config.php.dist') as $name) { $candidates[ABSPATH . $name] = array('critical', __('Copy of wp-config.php (database password and keys)', 'all-in-one-wp-content-security'), ''); } return $candidates; } public function run_batch($context, $cursor) { if (!is_array($cursor)) { $targets = array(array('type' => 'home'), array('type' => 'rest_users')); if (file_exists(ABSPATH . 'readme.html')) { $targets[] = array('type' => 'readme'); } foreach ($this->sensitive_candidates() as $path => $info) { if (@is_file($path)) { $targets[] = array('type' => 'sensitive', 'path' => $path, 'severity' => $info[0], 'label' => $info[1], 'signature' => $info[2]); } } $uploads = AOWPCS_Environment::uploads_dir(); $targets[] = array('type' => 'listing', 'url' => trailingslashit($uploads['url'])); $targets[] = array('type' => 'listing', 'url' => site_url(WPINC . '/')); $cursor = array('targets' => $targets, 'index' => 0, 'listing_ok' => 0, 'sensitive_unknown' => 0); } $findings = array(); while ($cursor['index'] < count($cursor['targets'])) { if ($cursor['index'] > 0 && $context->out_of_time()) { return array($findings, $cursor); } $target = $cursor['targets'][$cursor['index']++]; $method = 'target_' . $target['type']; foreach ((array) $this->$method($target, $cursor) as $finding) { $findings[] = $finding; } } if ($cursor['sensitive_unknown'] > 0) { $findings[] = $this->unknown('server.sensitive_file_public', __('Some sensitive files exist but could not be requested to confirm whether they are public.', 'all-in-one-wp-content-security')); } return array($findings, null); } private function target_home($target, &$cursor) { $response = AOWPCS_Loopback::request(home_url('/')); if ($response['error'] !== '' || $response['status'] >= 400) { return array($this->unknown('core.version_disclosure', __('The home page could not be loaded.', 'all-in-one-wp-content-security'))); } if (preg_match('/]+name=["\']generator["\'][^>]+content=["\']WordPress\s*([0-9.]+)/i', $response['body'], $m)) { /* translators: %s: m 1 */ return array($this->issue('core.version_disclosure', 'low', 'generator', sprintf(__('The home page contains .', 'all-in-one-wp-content-security'), $m[1]), array( 'detected' => 'WordPress ' . $m[1], 'expected' => __('No generator tag', 'all-in-one-wp-content-security'), ))); } return array($this->pass('core.version_disclosure', __('The home page does not contain a WordPress generator tag.', 'all-in-one-wp-content-security'))); } private function target_readme($target, &$cursor) { $public = AOWPCS_Loopback::is_publicly_served(site_url('readme.html'), 'WordPress'); if ($public === null) { return array($this->unknown('core.readme_disclosure', __('readme.html could not be requested.', 'all-in-one-wp-content-security'))); } if ($public) { return array($this->issue('core.readme_disclosure', 'low', 'readme.html', __('readme.html is served to anonymous visitors.', 'all-in-one-wp-content-security'), array('evidence' => array('URL' => site_url('readme.html'))))); } return array(); } private function target_rest_users($target, &$cursor) { $evidence = array(); $response = AOWPCS_Loopback::request(rest_url('wp/v2/users'), array('cache' => false)); if ($response['error'] === '' && $response['status'] === 200) { $users = json_decode($response['body'], true); if (is_array($users) && !empty($users) && isset($users[0]['slug'])) { /* translators: Placeholder is a number or value shown in the message */ $evidence[__('REST API user list', 'all-in-one-wp-content-security')] = sprintf(_n('%d user name returned by /wp-json/wp/v2/users', '%d user names returned by /wp-json/wp/v2/users', count($users), 'all-in-one-wp-content-security'), count($users)); } } $author = AOWPCS_Loopback::request(add_query_arg('author', 1, home_url('/')), array('cache' => false)); if ($author['error'] === '' && in_array($author['status'], array(301, 302), true) && isset($author['headers']['location']) && strpos($author['headers']['location'], '/author/') !== false) { $evidence[__('Author enumeration', 'all-in-one-wp-content-security')] = __('?author=1 redirects to an author archive URL containing the user name', 'all-in-one-wp-content-security'); } if ($response['error'] !== '' && $author['error'] !== '') { return array($this->unknown('core.rest_user_enumeration', __('The REST API could not be requested.', 'all-in-one-wp-content-security'))); } if ($evidence) { return array($this->issue('core.rest_user_enumeration', 'low', 'users', __('User names can be listed by anonymous visitors.', 'all-in-one-wp-content-security'), array('evidence' => $evidence))); } return array($this->pass('core.rest_user_enumeration', __('User names are not listed to anonymous visitors.', 'all-in-one-wp-content-security'))); } private function target_sensitive($target, &$cursor) { $url = AOWPCS_Environment::path_to_url($target['path']); if ($url === '') { return array(); } $public = AOWPCS_Loopback::is_publicly_served($url, $target['signature']); $relative = AOWPCS_Plugin::relative_path($target['path']); if ($public === null) { $cursor['sensitive_unknown']++; return array(); } if (!$public) { return array(); } /* translators: 1: relative, 2: target label */ return array($this->issue('server.sensitive_file_public', $target['severity'], $relative, sprintf(__('%1$s (%2$s) can be downloaded by anyone.', 'all-in-one-wp-content-security'), $relative, $target['label']), array( 'confidence' => 'confirmed', 'kind' => 'vulnerability', /* translators: %s: url */ 'detected' => sprintf(__('HTTP 2xx for %s', 'all-in-one-wp-content-security'), $url), 'expected' => __('HTTP 403 or 404', 'all-in-one-wp-content-security'), 'evidence' => array_merge(array('URL' => $url, __('File type', 'all-in-one-wp-content-security') => $target['label']), AOWPCS_Check_Core_Checksums::file_evidence($target['path'])), ))); } private function target_listing($target, &$cursor) { $response = AOWPCS_Loopback::request($target['url'], array('cache' => false)); if ($response['error'] !== '') { return array($this->unknown('server.directory_listing', __('The directory could not be requested.', 'all-in-one-wp-content-security'))); } if ($response['status'] === 200 && preg_match('/