Module 23 · DevSecOps & Application Security · Lesson 67 of 75

The secure development lifecycle and threat modelling

Why fixing security early is cheaper, the stages of a secure SDLC, secure coding principles, and a STRIDE threat model of a real feature.

In this lesson · about 40 minutes

  • Describe security activities at each stage of the SDLC
  • Apply core secure-coding principles
  • Threat-model a feature with STRIDE and a data flow diagram

Shift left, and keep watching right

"Shift left" moves security earlier in the timeline. It does not replace testing and monitoring in production ("shield right"); you need both.

Security in each stage of the SDLC

StageSecurity activity
RequirementsSecurity and privacy requirements, abuse cases ("as an attacker, I want to...")
DesignThreat modelling, secure architecture review
CodeSecure coding standards, IDE linters, peer review, pre-commit secret scanning
BuildSAST, SCA, secrets scanning, IaC and container scanning in CI
TestDAST, API testing, penetration testing for big changes
Release / deploySigned artefacts, approved images, policy checks
OperateMonitoring, WAF, runtime protection, bug bounty, patching

Frameworks: NIST SSDF (SP 800-218), OWASP SAMM (maturity model), Microsoft SDL, and OWASP ASVS for web application requirements.

Secure coding principles

  • Validate input on the server (allow-lists, types, lengths) and encode output for its context (HTML, JavaScript, SQL, shell).
  • Parameterised queries, never string-built SQL.
  • Use proven libraries for authentication, sessions and cryptography; never write your own crypto.
  • Least privilege for the app's database account, cloud role and file access.
  • Fail securely: errors deny access and do not leak stack traces.
  • Secrets in a vault or secrets manager, never in code.
  • Log security events without logging secrets or personal data.

Threat modelling

Four questions (from the Threat Modeling Manifesto): What are we building? What can go wrong? What are we going to do about it? Did we do a good job? Draw a data flow diagram with processes, data stores, external entities, data flows and trust boundaries (where data crosses from less to more trusted). Then walk each element through STRIDE:

ThreatViolatesExample control
SpoofingAuthenticationMFA, signed tokens
TamperingIntegritySignatures, server-side validation
RepudiationNon-repudiationAudit logs
Information disclosureConfidentialityEncryption, access checks
Denial of serviceAvailabilityRate limits, quotas
Elevation of privilegeAuthorisationRole checks on every request

Other approaches: PASTA (risk-centric), LINDDUN (privacy), attack trees. Tools: OWASP Threat Dragon, Microsoft Threat Modeling Tool, or a whiteboard.

Performance-based question (PBQ)

STRIDE the password-reset feature

Your team is building "forgot password": the user enters an email, receives a link with a token, and sets a new password. You list threats in the design review.

Pick the STRIDE category for each threat.

  • The page says 'no account with that email', revealing which emails are customers
  • An attacker guesses a short reset token and takes over the account
  • A bot requests 50,000 reset emails, getting the mail domain blocked
  • Changing user_id in the reset request sets another user's password
  • No log is kept of resets, so a user can deny requesting one
  • The token in the link can be modified to extend its expiry time
0 of 6 answered

Check your understanding0 of 3 correct

Question 1

1.Where in the SDLC does threat modelling belong?

Question 2

2.In STRIDE, the R stands for...

Question 3

3.What is a trust boundary?

Quiz score: 0 of 3

Tip: answer every quiz question correctly first.

Written by Noviq Academy in its own words. All labs are simulations: no real systems are touched, and every name, address, password and hash is made up. The offensive techniques taught here are for defending systems and for authorised testing only; never scan, access or test a system without the owner's written permission. Tool and product names belong to their owners, and command output may differ slightly from yours. Read-aloud uses your device's built-in voices.