Security guides
-
Security guide
A backup you have not restored is a hope
Back up the database consistently, encrypt and store copies off the server, and prove the backup works by restoring it on a schedule.
-
Security guide
Bind databases, queues and admin panels to localhost
A database that listens on 0.0.0.0 is an internet service. Bind it to 127.0.0.1, publish Docker ports on loopback, and reach admin panels through an SSH tunnel.
-
Security guide
Block server-side requests to the cloud metadata address
A URL fetch feature can be pointed at 169.254.169.254 and read cloud credentials. Validate destinations after DNS resolution, require IMDSv2, and block the address for the app user.
-
Security guide
Commit the lockfile and install exactly what it says
Lockfiles pin every dependency to a reviewed version. Commit them, install with the lockfile-only commands in CI and deploys, and audit them on every build.
-
Security guide
Do not mount the Docker socket into an app container
Write access to /var/run/docker.sock is root on the host. Find containers that mount it, and give tools that need it a filtering proxy instead.
-
Security guide
Isolate each site with its own user and PHP-FPM pool
One Linux user and one PHP-FPM pool per site keep a compromise of one site from reading or writing the others. open_basedir is a seatbelt on top, not the boundary.
-
Security guide
Keep .env and .git out of the web root
Point the vhost at public/, deny dotfiles except .well-known, and confirm /.env and /.git/config answer 403 or 404 from outside.
-
Security guide
Keep secrets out of ps, core dumps and swap
Command-line arguments are visible to every user, crashing processes write memory to disk, and swap can hold secrets after a process exits. Close each of those paths.
-
Security guide
Keep the server clock in sync
TLS, signed requests, TOTP codes and log timelines all depend on an accurate clock. Run one time-sync service and check that it is synchronised.
-
Security guide
Lock the origin to Cloudflare, after the tunnel or proxy works
A Cloudflare-proxied site whose server still answers on its public IP can be attacked directly. Use a Cloudflare Tunnel or allow only Cloudflare IP ranges, in an order that does not take the site down.
-
Security guide
One database user per application, with only the rights it needs
Apps should not connect as root or postgres. Create one user per app, grant it one database, and keep migration rights separate where you can.
-
Security guide
Publish a security.txt so researchers can reach you
A security.txt file at /.well-known/security.txt tells people who find a vulnerability where to report it. It takes five minutes and needs an Expires date.
-
Security guide
Put a local proxy and a daily cap in front of OpenAI and Anthropic
Point SDKs at the PortGate AI proxy on 127.0.0.1:8787 so known injections are blocked, secrets are redacted, and a daily request and token cap stops runaway spend.
-
Security guide
Session cookies: flags, CSRF tokens, and why CORS is not authentication
Set Secure, HttpOnly and SameSite on session cookies, keep CSRF protection on every state-changing request, and do not treat CORS as an access control.
-
Security guide
SPF, DKIM and DMARC for mail your server sends
Without SPF, DKIM and DMARC, your password resets land in spam and anyone can send mail as your domain. Set all three, starting DMARC at p=none.
-
Security guide
Stop PHP from running inside WordPress uploads
Uploads should hold images and documents, never code. Deny PHP execution there in nginx or Apache, block xmlrpc.php if unused, and turn off the dashboard file editor.
-
Security guide
Turn off debug pages and version banners in production
Debug mode turns an error into a map of your app, and some debug tools run code. Turn them off, stop advertising versions, and check from outside.
-
Security guide
Turn off SSH passwords without locking yourself out
Install and test a key, write a drop-in that sshd reads first, check the effective config with sshd -T, and keep a second session and the firewall rule in place until it works.