Secure by Design: Building Security into Software Before Development Starts

Most serious vulnerabilities come from design decisions, not typing mistakes. An API that trusts any client to provide a customer ID, or an admin role that can do everything, are flaws no scanner will flag at the end. CISA's Secure by Design programme and the NCSC's secure development guidance both make the same point: security has to be designed in from the start.
Threat model early, and keep it light
Threat modelling just means asking four questions:
- What are we building?
- What could go wrong?
- What are we going to do about it?
- Did we do a good enough job?
One workshop with a data-flow diagram is enough to start. Focus on trust boundaries: places where data crosses from a user, partner or external system into yours.
Design decisions that matter most
- Identity: use your existing identity provider, such as Entra ID, rather than building your own login system. Require multi-factor authentication for privileged users.
- Authorisation: check permissions on the server for every request and every record. Broken access control has topped the OWASP Top 10 for years.
- Least privilege: give users, services and integrations only the access they need, including database accounts and API keys.
- Data protection: classify your data, encrypt it in transit and at rest, and collect only what you need.
- Secrets: keep them in a vault, never in code or configuration files.
- Logging: record security-relevant events without logging personal data or credentials.
- Failure behaviour: when something fails, the system should fail closed (deny access) rather than fail open.
Turn controls into acceptance criteria
Security requirements should be tested in the same way as features. OWASP ASVS offers three verification levels. Pick the level that matches your risk and use it as your checklist.
AI changes the threat model
If your application uses large language models (LLMs), new threats appear. These include prompt injection, sensitive information leaking through outputs, and agents taking actions with too much authority. The OWASP Top 10 for LLM Applications is the place to start. Treat model output as untrusted input.
Buyer's checklist
- Has a threat model been produced and reviewed?
- Is authorisation enforced on the server, per record?
- Are secrets kept in a managed vault?
- Which ASVS level applies, and how will it be verified?
- If AI features are included, have the LLM risks been assessed?
How Cyber Samurai can help
Further reading in this series
Keep reading


