Why a static site still needs security
A static site has no server program or database to break into, which removes many attacks. The risks that remain happen in the visitor’s browser: code that should not run, links that hijack a tab, the site shown inside someone else’s page, or private details leaking out.
Good security works in layers. No single measure is perfect, so each layer limits the damage if another one fails.
The main threats
- Code injection (XSS)
- Someone gets their own JavaScript to run on the site, where it could read what visitors type.
- Compromised outside code
- A script loaded from another company’s server is changed by an attacker, and runs on every site that loads it.
- Clickjacking
- Another site shows this one inside an invisible frame and tricks visitors into clicking.
- Unsafe links
- A page opened in a new tab takes control of the tab that opened it.
- Leaking information
- Private files, internal notes or hidden data inside images end up public.
- Form abuse
- Bots fill a contact form with spam.
Principles
- Allow only what is needed, and refuse everything else by default.
- Treat every piece of data as text, never as code.
- Run no code that has not been read.
- Publish only what visitors need.
- Write down the known gaps instead of pretending there are none.
How this site applies them
- A strict security policy
- A Content-Security-Policy header tells browsers to run only this site’s own scripts, plus five inline scripts identified by fingerprints of their exact text. Injected code has a different fingerprint and is refused.
- Text, never code
- All content is inserted with textContent, never innerHTML, and the generated pages escape every character that could start a tag.
- Safe links
- Links must start with # or https://, and external ones open with rel="noopener noreferrer".
- Almost no outside code
- The fonts and the visit-counting script are stored on the site itself. The one exception is the contact form’s “I am human” check (hCaptcha): it loads only when a visitor nears the form, and the policy names its address only for that check.
- No framing
- frame-ancestors none and X-Frame-Options DENY stop other sites from showing this one in a frame.
- Private files stay private
- Tests, tools and internal notes are kept off the live site by a .vercelignore file.
- Hidden image data removed
- Eight screenshots carried phone metadata: a build number, capture times and image ids, though no location. A small tool removed it without changing the pictures, and a test now fails if any image carries it.
Proving it
The defences are tested, not trusted: a script injected into the page is blocked, markup planted in the data file appears as harmless text on the generated pages, and a javascript: link is dropped. Every page is tested under the real policy, and no violation is allowed.
The known gap, and its fix
The contact form’s spam checks ran only in the visitor’s browser, and its access key is public by design, so a bot could send messages to the service directly. The fix is a captcha: the form now sends a one-time proof from hCaptcha with each message. The gap closes only once the form service is told to refuse messages without that proof, and until then it stays open. Writing the gap down is part of the security work.