Misconfiguration
🏠The everyday picture
A strong lock on a door left open. Most break-ins at well-built buildings come through something left unlocked, not through breaking the lock.
📘What it really is
Common misconfigurations, and the fix:
-
Verbose errors: stack traces and SQL shown to users reveal internals. Show a generic message with a reference ID; log the details (Module 72). Set
NODE_ENV=production. -
Missing security headers. Add (in Nginx, or with Express's
helmet): Strict-Transport-Security(HTTPS only, Module 66);Content-Security-Policy(Lesson 3);X-Content-Type-Options: nosniff;Referrer-Policy: strict-origin-when-cross-origin;-
frame-ancestors 'none'in the CSP (orX-Frame-Options: DENY) to stop your pages being framed (clickjacking). -
Exposed files:
.env,.gitfolders, backups (db.sql), source maps in public folders. Check none are reachable. - Default or shared credentials on databases, admin panels, routers.
- Open storage and databases: public buckets, databases reachable from the internet (Modules 66, 68).
- Directory listing turned on, debug endpoints and test pages left in production.
- Too-wide CORS (Lesson 4).
-
File uploads: check type and size, store outside the web root or in object storage with random names, never run uploaded files, and serve them with
Content-Disposition: attachmentwhere possible (Module 45). -
Check regularly: Mozilla's HTTP Observatory and securityheaders.com scan headers (on your own sites); OWASP ZAP's baseline scan finds many misconfigurations (Module 78).
🖱️Try it
On your own staging site: run an HTTP Observatory scan and fix the headers it reports. Try to fetch /.env, /.git/config
and /backup.sql; all must be refused or not found. Trigger an error and check users see only a generic message. Fix what
you find and rescan.
✅Quick check
Why shouldn't error pages show stack traces?
Show the answer
They reveal internal details that help attackers; log them instead.
Name two security headers and what they do.
Show the answer
Any two: HSTS (HTTPS only), CSP (allowed scripts), nosniff (no type guessing), Referrer-Policy (limits leaked URLs), frame-ancestors or X-Frame-Options (stops clickjacking).
