// hosting explained

Egress firewalls, environment variables and read-only files: WordPress hardening, explained

Most WordPress security advice is about keeping attackers out. These three settings limit what an attacker can do if they get in.

KEY TAKEAWAYS

  • Egress firewall: controls which outside servers your site can connect to, so malware can't easily phone home.
  • Environment variables: keep API keys out of files a hacked plugin could read.
  • Read-only filesystem: stops PHP writing files while you clean up a hacked site.

Egress firewall

Normal firewalls filter incoming traffic. An egress firewall filters outgoing connections: you allow a destination IP, port and protocol your site legitimately needs, such as an external database on port 3306.

Pressable egress firewall rule form with destination IP, port and protocol
Creating an egress rule on Pressable.

Environment variables for secrets

Put keys like STRIPE_SECRET_KEY in encrypted environment variables instead of wp-config.php. On Pressable they're encrypted at rest, hidden once saved and read in PHP with a helper class.

Pressable environment variables keep API keys out of wp-config.php, encrypted at rest
Adding an environment variable on Pressable.

Read-only filesystem

PHP normally writes files when you update plugins or upload images. Switching to read-only stops that, which is ideal while removing malware. Pressable's "read only unless logged in" mode still lets you update from wp-admin. Switch it back after cleanup.

Pressable PHP filesystem permission switch between read/write and read-only
PHP filesystem permission on Pressable.

Keep reading

WRITTEN BY

Fathi Arfaoui

Fathi Arfaoui has helped people choose web hosting, start blogs and build WordPress sites since 2013. He founded SiteHostingFinder to replace opinion-based hosting reviews with real prices and public data. He has been a HostGator customer since 2013 and has hosted 40-50 WordPress sites on Pressable since 2017.