This is how I’m closing the update-window hole on self-hosted WordPress. Keep it generic and adapt it to your stack.
- Nginx: in the server block, add
location ^~ /wp-content/upgrade/ { deny all; }, then runnginx -tand reload. - Apache: add a
<Directory>block for that path withRequire all denied, or putRedirectMatch 403 ^/wp-content/upgrade/above the rewrite rules in the root .htaccess. - Test:
curl -I https://your-site/wp-content/upgrade/should come back 403. - Update:
wp core update, thenwp core versionandwp core verify-checksums. - Look around: check for unexpected admins (
wp user list --role=administrator) and for a changed wp-config.php. - Automate it: if you manage servers with Ansible, put the deny rule in your web role so every site gets it.
WordPress works with that folder directly on disk, so blocking web access doesn’t break updates.
God Bless, and Use the Source!