⚙️DevOps
Advanced · Lesson 8/8

DevSecOps — Security Built In

25 min 1 exercise 1 quiz

What you'll learn

  • Why security can't be a final step anymore
  • "Shift left" — catching issues early
  • Automated security in the pipeline
  • The mindset that ties DevOps and security together

Security as an ingredient, not a topping 🔒

The old way: build the software, and right before launch, throw it over the wall to a security team who scramble to find problems. By then, fixing a flaw is expensive and delays everything. DevSecOps fixes this with one idea: build security into every stage, automatically — it's an ingredient mixed into the dough, not a topping added at the end.

"Shift left." Picture the pipeline as a timeline flowing left (write code) to right (production). Traditionally security sat far right, at the end. DevSecOps shifts it left — security checks happen early and continuously, from the moment code is written. The earlier you catch a vulnerability, the cheaper and easier it is to fix (a bug caught while coding costs pennies; the same bug caught in production can cost a fortune and a breach).

Automated security in the CI/CD pipeline — bolt these onto the stages you already know:

  • SAST (Static analysis) — scan the source code for vulnerable patterns as it's committed.
  • Dependency scanning — check your libraries for known vulnerabilities (most apps are 80% third-party code — remember supply-chain risk).
  • Secret scanning — block commits that accidentally contain passwords or API keys (a top cause of leaks, from the cloud track).
  • Container scanning — inspect Docker images for vulnerable packages before they ship.
  • DAST (Dynamic analysis) — attack the running app in staging to find holes.

Each becomes a pipeline gate: if a critical vulnerability is found, the build fails and the code doesn't ship — the same fail-fast principle as CI/CD tests, applied to security.

The mindset: security is everyone's job and it's continuous, not one person's final checkbox. This connects the whole picture — the secure coding from the cyber track, least privilege from cloud, and the automation from DevOps, all woven together. Companies want engineers who build fast and safe, which is exactly why DevSecOps skills command top salaries.

Threat modeling — thinking like an attacker on purpose 🧠

Automated scanners (SAST, DAST, dependency scanning) catch known patterns of vulnerabilities. But some of the worst security failures aren't a missing scan — they're a design that never considered how it could be abused. Threat modeling is a structured exercise, done before or during building a feature, where the team deliberately asks: "how could this be attacked?"

A popular, simple framework is STRIDE, which names six categories of things to check for on any feature:

  • Spoofing — can someone pretend to be another user?
  • Tampering — can someone alter data they shouldn't (a request, a file, a database row)?
  • Repudiation — can someone deny doing something, with no log to prove otherwise?
  • Information disclosure — can private data leak to someone who shouldn't see it?
  • Denial of service — can someone overwhelm the system so real users can't use it?
  • Elevation of privilege — can a normal user gain admin-level power?

For example: building a "reset password" feature? Threat model it: Spoofing — could someone request a reset for an email they don't own? Tampering — can the reset token be guessed or reused? Denial of service — can someone spam reset requests to lock an account? Answering these before writing code is far cheaper than finding the bug after attackers do — the ultimate "shift left."

Threat modeling doesn't replace automated scanning — it complements it. Scanners catch known-pattern bugs in code that already exists; threat modeling catches design flaws before the code is even written.

Exercise 1

Build a simple vulnerability severity classifier, the kind a security pipeline gate uses. Write classifyVuln(score) where score is a CVSS-style number from 0 to 10. Return:

  • "low" for score < 4
  • "medium" for 4 to less than 7
  • "high" for 7 to less than 9
  • "critical" for 9 and above

A real pipeline would fail the build automatically on any "critical" result.

Real-world case study: Log4Shell (2021) 🔍

In December 2021, researchers disclosed a vulnerability in Log4j, a Java logging library used, directly or indirectly, inside an enormous share of the world's server software. The flaw, nicknamed Log4Shell, let an attacker send a single specially crafted string — sometimes just in a chat message or a username field — that the library would interpret as a command, letting attackers run arbitrary code on the server. It scored a maximum 10.0 on the CVSS severity scale: about as critical as a vulnerability gets.

The damage came from dependency depth: most teams didn't use Log4j directly — it was buried three or four layers deep inside other libraries they depended on. Exactly the "80% of your app is third-party code" supply-chain risk from this lesson. Security teams worldwide spent the following weeks scrambling to find out if Log4j was hiding anywhere in their stack, and patch it, because there was no simple way to know.

This is precisely why automated dependency scanning in the pipeline matters: a tool that continuously checks every library (including the invisible, deeply-nested ones) against a database of known vulnerabilities would have flagged Log4Shell automatically, instead of teams needing to manually hunt through their entire dependency tree during a live crisis.

Quick quiz

Question 1 of 6

What does 'shift left' mean in DevSecOps?

Question 2 of 6

Why catch a vulnerability early rather than in production?

Question 3 of 6

What does automated 'secret scanning' in a pipeline do?

Question 4 of 6

What is threat modeling?

Question 5 of 6

In STRIDE, what does the 'E' (Elevation of privilege) check for?

Question 6 of 6

Why was Log4Shell so hard for teams to find and fix?

Track complete! 🎓

Your DevOps foundation is built:

  • Linux/shell + Git workflows — the automation cockpit
  • Docker, CI/CD, Kubernetes — build, deliver, and orchestrate
  • IaC, monitoring, and DevSecOps — reproducible, observable, secure systems

Path to paid work: DevOps is one of the highest-paid, most in-demand fields in tech. Build a real project that shows the full loop: an app in a Docker container, a GitHub Actions pipeline that tests and deploys it, defined with Terraform, with basic monitoring — all on GitHub. Get a cert (AWS or the Certified Kubernetes Administrator), combine with the "Getting Paid" lesson, and you're ready. Automate the boring stuff, and get paid well to do it! 🚀

Practice

Reading is not learning until you run something. Pick one.

Open an example in Code Lab