(UPDATED: )

Threat Modeling

Threat Modeling is the practice of systematically identifying potential threats and their mitigations to protect something of value, and then presenting this information in an easily understandable way. It's a methodology for structuring all information that could affect the security of an application, system, or service, and then using that structure to identify security issues. I like to break down this process into the following main steps:

  • Decompose the Application: Identify assets and create various diagrams like DFDs and PFDs.
  • Identify Threats (Modeling): Identify and analyze threats.
  • Mitigate: Devise and apply mitigation strategies.
  • Validate: Confirm and verify the implemented measures.

Decompose the Application

This stage is all about clearly understanding what we need to protect. OWASP documentation recommends defining the following items:

AttributeDescription
Threat Model InformationDefine the threat modeling framework to be used (e.g., STRIDE).
External DependenciesDefine external dependencies that are outside of our direct control (e.g., external APIs, libraries).
Entry PointsDefine all entry points where users interact with the system (e.g., web pages, API endpoints). (+Trust Levels)
Exit PointsDefine exit points where data leaves the system (e.g., response data, log transmissions).
AssetsDefine the valuable assets that need protection (e.g., personal information, admin sessions, configuration files). (+Trust Levels)
Trust LevelsDefine the trust levels or trust boundaries for each component or data.
Data Flow DiagramsCreate Data Flow Diagrams (DFDs) to visualize the flow of data.

DFD (Data Flow Diagrams)

As the name suggests, a DFD is a diagram that illustrates the flow of data. While there can be slight differences depending on the modeling method, it generally focuses on representing the overall data flow within an application, system, or service.

OWASP DFD Example

PFD (Process Flow Diagrams)

A PFD is a diagram that represents the operational processes of an application. Unlike a DFD, it focuses on the service's operational flow, making it particularly useful for identifying scenarios that exploit business logic.

PFD Example

Other Diagrams

In addition to DFDs and PFDs, you can use various other diagrams that provide a comprehensive view of the system's overall architecture, trust boundaries, and network zones. This can be a great help in understanding the system's complex interactions and security context.

Security model of a system by Synopsis


Identify Threats

Once you've analyzed and understood the system, it's time to identify potential threats. Various modeling frameworks are used to systematically identify and classify threats. Each model offers a unique perspective, so it's effective to choose a model that fits the characteristics of the system being analyzed, or to use a combination of models.

STRIDE Model

STRIDE is a threat modeling framework developed by Microsoft, named as an acronym for six types of threats. It works by applying the STRIDE categories to each element (e.g., process, data flow) of a diagram like a DFD or PFD to identify threats and potential mitigations.

ThreatDescriptionDesired Property
SSpoofingAn attacker impersonates another user or component.Authenticity
TTamperingAn attacker modifies data exchanged between the system and users without authorization.Integrity
RRepudiationAn attacker denies having performed a malicious action.Non-repudiation
IInformation DisclosureAn attacker accesses sensitive data that the system transmits or stores without authorization.Confidentiality
DDenial of ServiceAn attacker degrades or disables the system's availability.Availability
EElevation of PrivilegeAn attacker gains higher privileges from a lower-privileged position to access unauthorized information.Authorization

STRIDE-per-interaction

This approach analyzes threats based on interactions. It is often preferred because it's more efficient in terms of time and resources than analyzing every single element.

STRIDE-per-element

This approach analyzes threats for each individual element (e.g., process, data store). It allows for a more detailed analysis but requires more effort.

DREAD Model

The DREAD model is used for quantitatively assessing the risk of each threat. While it's now often integrated into STRIDE or replaced by other risk assessment models, it still provides a useful perspective for prioritizing risks.

Risk CategoryDescription
DDamageHow much damage would an attack cause?
RReproducibilityHow easily can the attack be reproduced?
EExploitabilityHow much effort is required to launch the attack?
AAffected usersHow many users would be affected?
DDiscoverabilityHow easily can the vulnerability be discovered?

P.A.S.T.A. (Process for Attack Simulation and Threat Analysis)

PASTA is a 7-step, risk-centric methodology that analyzes threats from an attacker's perspective in alignment with business objectives.

StepDescription
1Define the ObjectivesDefine business and security objectives.
2Define the Technical ScopeDefine the technical scope of the analysis.
3Decompose the ApplicationAnalyze and break down the service.
4Analyze the ThreatsAnalyze threat intelligence.
5Vulnerability AnalysisAnalyze existing vulnerabilities.
6Attack AnalysisModel attack scenarios using identified threats and vulnerabilities.
7Risk and Impact AnalysisAnalyze risk and business impact, and develop mitigation strategies.

VAST (Visual, Agile, and Simple Threat)

VAST is a methodology focused on integration with Agile and DevOps processes. It aims to identify and respond to threats early in the development lifecycle, based on the application's process flows (PFD) and infrastructure configuration (DFD).


Mitigate

Threats and security vulnerabilities discovered through threat modeling must, of course, be mitigated or addressed. Discovered threats can be managed according to the following strategies:

  • Fix / Remediate: Resolve the threat directly by modifying code, strengthening security settings, or introducing new security technologies.
  • Remove: Eliminate the threat at its source by removing the feature or component causing it, if it is not essential.
  • Transfer: Transfer the risk associated with the threat to another party through insurance or third-party services (e.g., WAF, CDN).
  • Accept: If the business impact of the threat is low and the cost of mitigation is high, a decision may be made to accept the risk. In this case, the decision must be documented.

It's crucial to find the most appropriate action or mitigation strategy based on the system configuration and business requirements to reduce the threat level to a manageable range.


Validate

This is the final step to verify that the mitigations have been correctly applied and that the original threats have actually been alleviated. The following methods can be used:

  • Security Testing: Verify the effectiveness of mitigations from an attacker's perspective through methods like Penetration Testing and Fuzzing.
  • Secure Code Review: Review the modified code to ensure it doesn't introduce new vulnerabilities and complies with security standards.
  • Configuration Review: Check that the settings of the changed infrastructure or application are configured securely.
  • Regression Testing: Ensure that the security measures have not negatively impacted existing functionality.

Tools

Draw.io

If your goal is to draw diagrams, draw.io is an excellent choice. It's useful not just for threat modeling but also for creating flow charts, so it's a great tool to get familiar with.

OWASP Threat Dragon

This is an open-source threat modeling tool developed by OWASP. It supports the entire threat modeling process by providing features to draw diagrams like DFDs and to identify and manage threats based on STRIDE.

Resources

References