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.
2025

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.

Categories:
1Platform Architecture	/categories/platform-architecture/	engineer.company	70
1Backend Engineering	/categories/backend/	engineer.company	70
1Frontend Engineering	/categories/frontend/	engineer.company	70
1APIs & Integration	/categories/api/	engineer.company	70
1Databases	/categories/databases/	engineer.company	70
1Security	/categories/security/	engineer.company	70

Services:
1Backend & API Development	/services/backend-development/	engineer.company	70
1Security & Access Management	/services/security-access/	engineer.company	70

hThis page on the web	URL:https://engineer.company/portfolio/hardened-the-application-with-nonce-based-csp/	engineer.company	70
