brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: DISALLOW_FILE_MODS locks plugin and theme changes, not just the editor

Security
~/tips/tip-wordpress-disallow-file-mods

define( 'DISALLOW_FILE_MODS', true );

Stops anyone from installing or updating plugins and themes in the admin, so a stolen login can do less.

Most hardening guides tell you to set DISALLOW_FILE_EDIT. There is a bigger switch next to it.

DISALLOW_FILE_EDIT removes the plugin and theme code editor from the admin. Good, because an attacker with a stolen admin login would otherwise get to write PHP straight from the dashboard. DISALLOW_FILE_MODS goes further. It also blocks installing and updating plugins and themes from the admin, and it includes the editor block, so you do not need both.

define( 'DISALLOW_FILE_MODS', true );

With that line a compromised admin account cannot upload a malicious plugin. Updates then happen outside WordPress: with WP-CLI, Composer or a deployment from Git. For a site that I manage myself over SSH, I think that is the better setup.

The caveat bites. The Updates screen stops working, so nothing updates itself from the dashboard any more. If nobody runs wp plugin update --all on a schedule, you swapped one risk for a worse one: old plugins. Only use this when you have a real update routine. If you do not, DISALLOW_FILE_EDIT alone is the safer choice.

Further reading: Editing wp-config.php (WordPress developer docs), On this site: wp config shuffle-salts logs everybody out after a break-in, On this site: set WP_ENVIRONMENT_TYPE so plugins know a site is staging

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link