Threat modelling
1. Overview
Threat Modelling is a proactive, structured process for identifying and evaluating potential security threats and vulnerabilities in a system during its design phase. By thinking like an attacker before we write code, we can build more secure features from the ground up, reducing risk for Luna and our users.
This document outlines our approach to threat Modelling.
2. The Threat Modelling Handbook
For a comprehensive, industry-standard guide on the principles and techniques of threat Modelling, we refer to the OWASP Threat Modelling Cheat Sheet. It is a valuable resource for understanding different methodologies and best practices.
Reference Link: OWASP Threat Modelling Cheat Sheet
3. When to Threat Model on Luna
Threat Modelling is not required for every minor change, but it should be performed when the potential for introducing new security risks is high. A threat Modelling session should be considered a standard part of the design process for any of the following:
- New Features or Services: Any significant new feature, especially a new microservice or user-facing application.
- Significant Architectural Changes: When refactoring a service or changing how core components interact.
- Changes to Authentication or Authorisation: Any modification to login, session management, permissions, or access control logic.
- Introduction of New Sensitive Data: When a feature will handle new Personally Identifiable Information (PII), financial data, or other sensitive user content.
- Adding New Dependencies: When integrating a new third-party service or library, particularly for critical functions like payment processing or identity management.
- Creating or Modifying Public APIs: Any change to the endpoints that are exposed to the internet or third-party developers.
Rule of Thumb: If you are creating a design document for a feature, it's a strong indicator that you should also conduct a threat Modelling session.
4. How to Conduct a Threat Modelling Session
Our process is designed to be collaborative and efficient. A typical session involves developers, a security champion or security team member, and a product owner or QA engineer.
Step 1: Preparation (Before the Session)
- Gather Artifacts: The feature owner should bring a design document, user stories, and most importantly, a system diagram. A simple Data Flow Diagram (DFD) is ideal.
- The Diagram: Your diagram should clearly show:
- Processes: The services or components doing work (e.g., API Gateway, User Service, Database).
- External Entities: Users, browsers, or other systems that interact with your feature.
- Data Stores: Where data is saved (e.g., PostgreSQL DB, S3 Bucket, Redis Cache).
- Trust Boundaries: Lines drawn around components that have the same level of trust (e.g., a line separating your public-facing services from your internal-only database network).
Step 2: Deconstruct & Analyze (During the Session)
- Walkthrough: The feature owner explains the diagram and the flow of data through the system. For example, "A user sends a request to our API Gateway, which validates the JWT, then forwards the request to the User Service...".
- Identify Threats with STRIDE: For each part of the diagram (each process, data store, and data flow), the team brainstorms potential threats using the STRIDE methodology:
- Spoofing: Can an attacker pretend to be another user or service?
- Tampering: Can an attacker modify data in transit or at rest?
- Repudiation: Could a user deny having performed an action?
- Information Disclosure: Can an attacker access data they shouldn't?
- Denial of Service: Can an attacker crash or disable the service?
- Elevation of Privilege: Can an attacker gain higher permissions than they should have?
Step 3: Document & Mitigate (The Outcome)
- Capture Everything: Use a collaborative tool like Miro or a simple document to record all identified threats.
- Prioritise: For each threat, assign a risk rating (e.g., High, Medium, Low) based on its potential impact and likelihood.
- Define Mitigations: For each high or medium-risk threat, define a concrete mitigation plan. This could be adding input validation, changing an authentication mechanism, adding rate limiting, or implementing new logging.
- Create Tickets: The mitigation plans should be turned into actionable engineering tickets and added to the project backlog.
5. Example Outcome
The output of a threat Modelling session is a clear record of risks and the plan to address them. This allows the team to track progress and ensures accountability.
Example from a hypothetical "User Profile Update" feature:
| Threat ID | Threat Description | STRIDE Category | Risk | Mitigation Plan |
|---|---|---|---|---|
UP-T1 | An authenticated user can update another user's profile by guessing their ID. | Elevation of Privilege | High | Implement an ownership check in the updateProfile function. (Ticket: LI-1234) |
UP-T2 | User profile pictures are stored in a public S3 bucket with sequential names. | Information Disclosure | Med | Use non-sequential, randomly generated UUIDs for filenames. (Ticket: LI-1235) |
UP-T3 | A malicious user could submit a 10GB file as their profile picture. | Denial of Service | Med | Enforce a 5MB size limit on file uploads at the API gateway. (Ticket: LI-1236) |
Reference Board: 'Luna Kudos' Threat Model
