Jan 15, 2026 · 3 min read
Security-first web development: secure by default
- security
- web
- best-practices
Security-first web development isn't a login screen. Three questions I ask about every feature, and how schema validation makes the safe path the easy one.
Security-first web development, in plain terms: the three questions I ask before I build any feature, the one habit that makes secure code the default, and why it gets cheaper every time you do it.
I build websites with a focus on making them secure. People sometimes hear that and think I add a login screen and call it a day. I don't. Security-first is a way of thinking about every decision before the code exists.
Most breaches start with the boring stuff
Most breaches don't come from exotic exploits. They come from the boring things nobody threat-modelled:
- a form without rate limiting,
- a database query built from user input,
- an environment variable committed by accident.
None of those need a genius attacker. They need someone who looks. So I look first.
Threat modelling for web apps: three questions
Threat modelling sounds heavy. It doesn't have to be. Before a feature ships, I ask three questions about it:
- What's the worst input someone could send here? Not the input you expect. The worst one.
- What happens if this request is replayed a thousand times a second? If the answer is "the server falls over" or "the inbox fills up", it needs a limit.
- Who can see this data, and have I actually checked? "Only logged-in users" is an assumption until the code proves it.
Three questions. Every feature. That's the habit.
Input validation: make the safe path the easy path
The trick is to make security the default, so you (and anyone you work with) have to go out of your way to do the wrong thing. For input, that means one schema at the boundary:
// Validate everything at the boundary with a schema.
import { z } from "zod";
const ContactInput = z.object({
name: z.string().min(1).max(80),
email: z.string().email(),
message: z.string().min(10).max(2000),
});
export function parseContact(raw: unknown) {
return ContactInput.parse(raw); // throws on anything unexpected
}The input comes in as unknown. Nothing gets past parseContact unless it has
the right shape and the right length. Anything else throws, right there, before it
touches the rest of the app.
When validation, escaping and authorisation all live at the boundary, the rest of your code can trust its inputs. That's not just safer. It's calmer to work in. You stop sprinkling checks everywhere and hoping you didn't miss one.
Secure habits compound
Every secure habit you build is reusable:
- The schema you wrote for one form protects the next one.
- The Content-Security-Policy you tuned once keeps paying off on every page.
- The check you made a rule stops being a thing you have to remember.
Same on client work. The Furrea webshop has a Content-Security-Policy and CSRF protection in the build, next to the products and the payments.

Security-first isn't slower. It's how you avoid rewriting everything after the incident. And when you skip it, the bill comes anyway: I learned that the hard way, and wrote it up in the unglamorous security wins (and the crypto-miner I let in).
Secure is the default here
Not an extra. Not a line item. Not a promise in the headline. Just how the websites I build are put together.

Want to talk security, performance or building something properly? Get in touch.