This is a static site. No server-side code, no database, no user input forms. The attack surface is narrow by design. But “narrow” is not “zero,” and most static sites ship with none of the protections described here.
This post documents everything I implemented, why each measure matters, and how it works. The source is public — every snippet below links back to the actual file in the repository.
What static sites don’t need to worry about
Before the list of what I did, here’s what I didn’t need to do:
- SQL injection — there is no database
- CSRF — there are no forms, no sessions, no state-changing requests
- Session hijacking — there are no sessions
- Server-side request forgery — there is no server
- Authentication bypass — there is no authentication
This is not laziness. This is the threat model. A static site’s attack surface is the browser, the CDN, and the CI pipeline. That’s where the hardening goes.
Transport layer
HTTPS and HSTS
Cloudflare Pages enforces HTTPS and sets Strict-Transport-Security automatically. There’s nothing to configure — it’s on by default with no opt-out. Every connection is TLS 1.2+ with a valid certificate issued by Cloudflare’s CA.
This is table stakes. If your static site is still serving over HTTP, fix that before reading the rest of this post.
Response headers
Content Security Policy
The CSP starts with default-src 'none' and explicitly allowlists only what the site needs:
default-src 'none';
script-src 'self' 'sha384-WPdCOuyIyxx73emN29FdNG0528bacmGSH7D5bSC5WaDViePqyAzU+u5w9RDsWqbE';
style-src 'self' 'unsafe-inline';
font-src 'self';
img-src 'self' data:;
connect-src 'self';
base-uri 'self';
form-action 'none';
frame-ancestors 'none'
This is enforced as an HTTP header by Cloudflare Pages (via static/_headers) and mirrored as a <meta> tag for belt-and-braces coverage on any cached or locally-served copy. The HTTP header is the authoritative source — it’s where frame-ancestors actually runs, since frame-ancestors is ignored in meta-tag CSP by all current browsers.
What this blocks:
- XSS payloads — any injected script from an external origin is refused
- Clickjacking —
frame-ancestors 'none'prevents embedding in iframes - Form hijacking —
form-action 'none'blocks form submissions entirely - Data exfiltration —
connect-src 'self'blocks fetch/XHR to external origins
The sha384-… hash in script-src is the SHA-384 of the theme initialization script that runs inline before the page renders — it prevents a flash of unstyled content without opening 'unsafe-inline'. The hash is computed at build time. If the script changes, the build updates the hash; if the deployed hash doesn’t match what the browser receives, the script is blocked.
Other security headers
The _headers file sets everything else:
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=(), usb=(),
interest-cohort=(), browsing-topics=(), attribution-reporting=(),
private-state-token-issuance=(), private-state-token-redemption=(),
screen-wake-lock=(), idle-detection=(), serial=(), bluetooth=(), hid=()
X-XSS-Protection: 0
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
X-XSS-Protection is intentionally set to 0, not 1. The legacy XSS filter in older browsers can actually introduce vulnerabilities by selectively removing parts of the page. CSP supersedes it entirely. Setting it to 0 disables the filter explicitly.
X-Frame-Options: DENY is intentionally absent. frame-ancestors 'none' in the CSP is the modern equivalent and supersedes XFO in every browser released in the last decade. Carrying both is dead weight that signals “copied a 2014 checklist.”
Permissions-Policy disables hardware APIs this site will never use. The first wave covered FLoC via interest-cohort=(); the updated list adds the APIs that replaced FLoC — browsing-topics, attribution-reporting, and the Private State Token APIs — along with newer sensor and device APIs (screen-wake-lock, idle-detection, serial, bluetooth, hid). These directives are ignored by browsers that don’t understand them, so adding them is risk-free.
Asset integrity
Subresource Integrity
Every CSS and JS file goes through Hugo’s fingerprint pipeline:
{{- $css := resources.Get "css/main.scss" | toCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}" integrity="{{ $css.Data.Integrity }}" />
{{- $js := resources.Get "js/main.js" | js.Build (dict "minify" true) | fingerprint }}
<script src="{{ $js.RelPermalink }}" defer integrity="{{ $js.Data.Integrity }}"></script>
The fingerprint function generates a SHA-384 hash and appends it to the filename. The integrity attribute tells the browser to verify the hash before executing. If the file has been tampered with — by a compromised CDN, a MITM proxy, or a cache poisoning attack — the browser refuses to load it.
Asset fingerprinting
The same fingerprint function produces content-addressed filenames like main.a1b2c3d4.css. When the file changes, the hash changes, the filename changes, and browser caches are automatically busted. No stale scripts survive a deploy.
Self-hosted fonts
No Google Fonts. No external CDN. Two font families served from /static/fonts/ in WOFF2 format:
- Inter (Regular, SemiBold, Italic) for prose
- JetBrains Mono (Regular) for code
This eliminates a common privacy leak. Google Fonts requests send visitor IPs, referer headers, and user agent strings to Google on every page load. Self-hosting removes that entirely and lets the CSP enforce font-src 'self' without exceptions.
Content policy
Unsafe HTML disabled
Hugo’s Goldmark renderer is configured with unsafe = false:
[markup.goldmark.renderer]
unsafe = false
This strips raw HTML from Markdown content. No <script>, no <iframe>, no <object> — none of it survives the renderer. All HTML comes from layouts and shortcodes, which are controlled code.
Minimal JavaScript surface
The entire site runs on roughly 150 lines of vanilla JavaScript. Theme toggle, scroll behavior, copy buttons, a Konami code easter egg. No frameworks, no npm dependencies, no bundler beyond Hugo’s built-in esbuild.
Fewer lines of JavaScript means fewer places for vulnerabilities to hide and fewer dependencies to audit.
Supply chain
GPG-signed commits
Every commit to this repository is cryptographically signed with an ed25519 GPG key. GitHub renders a “Verified” badge. If a commit appears without the badge, something is wrong.
Dependabot
GitHub Actions versions are monitored weekly by Dependabot. When a new version of actions/checkout, cloudflare/pages-action, or any other pinned action is released, a PR is opened automatically. No manual tracking required.
Build traceability
Every deploy writes a data/build.json with the full commit SHA, short hash, UTC timestamp, and branch name. The short hash is rendered in the footer as a link to the commit on GitHub. Any visitor can verify which commit produced the live site.
Monitoring
Automated security scanning in CI
A “Security checks” step runs in the deploy pipeline after the Hugo build and before the artifact upload:
# CSP meta tag must be present in every HTML file
CSP_MISSING=$(find public -name '*.html' \
-not -path 'public/admin/*' -not -path 'public/wp-*' \
-not -path 'public/healthz/*' \
| xargs grep -L 'Content-Security-Policy' \
| xargs grep -L 'http-equiv=refresh' || true)
# SRI integrity attributes on stylesheet and script tags
SRI_MISSING=$(grep -rlE '<(link rel="stylesheet"|script src=)' public \
--include='*.html' | xargs grep -L 'integrity=' || true)
# No external script or stylesheet URLs
EXTERNAL=$(grep -rhoP '(src|href)="https?://[^"]*"' public \
--include='*.html' \
| grep -v 'github.com/marianholly' \
| grep -v 'marianholly.github.io' || true)
If any check fails, the pipeline exits non-zero. No deploy happens without CSP, SRI, and zero external resources.
Disclosure and contact
security.txt (RFC 9116)
A machine-readable security contact file at /.well-known/security.txt:
Contact: mailto:[email protected]
Expires: 2027-03-24T00:00:00.000Z
Preferred-Languages: en
Policy: https://marianholly.github.io/blog/security/
Encryption: https://marianholly.github.io/blog/pgp-key.asc
The Encryption field points to the PGP public key, so researchers can encrypt their reports. The Policy field points to a dedicated disclosure page with scope, response timelines, and a safe harbor clause.
PGP public key
The GPG public key is served at /pgp-key.asc in ASCII-armored format. Researchers can import it and encrypt messages to the contact email. The key is ed25519, expiring 2029.
Extras
Honeypot routes
Static pages at /admin, /wp-admin, and /wp-login.php serve a terminal-style “ACCESS DENIED” message. A hidden link in the base layout (visually hidden, aria-hidden, tabindex="-1") ensures crawlers find /admin. There is no admin panel. That’s the point.
Client-side encrypted posts
A Hugo shortcode for password-protected content. The content is encrypted offline with AES-256-GCM (PBKDF2-SHA256 key derivation, 600k iterations) and stored as Base64 ciphertext in the HTML. The browser decrypts it client-side using the Web Crypto API. The key never touches a server.
Wrong passwords fail cleanly — AES-GCM’s authentication tag catches them, and the UI shows an error instead of garbled output.
CTF flags
Three flags are hidden on the site at increasing difficulty levels. The /security page mentions that a flag exists somewhere. No other hints are given.
Checklist for your static site
If you want to apply any of this to your own site, here’s what to check:
- CSP with
default-src 'none'and explicit allowlisting - Hash-pinned inline scripts in
script-src(no'unsafe-inline') - SRI
integrityattributes on all CSS and JS tags -
X-Content-Type-Options: nosniffheader -
Referrer-Policy: strict-origin-when-cross-originheader -
Permissions-Policydisabling unused hardware and tracking APIs -
frame-ancestors 'none'in CSP (supersedesX-Frame-Options) - Self-hosted fonts (no Google Fonts requests)
-
security.txtat/.well-known/security.txt - Asset fingerprinting for cache busting
- Raw HTML disabled in Markdown renderer
- Signed commits
- Dependabot for CI action versions
- CI checks that verify security properties before deploy
- Host that enforces HTTP headers (
_headersis silently ignored by GitHub Pages)
Test your headers:
- securityheaders.com — grades your HTTP response headers
- Mozilla Observatory — broader security assessment
- CSP Evaluator — analyzes your Content Security Policy for weaknesses
The source for everything described here is at github.com/marianholly/blog.