Hardened the application with nonce‑based CSP
Hardened the application with nonce‑based CSP, HSTS, SameSite cookies, least‑privilege database roles and server‑side entitlement re‑checks.
Work carried out: 2025
defence that holds when the browser is hostile
Situation. The platform holds professional and organizational data, the kind people expect to be handled properly, so a single line of defence was never going to be enough. The working assumption has to be that the client is hostile — that anything the browser enforces can be switched off by whoever’s holding the browser — and the security has to hold up anyway.
Task. The platform had to be hardened at every layer — frontend, API, database — so that security was enforced by the server independently of whatever the interface happened to allow.
Action. On the frontend, the Next.js proxy middleware — proxy.ts — sets a Content‑Security‑Policy with a per‑request nonce and strict‑dynamic, plus HSTS and SameSite cookies, so the browser is locked down about what it’ll run and send. At the API, there’s rate limiting, CORS, request‑size limits, input validation before anything touches the database, and logging of the security‑relevant events. In the database, the API logs in as a least‑privilege role that can only EXECUTE the app functions, the functions run SECURITY DEFINER, and everything is parameterised. And the entitlements — tier, role, organization, ship scoping — are re‑checked on the server on every request, with the frontend gates treated as UX only. The gates decide what you see; the server decides what you can do.
Result. Security doesn’t depend on the UI behaving. The protections are layered to avoid relying on a single control. Server‑side authorization is designed to operate independently of client‑side checks, so the interface is not the authority for access decisions.

Photo: ChiemSeherin / Pixabay 
Photo: zauber2011 / Pixabay
Bring this experience to your project
Use “Hardened the application with nonce‑based CSP” as a starting point for a similar challenge in your organisation. The services behind this work are available for your project. The part users never see: where the data lives, what the rules are, and how other systems are allowed to talk to it.
Look behind the result
Read the situation, decisions and result in this example. We can discuss which parts transfer to your constraints and which need another approach. Hardened the application with nonce‑based CSP — defence that holds when the browser is hostile
Read next: Built fail‑closed rate limiting and anti‑abuse. Or take a look at the full Portfolio.
One piece of a longer record — and it is all on this site.
Every entry is written the same way: the situation, the task, what we did and what changed.

