Back to Engineering Blog
Systems Design 3 min read

Security Headers on a Public Edge, and the CSP Trade-Off We Kept

A header check on our own public site showed no CSP, HSTS, frame, nosniff, referrer or permissions policies. We added one reviewed block in the edge proxy, with analytics origins allowed, and recorded the unsafe-inline trade-off we are still carrying.

Jason NevillBy , Houston, TX
#Caddy#CSP#HSTS#Web Security

Key Architectural Takeaways

  • Check your own response headers with curl -I; the framework set none and the edge config had no header block.
  • Apply proxy config with a timestamped backup, a validate step, a reload and a documented rollback.
  • Name the compromise: a script-src with unsafe-inline and unsafe-eval is a known gap, and nonces are the later hardening step.

The finding

curl -I https://htx-tek.com/ returned no Content-Security-Policy, no HSTS, no X-Frame-Options, no nosniff, no Referrer-Policy and no Permissions-Policy. The Next.js application sets none of them. The production edge's Caddyfile, which we confirmed was identical to the live one, had no header block either. Only the internal test build's template carried a header policy.

The change

A security_headers snippet imported into the public site's block, using the same policy as the internal build. It includes the Google Tag Manager and Analytics origins in script-src, connect-src, img-src and frame-src, so the analytics we rely on are not blocked by our own policy. caddy validate passed.

How it is applied

The edge is not Ansible-managed, so the rollout is a short, careful, manual procedure:

  1. Copy the live Caddyfile to a timestamped .bak.
  2. Install the new file.
  3. caddy validate, then systemctl reload caddy.
  4. Verify with curl -I, then load the site in a browser with the console open and confirm GA4's Realtime view still counts the visit.
  5. Rollback: restore the .bak and reload.

The browser check matters. A CSP that blocks a script fails silently for your visitors, and only the console and your analytics will tell you.

The trade-off we kept

script-src still allows 'unsafe-inline' and 'unsafe-eval', because the Next.js inline bootstrap and Tag Manager need them. A nonce-based CSP is the later hardening step. We wrote the compromise down in the pull request instead of presenting the policy as stronger than it is.

Takeaway

Headers are cheap to add and easy to forget when the framework does not set them. Add them, verify them from the outside, and be explicit about the parts of the policy that are still loose.

Follow the build on LinkedIn or by RSS.

All Articles

Follow the build

Questions about the build, or spotted something we got wrong? Find us on LinkedIn and GitHub.