Skip to content

Expert · DevSecOps · topic 46 of 53 · 30 min

DevSecOps: shifting security left

Explanation

DevSecOps means building security into every step of delivery, from design to production, instead of a security check just before release. Finding a problem early (shifting left) is far cheaper than finding it in production. Threat modelling, the OWASP Top 10, secure defaults and sensible pipeline gates are the basic tools.

Why "shift left"?

Picture the life of a feature as a line from left to right: idea, design, code, build, test, release, run. Shift left means moving security checks towards the left side of that line, so they happen earlier. A design flaw found on a whiteboard costs a ten-minute conversation. The same flaw found in production can cost an emergency fix, a lost weekend, a breach notice to customers and a regulator, and lost trust.

In the old model, a separate security team tested the app a few days before release and handed over a long PDF of problems. Developers had already moved on, deadlines were close, and most findings were either rushed or ignored. DevSecOps (development, security and operations) replaces that with small, automatic checks in every pull request and every pipeline run, plus a few human practices like threat modelling.

Think of it like this: Think of building a house. If the electrician checks the wiring while the walls are still open, a mistake takes five minutes to fix. If the check happens after the walls are plastered and painted, every fix means breaking a wall. Security checks in a pipeline are the electrician visiting during construction.

Security is everyone's job

  • Developers validate input, use parameterised database queries and never hard-code secrets.
  • Reviewers look for missing access checks in pull requests, not just style.
  • DevOps engineers add scanners to the pipeline, give every service the least privilege it needs, and keep base images patched.
  • The security team becomes an enabler: it chooses tools, writes guidance, trains "security champions" (one interested developer per team) and helps with threat models.

Threat modelling: thinking like a defender

Threat modelling is a structured conversation about what could go wrong with a design before it is built. Four simple questions guide it: What are we building? What can go wrong? What are we going to do about it? Did we do a good enough job?

Start with a data flow diagram (DFD): a simple drawing of external entities (users, a payment gateway), processes (your API), data stores (databases, buckets) and the arrows between them. Then mark the trust boundaries: the places where data crosses from a less trusted zone to a more trusted one, such as from the internet into your API. Most threats sit on those boundaries.

output
[Student phone] --HTTPS--> | trust boundary | --> [Canteen API] --> (Orders DB)
                                                        |
                                                        +--> [Payment gateway]  (external)
A tiny DFD for a college canteen ordering app. The vertical bars mark the trust boundary between the internet and the API.

Then walk through each element and arrow with STRIDE, a checklist of six kinds of threat. For each one, ask "could this happen here?" and note the defence.

LetterThreatCanteen app exampleTypical defence
SSpoofing: pretending to be someone elseOrdering with another student's IDStrong authentication, MFA for staff
TTampering: changing data you should notEditing the price in the request bodyServer-side checks, integrity checks, signatures
RRepudiation: denying you did something"I never placed that order"Audit logs with user, time and action
IInformation disclosure: data leaksAPI returns every student's phone numberAccess control, return only needed fields, encryption
DDenial of service: making it unavailableA script floods the order endpoint at lunchRate limits, quotas, autoscaling
EElevation of privilege: gaining more rightsA student calls the admin refund endpointRole checks on every request, least privilege

The OWASP Top 10 for DevOps people

OWASP (the Open Worldwide Application Security Project) is a non-profit that publishes free security guidance. Its Top 10 is a list of the most common web application risks. The table follows the 2025 edition; the 2021 edition is still widely quoted, so check owasp.org for the exact wording.

RiskIn one lineThe usual fix
A01 Broken Access ControlUsers reach data or actions they should notCheck permissions on the server for every request; deny by default
A02 Security MisconfigurationDebug mode on, default passwords, open bucketsHardened, reviewed configuration as code; scan IaC
A03 Software Supply Chain FailuresVulnerable or malicious dependencies and build toolsSCA, lockfiles, SBOMs, signed artefacts
A04 Cryptographic FailuresWeak or missing encryptionTLS everywhere, strong algorithms, managed keys
A05 InjectionUntrusted input runs as SQL or commandsParameterised queries, input validation, SAST
A06 Insecure DesignThe design itself has no defenceThreat modelling, secure design patterns
A07 Authentication FailuresWeak logins, no MFA, broken sessionsMFA, rate limiting, proven login libraries
A08 Software or Data Integrity FailuresUnsigned updates or untrusted data trustedSignatures, verified pipelines, safe deserialisation
A09 Security Logging and Alerting FailuresAttacks happen and nobody noticesLog security events, alert on them, keep logs safe
A10 Mishandling of Exceptional ConditionsErrors leak details or fail openFail safely (closed), generic error messages, tests for errors

Secure defaults

A secure default is a setting that is safe unless someone deliberately changes it. People rarely change defaults, so the default decides how secure most systems are. Examples: new storage buckets are private, containers run as a non-root user, debug mode is off in production, network access is denied unless allowed, and every new service account starts with no permissions.

Security gates that do not block everything

A security gate is a pipeline step that fails the build when a scanner finds a serious problem. If the gate fails on every low-severity finding, developers learn to ignore it or ask for it to be switched off. A good gate is strict about what matters and quiet about the rest.

  • Severity threshold: fail on critical and high findings; show medium and low as warnings.
  • Baseline: fail only on new findings in this change, and track older ones as a backlog to burn down.
  • Exceptions with expiry: when a finding cannot be fixed yet (no patch exists, or it is a false positive), record an exception with an owner, a reason and an expiry date. After the date, the gate fails again.
yaml
# security-gate.yaml: read by the pipeline's gate step
fail_on: high            # fail on high and critical
exceptions:
  - id: DEMO-2026-0012
    reason: "No fixed version of the PDF library yet; input is only from staff"
    owner: priya@example.com
    expires: 2026-12-31
An example gate policy. Every exception has an owner, a reason and an expiry date.
Careful: Common mistakes: (1) a gate that blocks on everything, so people disable it; (2) exceptions with no expiry date, which quietly become permanent; (3) scanners that run but whose reports nobody reads; (4) leaving all security to one review at the end. Fix them with thresholds, expiring exceptions, findings shown inside the pull request, and small checks at every stage.
Tip: Start with one or two scanners in "report only" mode for a couple of weeks, fix the noise, then turn on the gate for critical and high findings. Teams accept a gate that is quiet and right.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

DevSecOps: shifting security left · 1/7

DevSecOps Security in every step

DevSecOps means building security into every step of delivery, instead of one big check just before release.

Prefer a video by a teacher? Find free videos on “devsecops shift left threat modelling stride explained” on YouTube ↗

In real life: A fintech team in Pune threat-models a "split the bill" feature

Before writing code, three developers and a security champion draw the data flow for a new feature that lets friends split a restaurant bill over UPI. Walking through STRIDE, they notice the draft API takes the payer's user ID from the request body. Anyone could change it and charge a friend (spoofing and elevation of privilege). They change the design so the user ID always comes from the login token. The discussion takes 45 minutes. Found after launch, the same flaw would have meant a fraud investigation and an RBI incident report.

Practice (0/3 done)

Task 1 · Question

A team adds a SAST scanner that fails the build on every finding, including low ones. What is the most likely result after a month?

Task 2 · Code · Python

Write gate_passes(findings, allowlist, today, threshold="high"). findings is a list of dicts like {"id": "F1", "severity": "critical"}; severities in order are low, medium, high, critical. allowlist maps a finding id to an expiry date "YYYY-MM-DD". The gate FAILS (return False) if any finding at or above the threshold is not covered by an exception that is still valid on today (an exception is valid up to and including its expiry date). Otherwise return True.

Task 3 · Practice

Threat-model a college canteen ordering app: students order and pay on their phones; canteen staff see orders on a tablet; payments go through a payment gateway; orders are stored in a database. Draw (or write) the data flow, mark trust boundaries, and list at least one threat and defence for each STRIDE letter.

Quick quiz

Question 1

1.What does "shift left" mean in DevSecOps?

Question 2

2.In STRIDE, a user claims "I never placed that order" and you cannot prove otherwise. Which threat is this?

Question 3

3.Which is the best example of a secure default?

Question 4

4.A vulnerability has no fixed version yet. What is a sensible way to let the pipeline continue?

Question 5

5.Where do most threats appear on a data flow diagram?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What does "shift left" mean in DevSecOps?

Answer: Doing security checks earlier in the delivery process

Left is the start of the delivery line (design and code). Finding problems there is cheaper.

In STRIDE, a user claims "I never placed that order" and you cannot prove otherwise. Which threat is this?

Answer: Repudiation

Repudiation is denying an action. Audit logs with who, what and when are the defence.

Which is the best example of a secure default?

Answer: New storage buckets are private unless someone makes them public

A secure default is safe unless someone deliberately changes it.

A vulnerability has no fixed version yet. What is a sensible way to let the pipeline continue?

Answer: Add an exception with an owner, a reason and an expiry date

An expiring exception is recorded, owned and reviewed again, so it does not become permanent by accident.

Where do most threats appear on a data flow diagram?

Answer: At trust boundaries, where data crosses from a less trusted zone to a more trusted one

Trust boundaries are where input from outside must be checked, so most threats sit there.

What is the OWASP Top 10?Related

Answer: A list of the most common and serious web app security risks

The Top 10 is a free awareness list of the most common and serious risks found in real web apps.

From The OWASP Top 10: the most common web risks

Why refer to OWASP in a finding?Related

Answer: It is a trusted standard the client recognises

OWASP is widely recognised, which makes findings credible.

From The OWASP approach to web testing

Debug mode left on in production, showing stack traces to users, is…Related

Answer: Security misconfiguration

Wrong settings in production are misconfiguration.

From The OWASP Top 10 with fixes

Under semantic versioning, a release adds a new feature without breaking anything. Version 2.3.1 becomes:Related

Answer: 2.4.0

A new backward-compatible feature bumps MINOR and resets PATCH to 0.

From Testing, quality gates and artefacts

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 3 more topics in “DevSecOps” before its exam: Secrets management, Software supply chain security, Kubernetes security.
  2. Module 11 exam: DevSecOps · 12 questions · 20 min, without help. 4 topics of this module still to finish first.
  3. Then the next module, GitOps, platform engineering and DevOps careers. 53 topics left in the course before the final exam.

← Previous: Resilience patterns, capacity and chaos engineering