Threat Modeling and Risk Assessment

The $2.4M Security Breach We Didn't See Coming

October 15, 2020. 2:47 AM. My phone exploded with alerts.

"User data exposed. Elasticsearch cluster publicly accessible. 2.4 million customer records compromised."

The post-mortem was brutal. The vulnerability was embarrassingly simple: an Elasticsearch cluster deployed without authentication. The security team had never reviewed the architecture. Developers didn't know it was a risk. Nobody had asked: "What could go wrong with this design?"

The regulatory fines: $2.4 million. The customer trust lost: Incalculable. The lesson: Painful.

We had all the security toolsβ€”SAST, DAST, container scanning. But we never asked the most important question: "What are we protecting, and from whom?"

This breach taught me that security tools catch vulnerabilities in code, but threat modeling catches vulnerabilities in thinking. You can scan code all day, but if your architecture is fundamentally insecure, no amount of tooling will save you.

This article documents the threat modeling framework we built after that breachβ€”a systematic approach to identifying security risks before writing code. In the 3 years since implementing it, we haven't had a single architecture-level breach.

What You'll Learn

  • STRIDE threat modeling framework

  • Risk assessment and prioritization

  • Threat modeling for microservices

  • Data flow diagram analysis

  • Security requirements from threats

  • Integrating threat modeling into SDLC

What is Threat Modeling?

Threat modeling is structured thinking about security:

Why Threat Modeling Matters

Traditional security testing catches implementation bugs. Threat modeling catches design flaws.

spinner

Example:

  • SAST finds: SQL injection vulnerability in login code

  • Threat modeling finds: Login service lacks rate limiting, enabling brute force attacks

The STRIDE Threat Modeling Framework

STRIDE is a mnemonic for six threat categories, created by Microsoft:

Threat Modeling Process

Step 1: Diagram the System

Create a Data Flow Diagram (DFD) showing:

  • External entities (users, external systems)

  • Processes (services, functions)

  • Data stores (databases, caches)

  • Data flows (API calls, events)

  • Trust boundaries (security zones)

Example: E-Commerce Microservices Architecture

spinner

Step 2: Identify Threats Using STRIDE

For each component and each data flow, ask STRIDE questions:

Example: Payment Service Analysis

Component
STRIDE Category
Threat
Likelihood
Impact
Risk

Payment Service

Spoofing

Attacker impersonates payment service

Medium

Critical

High

Tampering

Order amount modified in transit

Low

Critical

Medium

Repudiation

Payment processed without audit trail

Low

High

Medium

Info Disclosure

Credit card data logged in plaintext

High

Critical

Critical

DoS

Service overwhelmed by requests

Medium

High

High

Elevation

Attacker gains admin access to payments

Low

Critical

High

Example: Data Flow Analysis (API Gateway β†’ Payment Service)

Step 3: Assess Risk

Use a risk matrix to prioritize threats:

Our Risk Matrix:

Step 4: Mitigate Threats

For each identified threat, choose a mitigation strategy:

Example Mitigations for Payment Service:

Threat
Mitigation
Implementation

Payment data disclosure

Encryption + Tokenization

Use Stripe tokens, never store cards

Service spoofing

Mutual TLS

mTLS between services

Amount tampering

Request signing

HMAC signature validation

DoS attacks

Rate limiting

10 req/sec per user

Missing audit trail

Comprehensive logging

Log all payment events to immutable store

Step 5: Validate Mitigations

After implementing mitigations, verify they work:

Real Example: Microservices Threat Model

Let me show you the actual threat model we created for our e-commerce platform.

System Overview

12 microservices, event-driven architecture:

Threat Model Session

Participants: Product Manager, Lead Architect, 2 Developers, Security Engineer, SRE

Duration: 3 hours

Output: 47 identified threats, 12 critical, 18 high priority

Critical Threats Found

Threat 1: Elasticsearch Public Exposure

Component: Analytics Service β†’ Elasticsearch Category: Information Disclosure Description: Elasticsearch cluster accessible from internet without authentication Impact: CRITICAL (2.4M customer records exposed) Likelihood: HIGH (default config, easy to exploit) Risk: CRITICAL

Mitigation:

Threat 2: Service-to-Service Authentication Missing

Component: Order Service β†’ Payment Service Category: Spoofing, Elevation of Privilege Description: Services communicate without authentication, any service can call payment Impact: CRITICAL (fraudulent payments) Likelihood: MEDIUM (requires compromised service) Risk: HIGH

Mitigation:

Threat 3: Payment Amount Tampering

Component: Cart Service β†’ Order Service β†’ Payment Service Category: Tampering Description: Attacker modifies cart total between services Impact: HIGH (financial loss) Likelihood: MEDIUM (requires intercepting service calls) Risk: HIGH

Mitigation:

Threat Model Document

We document all threats in a structured format:

Threat Modeling for Common Patterns

Pattern 1: API Gateway

Pattern 2: Message Queue

Pattern 3: Database

Integrating Threat Modeling into SDLC

When to Threat Model

spinner

Threat Modeling Checklist

Real Results

After implementing threat modeling:

The Elasticsearch breach cost us $2.4M. Threat modeling would have caught it in a 30-minute session.

Key Takeaways

βœ… Threat modeling finds design flaws that code scanning misses βœ… STRIDE framework provides systematic threat identification βœ… Fix in design is 100x cheaper than fixing in production βœ… 3-hour modeling session prevents months of incident response βœ… Include diverse participants - each perspective finds unique threats βœ… Make it routine - quarterly reviews catch architectural drift

What's Next

You now have the tools to identify threats in your architecture. The next phase of our DevSecOps journey covers application security testingβ€”starting with SAST (Static Application Security Testing) to catch vulnerabilities in your code.


Next Article: Static Application Security Testing (SAST) β†’


Part of the DevSecOps 101 Series

Last updated