Security

Secure Defaults & Hardening

Foundational

The default behaviour is what you get under pressure, in a hurry, and late at night. So the default must be the safe one. A system is hardened not by the controls you can switch on, but by the ones that are already on, locked, and hard to turn off.

Most breaches do not use a clever zero-day. They walk through a setting someone left at its open default — open CORS, TLS validation disabled "for testing", a detailed error page in production, an admin endpoint with no auth. Hardening means shipping with every setting at its safest position, and requiring a deliberate, reviewed change to loosen it.

The Finperiti sample showed how this goes wrong: wide-open CORS, RequireHttpsMetadata=false outside dev, and a whole controller left unauthenticated. None of these were attacks. They were defaults nobody closed. Close them by design.

Ship locked down

Opening a default safely

Open CORS policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();

With credentials, this lets any website on the internet make authenticated calls on a user's behalf. Pin to an explicit origin list.

Explicit allow-list policy.WithOrigins(allowed).AllowCredentials()
.WithHeaders("Authorization", "Content-Type");

Only known front-ends can call the API, and only with the headers they actually need.

Self-review checklist

Why it matters: Open defaults are silent. Nothing breaks, no test fails, and the gap stays open until someone finds it. The cheapest, most reliable security control we have is shipping with the safe setting already in place, so that being insecure takes a deliberate, visible act.