Back to Blog
Homelab 3 min read

Cloudflare Hardening, Turnstile Bot Protection, and a Next.js 15 Upgrade

Locking down parked domains with SPF hard-fail and DMARC reject, wiring Cloudflare Bot Fight Mode and AI Labyrinth, adding Turnstile to the contact form, scrubbing internal network details from public pages, and upgrading to Next.js 15.

Threat modeling doesn't stop at the edge of your primary domain. If you own the .net, .cc, and .org variants of your brand and they sit unguarded, they're vectors for spoofed email and lookalike phishing. This sprint locked all three down and hardened the whole perimeter.

DNS Email Guard: Locking Down Parked Domains#

Three parked domains — the .net, .cc, and .org variants — each got a hardened DNS record set via Cloudflare. SPF is set to v=spf1 -all, the strictest possible: it explicitly asserts that no mail servers are authorized to send from these domains. Any server that attempts delivery fails authentication immediately.

DMARC policy is p=reject with 100% sampling. If a mail server somehow bypasses SPF and delivers, DMARC instructs receiving servers to reject the message outright — not quarantine, reject. Reports flow back to the primary domain address so any spoofing attempts surface in telemetry.

Each parked domain also has a redirect forwarding all web traffic to shaferware.com. The combination means these domains can't be weaponized for phishing and don't leave visitors stranded on a blank page.

Cloudflare Perimeter Hardening#

Three features were enabled on the primary domain's Cloudflare zone.

Bot Fight Mode classifies and challenges known bot traffic before it reaches the origin server. Cloudflare's bot intelligence fingerprints automated clients and issues browser challenges, reducing scraping and credential-stuffing attempts without touching legitimate users.

AI Labyrinth is Cloudflare's countermeasure for AI crawlers. Instead of blocking them outright (which triggers retries from different IPs), it feeds crawlers a maze of plausible but endless AI-generated pages. Crawlers burn compute cycles going nowhere. The origin server sees none of it.

Security.txt was configured through the Cloudflare dashboard — a standardized disclosure file at /.well-known/security.txt that tells researchers where to send vulnerability reports.

Turnstile on the Contact Form#

The contact form at /services is the only user-facing input surface on the site. Without protection, a motivated attacker could hammer the endpoint directly, filling the Supabase contacts table and burning Resend quota with no friction.

Cloudflare Turnstile is the privacy-respecting alternative to reCAPTCHA. It doesn't fingerprint users or force them to identify traffic lights — it silently validates browser behavior and issues a cryptographic token.

The implementation is two-layer. On the client, @marsidev/react-turnstile renders the widget inside the ContactForm component and captures the token on success. On the server, the /api/contact route validates the token against Cloudflare's siteverify endpoint before the submission ever touches Supabase or Resend. No valid Turnstile token, no database insert.

Scrubbing Internal Details from Public Pages#

The /status and /lab pages were exposing internal hostnames and VLAN structure in page source. For a zero-trust network, that's an information disclosure — it hands an attacker the segmentation topology to probe.

All internal network details were stripped from the public-facing render paths. The public /status page now shows service names and uptime states only. The /lab page covers topology and tool descriptions without any addresses. Admin-only views retain full detail and are accessible only from trusted VLANs via the middleware IP guard.

Next.js 14 → 15 Upgrade#

Next.js 15 introduces a breaking change in the App Router: dynamic route params is now a Promise rather than a plain object. Any page or generateMetadata function that destructures params synchronously throws at build time.

The blog post route was the affected file. Both generateMetadata and the default page export now await params before destructuring the slug. The package was bumped to ^15.5.18 and tsconfig.json gained the "target": "ES2017" compiler option that Next.js 15 sets by default. The upgrade went clean — no other pages use dynamic params.