---
title: "Are you sure your website is safe?"
slug: "are-you-sure-your-website-is-safe"
publishedAt: "2026-10-25T12:39:27.256Z"
dateModified: "2026-10-25T12:39:27.256Z"
canonical: "https://www.notesof.dev/are-you-sure-your-website-is-safe"
author: "Hieu (Chris) Pham"
tags: ["Email Security", "Headless CMS", "Next.js", "Security"]
excerpt: "The four layers a headless CMS site has to check, why green scanners are not proof, and the DNS records that stop strangers emailing as you."
---

# Are you sure your website is safe?

>*Part 1 of 4 in the "Are you sure your website is safe?" series*

**TL;DR:** A headless CMS site can pass every scanner while it leaks drafts and lets strangers send email in its name. **Safety spans four layers: the code you ship, what search engines index, what AI systems read, and what your domain lets others claim.** For a domain that sends and receives no email, the quickest fix is **three DNS records that block forged mail.**

## A green dashboard is not a safe website

You run a blog, an online store or a company site. The content lives in a headless CMS such as Storyblok, Contentful or Sanity, and Next.js renders it. Pages load fast, the build pipeline passes, and every security tool in the repository reports zero problems.

> **Headless CMS** — a content management system that stores your content and serves it as data, leaving the website itself to your own code.

Take a small Next.js site on a headless CMS. Lighthouse scored it 92 to 100 for performance and 100 in its other three categories. SonarCloud reported security rating A, 0 vulnerabilities and 97.9% test coverage. CodeQL found nothing. GitHub secret scanning and push protection were on, and `pnpm audit` ran on every build. At the same time:

- the public JavaScript carried a CMS token that could read unpublished drafts;
- a block on `/global` checked the raw path, so `/%67lobal/header` (`%67` is an encoded g) got past it and showed the shared site header as a public page;
- the publish webhook compared its secret with `!==`, which is not a constant-time check, although a code comment said it was;
- the Dependabot auto-merge rule trusted `github.actor`, which can be Dependabot even when Dependabot only updated someone else's pull request;
- anyone could send email that claimed to come from the domain.

> **Webhook** — a web address your CMS calls when you publish, so the site can refresh its pages.

**Every dashboard was green, and the site still had five open problems.** They sit in four layers, and each layer fails on its own:

1. **What your code ships** — the JavaScript, tokens and routes a browser can reach.
2. **What search engines index** — spam pages, previews and duplicates in results.
3. **What AI systems read and do** — crawlers, AI search and agents.
4. **What your domain lets others claim** — the email and DNS (Domain Name System) records that decide who speaks for you.

## Why security scanners miss live problems

Each security tool checks one surface, and a pass covers that surface only. A yearly car inspection works the same way. The inspector checks the brakes, lights and tyres, and the car passes. The inspection says nothing about who holds a spare key, or whether someone has copied your number plate.

Here is what each tool reads:

- **Lighthouse** — scores how a page loads for a visitor.
- **SonarCloud** — reads source code without running it. Its secret detection skips Markdown files, test folders and `.env.dev*` files by design ([per Sonar's secrets docs](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/languages/secrets)).
- **CodeQL** — matches known dangerous patterns in source. The Open Worldwide Application Security Project (OWASP) notes that such tools are "frequently unable to find configuration issues" ([OWASP on source code analysis tools](https://owasp.org/www-community/Source_Code_Analysis_Tools)).
- **GitHub secret scanning and push protection** — secret scanning reads your git history ([GitHub's secret scanning docs](https://docs.github.com/en/code-security/concepts/secret-security/secret-scanning)), and push protection blocks secrets before they reach the repository ([GitHub's push protection docs](https://docs.github.com/en/code-security/concepts/secret-security/push-protection)).
- **`pnpm audit`** — compares your dependencies with published security advisories.

The leaked token never entered git. Next.js inlines any `NEXT_PUBLIC_` variable that client code uses "at build time, into the js bundle that is delivered to the client" ([per the Next.js docs](https://nextjs.org/docs/app/guides/environment-variables)). The value lived in an environment variable, so secret scanning had nothing to find.

Whether a token reads drafts is a fact about the CMS, and no source rule can see it. The scanners read the webhook code and the auto-merge rule, but none of their rules checks what that code allows. DNS records are not in the repository at all.

This gap is common. Intruder scanned about 5 million applications and found over 42,000 exposed tokens in JavaScript bundles ([Intruder's research](https://www.intruder.io/research/secrets-detection-javascript)). Its report notes that secrets "can be exposed via build processes that happen long after the classic shift-left failsafes have run".

> **Shift-left** — running security checks early in development, on each commit and build, to catch problems "as early and as cheaply as possible".

A fair objection is that this makes the scanners look useless. There is truth in it, since they missed all five problems. But they block whole classes of mistakes on every push at almost no cost, so keep them.

OWASP describes the goal as "shift-left (and increasingly shift-everywhere)" ([OWASP DevSecOps Guideline](https://owasp.org/www-project-devsecops-guideline/)). In practice, add a regular check of the deployed site: download its JavaScript, request odd URLs, read its DNS records. A security review of the running system, plus those live checks, found all five problems.

If an AI assistant writes much of your code, the outside check matters even more, as [AI-generated code ships hidden vulnerabilities](/ai-generated-code-ships-hidden-vulnerabilities) explains.

![At dusk, the squirrel shines a flashlight on the latch of the shop's back window.](https://a.storyblok.com/f/288495199849781/1536x1024/4601eef562/check-the-live-site-not-the-repo.webp)

## Layer 1: secrets your frontend ships to browsers

Anything a browser downloads is public. The example site set up its client-side CMS SDK (software development kit) with a preview token from a `NEXT_PUBLIC_` variable. Storyblok's preview token reads "`draft` and `published` content", while its public token reads published content only ([Storyblok's token docs](https://www.storyblok.com/docs/concepts/access-tokens)).

Anyone who called the CMS with that token and `version=draft` got the drafts back. No unreleased story had leaked yet, but every future draft would have. The browser never called the CMS itself. The token had no reason to be there.

If you built your site from a guide like [How to set up Storyblok with Next.js](/storyblok-and-next-js-the-complete-setup-in-2026), check which token your client code reads.

![A rabbit customer admires a finished landscape print at the counter while the squirrel closes the door to a back room full of unfinished sketches.](https://a.storyblok.com/f/288495199849781/1536x1024/22e81cb2eb/published-prints-private-drafts.webp)

## Layer 2: pages search engines should never index

Blocking a path in robots.txt does not keep it private. Google says robots.txt "is not a mechanism for keeping a web page out of Google" ([Google's robots.txt guide](https://developers.google.com/search/docs/crawling-indexing/robots/intro)).

A hacked site can hide spam from its owner. The Japanese keyword hack creates spam pages and cloaks them, so the owner sees a 404 error while Googlebot sees spam ([Google's guide to the hack](https://web.dev/articles/fix-the-japanese-keyword-hack)). A headless site has no WordPress-style plugins, yet a stolen CMS management token or editor login can publish spam the normal way.

Honest mistakes count too. On the example site, every post answered at two URLs, and each one named itself as the main version. Only about 3 of 17 posts were indexed until a redirect removed the duplicates.

## Layer 3: what AI crawlers and agents read

AI systems read your site for different jobs, and each job needs its own decision. OpenAI documents separate bots for training (GPTBot), for ChatGPT search (OAI-SearchBot) and for actions a user asks for (ChatGPT-User), where "robots.txt rules may not apply" ([OpenAI's crawler docs](https://developers.openai.com/api/docs/bots)).

Agents also take instructions from what they read. OWASP ranks prompt injection first among risks for AI applications, and its indirect form uses "external sources, such as websites or files" to plant instructions ([OWASP's prompt injection entry](https://genai.owasp.org/llmrisk/llm01-prompt-injection/)).

So a hacked page, or a review on your store, can hide text aimed at the agent reading it.

## Layer 4: email others can send in your domain's name

Email has no built-in proof of who sent it. Anyone can put your domain in the From line, the same way anyone can write your home address as the return address on an envelope. Receiving mail servers decide whether to trust that claim by reading your DNS records.

> **SPF** — Sender Policy Framework, a DNS record that lists the servers allowed to send mail for your domain, where `-all` tells receivers to fail everyone else ([per the SPF standard](https://www.rfc-editor.org/rfc/rfc7208)).

> **DMARC** — Domain-based Message Authentication, Reporting and Conformance, a DNS record that tells receivers what to do with mail that fails those checks: deliver it (`p=none`), send it to spam (`p=quarantine`) or refuse it (`p=reject`).

The example site sends no email, and its contact address lives on a webmail provider. Yet its DNS had no SPF record, and the registrar's default DMARC record said `p=quarantine`.

Since April 2025, GoDaddy has given every new or transferred domain a default DMARC record set to quarantine ([GoDaddy's announcement](https://www.godaddy.com/resources/skills/enhancing-domain-security-dmarc-implementation)). With quarantine, forged mail still reaches the recipient's spam folder. **A domain that sends nothing has no reason to let any mail through in its name.**

Back to the envelope. SPF and DMARC work like a notice at the post office: nothing is ever posted from this address, so refuse anything that claims it was. The analogy has one limit. The notice works only at receivers that check it. Gmail does, and requires every sender to pass SPF or a signature check ([Gmail's sender guidelines](https://support.google.com/mail/answer/81126)).

![A badger postal clerk hands an envelope marked with the shop's picture back to a nervous ferret, beside a counter card showing the shop next to a crossed-out envelope.](https://a.storyblok.com/f/288495199849781/1536x1024/1d8f3ddd58/forged-mail-refused-at-the-counter.webp)

## Protect a domain that sends no email

The UK's National Cyber Security Centre (NCSC) recommends three DNS records, plus an empty email signing key, for any domain that sends no mail ([NCSC on parked domains](https://www.ncsc.gov.uk/blog-post/protecting-parked-domains)).

### Step 1: confirm nothing sends or receives as your domain

List every service putting your domain in the From line: a mailbox, a newsletter tool, a contact form, shop or CMS notifications. If any exist, stop: list them in SPF, and move to `p=reject` only after DMARC reports show they pass.

Then run `dig +short MX example.com`. If it returns a mail host, an address at your domain receives mail. Publish SPF and DMARC, but skip the null MX.

> **Null MX** — a mail exchange (MX) record with priority 0 and host `.`, which tells other servers the domain accepts no email at all ([per the null MX standard](https://www.rfc-editor.org/rfc/rfc7505)).

### Step 2: publish SPF, DMARC and a null MX

Add three records in your DNS host's form. Each one asks for a host, a type and a value:

- **SPF** — host `@`, type TXT (text), value `v=spf1 -all`
- **DMARC** — host `_dmarc`, type TXT, value `v=DMARC1; p=reject; rua=mailto:dmarc-reports@example.com`
- **Null MX** — host `@`, type MX, priority 0, value `.`

Add the SPF value as its own TXT record, and keep the other TXT records at `@`, such as site verification codes. If a record starting with `v=spf1` already exists, edit that one. Two SPF records count as an error.

One of those codes may verify Google Search Console (the Google tool that reports how Google indexes your site, and warns about hacks and manual actions). Google checks its token again from time to time. If the record is gone, your Search Console permissions expire after a grace period ([Google's verification help](https://support.google.com/webmasters/answer/9008080)).

Add the `_dmarc` record, or edit the existing one to `p=reject`, and keep a `rua` reporting address so receivers can tell you who tries to send as you.

### Step 3: verify on two kinds of DNS server

The authoritative nameservers show what you published. Public resolvers such as 1.1.1.1 and 8.8.8.8 show what receivers see right now, which can lag behind until old cached answers expire.

```bash
dig +short NS example.com
dig +short TXT example.com @ns1.your-dns-host.example
dig +short TXT _dmarc.example.com @ns1.your-dns-host.example
dig +short TXT example.com @1.1.1.1
dig +short TXT _dmarc.example.com @8.8.8.8
dig +short MX example.com @8.8.8.8
```

Put one of the nameservers from the first command in place of `ns1.your-dns-host.example`. You should see `"v=spf1 -all"`, the DMARC record with `p=reject`, and `0 .` for the MX. On the example site, SPF reached the authoritative servers a few minutes after DMARC, so wait a few minutes before you edit a missing record.

### When not to use this fix

If the domain sends any mail, `-all` and `p=reject` will make receivers refuse it. If the domain receives mail, a null MX will make other servers stop delivering it, so leave the MX records alone.

## Core practices: do, don't, and what happens if you skip it

Each layer has one core practice to start with, and one rule covers all four.

### Keep CMS tokens on the server, and check the deployed site

- **Do** — read the token from a variable without the `NEXT_PUBLIC_` prefix, and search the live JavaScript for it after each deploy.
- **Don't** — pass a preview or management token to client code, or treat green scanners as proof.
- **If you skip it** — anyone can copy the token from the bundle and read your drafts while every scanner stays green, and a leaked management token can also change content ([Storyblok's token docs](https://www.storyblok.com/docs/concepts/access-tokens)).

Part 2 shows how to find and rotate leaked tokens.

### Verify Search Console with DNS, and read its alerts

- **Do** — use a Domain property (one property for every subdomain), which Google verifies with "DNS record verification only" ([Google's property guide](https://support.google.com/webmasters/answer/34592)), and send its alerts to an inbox someone reads.
- **Don't** — rely only on an HTML file on the site, because whoever deletes that file removes your verification ([Google's verification help](https://support.google.com/webmasters/answer/9008080)).
- **If you skip it** — the notice Google sends every existing owner when a new owner appears ([Google's new-owner help](https://support.google.com/webmasters/answer/7281924)) lands where nobody reads it, and a hack goes unseen.

Part 3 turns Search Console and Bing Webmaster Tools into an early warning.

### Decide robots.txt per job

- **Do** — block training bots if your content is your product, allow AI search bots if you want to be cited in AI answers, and treat fetches a user asks for like a browser visit, since "robots.txt rules may not apply" to them ([OpenAI's crawler docs](https://developers.openai.com/api/docs/bots)).
- **Don't** — block every AI bot in one rule, or block a bot's network addresses when it already obeys robots.txt.
- **If you skip it** — a blanket block drops the site from ChatGPT search answers, and an address block can stop a bot from reading robots.txt at all ([Anthropic's crawler FAQ](https://support.claude.com/en/articles/8896518-does-anthropic-crawl-data-from-the-web-and-how-can-site-owners-block-the-crawler)).

Part 4 covers bots and planted instructions.

### Publish SPF and DMARC `p=reject`, and a null MX only if nothing is received

- **Do** — replace the registrar's `p=quarantine` default on a domain that sends no mail. If the domain sends mail, list those senders in SPF and move to `p=reject` only after DMARC reports show they pass.
- **Don't** — add a null MX to a domain that receives mail.
- **If you skip it** — anyone can send mail as the domain and, with quarantine, it still lands in spam folders. A wrong null MX stops your inbound mail.

### Turn on two-factor authentication for every account that controls the site

- **Do** — protect the code host, the deploy host, the CMS, the Google account and the registrar, and store the recovery codes.
- **Don't** — leave any of them on a password alone.
- **If you skip it** — one stolen password undoes every code fix, and the registrar account also controls your DNS verification.

## A self-audit for all four layers

### What your code ships

- Does any deployed JavaScript file (or its `.map` source file) contain a token, and what can that token read?
- Do internal CMS routes return a real 404, including for encoded paths?
- Are webhook secrets compared in constant time, sent to an address that does not redirect, and do deliveries succeed?
- Is dependency auto-merge gated on the pull request's author?

### What search engines index

- Who are the verified owners in Google Search Console and Bing Webmaster Tools, and does anyone read their alerts?
- Does a `site:` search for spam words on your domain return anything?
- Are preview and staging hosts behind a login, or at least marked `noindex` (hidden from search results)?

### What AI systems read and do

- Which AI bots does robots.txt allow, decided per job: training, search and user fetches?
- Can strangers post text that an AI agent might read and obey?

### What your domain lets others claim

- Does the domain publish SPF and DMARC `p=reject`, plus a null MX if it sends and receives no email?

---

*Your scanners check the code in your repository. Strangers, search engines and AI agents meet the deployed site, and if you never check it from the outside, the first person who does may be the one who abuses it.*

*Next up:* [**Is your API key in your JavaScript bundle?**](/posts/is-your-api-key-in-your-javascript-bundle)
