Changeset 3466602
- Timestamp:
- 02/21/2026 09:26:38 PM (11 days ago)
- Location:
- security-hardener
- Files:
-
- 4 added
- 3 deleted
- 2 edited
-
tags/0.3 (deleted)
-
tags/0.5 (deleted)
-
tags/0.6 (deleted)
-
tags/0.7 (added)
-
tags/0.7/readme.txt (added)
-
tags/0.7/security-hardener.php (added)
-
tags/0.7/uninstall.php (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/security-hardener.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
security-hardener/trunk/readme.txt
r3466579 r3466602 5 5 Tested up to: 6.9 6 6 Requires PHP: 8.0 7 Stable tag: 0. 67 Stable tag: 0. 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Basic hardening: secure headers, user enumeration blocking, generic login errors, IP-based rate limiting, and comprehensiveWordPress security improvements.11 Basic hardening: secure headers, user enumeration blocking, generic login errors, IP-based rate limiting, and WordPress security improvements. 12 12 13 13 == Description == … … 161 161 == Changelog == 162 162 163 = 0.6 - 2026-21-02 = 163 = 0.7 - 2026-02-21 = 164 * Fixed: WPSH_VERSION constant updated to match plugin header version 165 * Fixed: Added wp_unslash() and sanitize_text_field() to $_GET['author'] in prevent_author_redirect() 166 * Fixed: Moved HTML markup outside translatable strings in generic_login_errors(), check_login_rate_limit(), and field descriptions for "Disable all file modifications" and "Enable HSTS" 167 * Security: Added CSRF protection to "Clear Logs" action via wp_nonce_url() and wp_verify_nonce() 168 * Improved: Added missing hardening recommendations to admin page: BasicAuth protection for wp-admin and changing the default database table prefix 169 * Fixed: Corrected date format in changelog entries (YYYY-MM-DD) 170 171 = 0.6 - 2026-02-21 = 164 172 * Fixed: Removed deprecated load_plugin_textdomain() call (automatic since WordPress 4.6) 165 173 * Fixed: Added wp_unslash() and sanitize_text_field() to $_GET['author'] before sanitization … … 171 179 * Fixed: Removed redundant function_exists() check for wp_cache_flush() in uninstall.php 172 180 173 = 0.5 - 2026-0 9-02=181 = 0.5 - 2026-0 = 174 182 * Complete rewrite following WordPress hardening best practices 175 183 * Increased minimum PHP requirement to 8.0 (PHP 7.4 is end-of-life) -
security-hardener/trunk/security-hardener.php
r3466579 r3466602 4 4 Plugin URI: https://wordpress.org/plugins/security-hardener/ 5 5 Description: Basic hardening: secure headers, disable XML-RPC/pingbacks, hide version, block user enumeration, login errors, IP-based rate limiting, and optional restriction of the REST API. 6 Version: 0. 66 Version: 0. 7 7 Requires at least: 6.0 8 8 Tested up to: 6.9 … … 20 20 21 21 // Plugin constants 22 define( 'WPSH_VERSION', '0. 5' );22 define( 'WPSH_VERSION', '0.' ); 23 23 define( 'WPSH_FILE', __FILE__ ); 24 24 define( 'WPSH_DIR', plugin_dir_path( __FILE__ ) ); … … 352 352 public function prevent_author_redirect( $redirect_url, $requested_url ) { 353 353 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only check 354 if ( isset( $_GET['author'] ) && is_numeric( $_GET['author'] ) ) { 354 $author = isset( $_GET['author'] ) ? sanitize_text_field( wp_unslash( $_GET['author'] ) ) : null; 355 if ( null !== $author && is_numeric( $author ) ) { 355 356 return false; // Cancel redirect 356 357 } … … 414 415 415 416 // Return generic error message 416 return __( '<strong>Error:</strong>Invalid username or password.', 'security-hardener' );417 return Invalid username or password.', 'security-hardener' ); 417 418 } 418 419 … … 456 457 return new WP_Error( 457 458 'too_many_attempts', 458 sprintf(459 sprintf( 459 460 /* translators: %d: number of minutes */ 460 __( '<strong>Error:</strong>Too many failed login attempts. Please try again in %d minutes.', 'security-hardener' ),461 Too many failed login attempts. Please try again in %d minutes.', 'security-hardener' ), 461 462 $minutes 462 463 ) … … 691 692 692 693 $this->add_checkbox_field( 'disable_file_edit', __( 'Disable file editor', 'security-hardener' ), 'wpsh_file_editing', __( 'Prevents editing of theme and plugin files through WordPress admin.', 'security-hardener' ) ); 693 $this->add_checkbox_field( 'disable_file_mods', __( 'Disable all file modifications', 'security-hardener' ), 'wpsh_file_editing', __( '<strong>Warning:</strong>This will disable plugin/theme updates and installations.', 'security-hardener' ) );694 $this->add_checkbox_field( 'disable_file_mods', __( 'Disable all file modifications', 'security-hardener' ), 'wpsh_file_editing', This will disable plugin/theme updates and installations.', 'security-hardener' ) ); 694 695 695 696 // XML-RPC section … … 789 790 ); 790 791 791 $this->add_checkbox_field( 'enable_hsts', __( 'Enable HSTS', 'security-hardener' ), 'wpsh_hsts', __( '<strong>Warning:</strong>Only enable if your site fully supports HTTPS.', 'security-hardener' ) );792 $this->add_checkbox_field( 'enable_hsts', __( 'Enable HSTS', 'security-hardener' ), 'wpsh_hsts', Only enable if your site fully supports HTTPS.', 'security-hardener' ) ); 792 793 $this->add_checkbox_field( 'hsts_subdomains', __( 'Include subdomains', 'security-hardener' ), 'wpsh_hsts' ); 793 794 $this->add_checkbox_field( 'hsts_preload', __( 'Enable preload', 'security-hardener' ), 'wpsh_hsts', __( 'Submit to <a href="https://hstspreload.org/" target="_blank">HSTS Preload List</a> (requires 1 year max-age).', 'security-hardener' ) ); … … 965 966 <li><?php esc_html_e( 'Restrict file permissions (directories: 755, files: 644)', 'security-hardener' ); ?></li> 966 967 <li><?php esc_html_e( 'Consider using a Web Application Firewall (WAF)', 'security-hardener' ); ?></li> 968 969 967 970 </ul> 968 971 … … 1025 1028 </table> 1026 1029 <p> 1027 <a href="<?php echo esc_url( admin_url( 'options-general.php?page=security-hardener&action=clear_logs' ) ); ?>"1030 <a href="<?php echo esc_url( clear_logs' ) ); ?>" 1028 1031 class="button" 1029 1032 onclick="return confirm('<?php esc_attr_e( 'Are you sure you want to clear all security logs?', 'security-hardener' ); ?>');"> … … 1038 1041 */ 1039 1042 public function show_admin_notices() { 1040 // Clear logs action 1043 // Clear logs action 1041 1044 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 1042 1045 if ( isset( $_GET['action'] ) && 'clear_logs' === $_GET['action'] && current_user_can( 'manage_options' ) ) { 1043 // Verify nonce would be better, but this is acceptable for read-only admin pages 1046 if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'wpsh_clear_logs' ) ) { 1047 wp_die( esc_html__( 'Security check failed.', 'security-hardener' ) ); 1048 } 1044 1049 delete_option( 'wpsh_security_logs' ); 1045 1050 ?>
Note: See TracChangeset
for help on using the changeset viewer.