WordPress

WordPress Security Checklist 2024 – Bảo Vệ Website Toàn Diện

WordPress Security Checklist 2024 – Bảo Vệ Website Toàn Diện

WordPress chiếm 43% website toàn cầu, nên cũng là mục tiêu tấn công hàng đầu. Đây là checklist bảo mật tôi áp dụng cho mọi dự án WordPress.

1. Đổi Tiền Tố Database

// wp-config.php - thay đổi trước khi cài WP
$table_prefix = 'mysite_'; // Thay vì 'wp_'

2. Ẩn Phiên Bản WordPress

// functions.php
remove_action('wp_head', 'wp_generator');
add_filter('the_generator', '__return_empty_string');

3. Giới Hạn Login Attempts

Dùng plugin như Limit Login Attempts Reloaded hoặc tự viết bằng hook:

add_filter('authenticate', function($user, $username, $password) {
    $failed_attempts = (int) get_transient('failed_login_' . $username);
    
    if ($failed_attempts >= 5) {
        return new WP_Error('too_many_attempts', 
            'Tài khoản bị khóa. Thử lại sau 30 phút.');
    }
    
    return $user;
}, 30, 3);

add_action('wp_login_failed', function($username) {
    $attempts = (int) get_transient('failed_login_' . $username);
    set_transient('failed_login_' . $username, $attempts + 1, 30 * MINUTE_IN_SECONDS);
});

4. Bảo Vệ wp-config.php

# .htaccess
<Files wp-config.php>
    Order allow,deny
    Deny from all
</Files>

# Chặn XML-RPC nếu không dùng
<Files xmlrpc.php>
    Order allow,deny
    Deny from all
</Files>

5. Checklist Nhanh

  • ✅ Cập nhật WordPress core, theme, plugin thường xuyên
  • ✅ Dùng mật khẩu mạnh + 2FA cho admin
  • ✅ Backup tự động hàng ngày
  • ✅ SSL/HTTPS bắt buộc
  • ✅ Xóa theme/plugin không dùng
  • ✅ Kiểm tra file permissions (755 cho thư mục, 644 cho file)

Bài viết liên quan