Skip to content

Quick start

To get the most out of this catalogue, it's important to understand how it is structured. The catalogue essentially consists of three levels: the context level, the problem level, and the pattern (solution) level.

Context

The context describes possible configurations in which software elements can interact with each other and their environment.

Throughout this catalogue we represent a system and its environment as a set of entities that interact by exchanging actions and/or data via channels. These concepts are explained in detail in the metamodel. For now, it suffices to remember the following:

  • An entity is an active element that can execute actions as well as send and/or receive data. It covers a broad range of concepts such as an individual program, a web application, an API server, an OS process, a (distributed) system as a whole, but also human users.
  • An action is a logical operation provided by an entity and requested by another. For example, the operations of an API are actions that are provided by the underlying entity. Actions may have parameters.
  • A data element represents a symbolic element that can be interpreted by entities, e.g. a string of characters, a number, or a PDF document. When requesting an action, the supplied arguments are data elements.
  • A channel is any connection between two or more entities via which they can communicate (i.e., exchange actions or data), e.g. a network connection, a Unix pipe, or a computer screen. A channel can be an abstraction of lower-level entities and actions that you do not want to consider separately.

The catalogue contains multiple contexts, but they are related to each other. The root context is an interaction between two entities, one of which is your system.

The system interacts with an entity.

There are several refinements of this root context, for example one where your system receives an action from an entity that is not under your control (e.g., a web client), or one where your system receives an action over a channel that you do not control (e.g., a public WiFi network). Of course, both of these can apply at the same time. In that case, you should repeat the next steps for each of the sub-contexts that you deem relevant.

Tip

Start by identifying all points where your system interacts with other entities, as well as the corresponding actions and channels, and map your findings to contexts in the catalogue.

This guide will continue with the context execute action request from an uncontrolled entity, which applies for example when you build a REST API server that accepts requests from several (untrusted) clients.

From context to problem

Each context comes with a set of potential problems attached to it. In the example context from before, the catalogue presents three specific problems to think about (in addition to a spoofing problem associated to the root context):

  1. The entity may request an action which it is not allowed to request
  2. The request may lead to excessive resource consumption
  3. The entity may repudiate ever requesting the action

The problem layer of the catalogue provides more elaborate descriptions for each of these problems and their possible consequences.

Tip

For each context that you have identified, consider the associated problems. For each relevant problem that requires attention, continue with the next step to find a suitable solution.

Let's continue with the first of these three problems: request an action which that is not allowed.

From problem to pattern

If we decide that this problem needs to be addressed (which for a REST API server is almost certainly the case), we observe that the catalogue provides a solution for this problem in the form of an Authorisation pattern.

Tip

Use the catalogue to find patterns that address the problems you have identified.

Sometimes, more than one alternative may be available. For this example, however, there is only one. Always keep in mind that this catalogue (just like any security resource) has no completeness guarantees. Other valid solutions for your problem may exist, but think very carefully before adopting one — especially if you know of no other situation where that solution has been applied before.

Understanding a pattern

All patterns in this catalogue adhere to the same template. This template can roughly be divided in three parts:

  1. Meta-data about the pattern (name, summary, place in the catalogue, etc.)
  2. Information to correctly understand and apply the solution contained in the pattern
  3. References to other knowledge (related patterns, literature, etc.)

The first and third parts should be self-explanatory, especially if you've already seen other software design patterns (e.g., those from the famous Gang of Four book).

Solution

Looking at the solution part, and taking the Authorisation pattern as an example, we see that the solution is composed of roles, actions, data elements, and behaviour, which is slightly different from what you may be used to. Behaviour of the authorisation pattern

Roles

The roles of the pattern are the entities that are involved in the pattern. For example, the Authorisation pattern has five roles: a Subject that wants to access a resource, the System that manages that resource, an Enforcer that ensures unauthorised subjects do not gain access to the resource, a Decider to make a decision on which requests are (un)authorised, and a Policy provider that manages the current set of policy rules.

It's important to realise that this catalogue does not prescribe how you should structure your software, but only conveys the security aspects of the solutions. Therefore, different roles are not necessarily distinct software elements such as objects, classes, modules, or components. Rather, think of them as responsibilities that must be realised by the implementation of concrete software elements.

The catalogue distinguishes certain entity types that occur repeatedly across security solutions. For example, an enforcement point (the Enforcer in the example) is responsible for enforcing security-sensitive decisions (e.g., allowing or disallowing an action, refusing ill-formed data, ...). These decisions are made by a decision point (the Decider) based on a policy managed by an information point (the Policy provider).

Actions

Actions are what entities (roles) use to collaborate. An action can have arguments and may be bi-directional, in which case it returns something after being executed. In the Authorisation pattern, the main ones are the action that the subject wants to perform on the resource, an authorise action to determine if the request is allowed, and a get_privileges action to retrieve the current policy and privileges.

Just like entities do not necessarily correspond to software elements, actions are not the same as methods and functions in your software. This means that correct instances of this authorisation pattern somehow need to perform these actions, but how that happens is up to you. Perhaps you have to convert them into methods; or perhaps the framework that you use can execute some of these actions automatically based on annotations or configuration files. Whatever the case, make sure that you know if, where, how, and when each of these actions happens in your software system.

Data elements

Data elements denote the main types of data that are involved in the pattern. They occur as arguments of actions and in reply messages. For the Authorisation pattern, important data types include the identifier of the action, the resource (object), and the principal (subject). You can probably guess by now that data elements are not (necessarily) the same as the data types in your software.

Behaviour

The behavioural part of the description indicates how the above building blocks (entities, actions, data elements) work together. The behaviour is explained by means of a picture that somewhat resembles an UML Communication Diagram, using numbers to convey sequence information.

Considerations

The roles, actions, data elements and behaviour describe the security pattern's building blocks and their main interactions. Nevertheless, there are additional (sometimes subtle) considerations and assumptions that are needed to ensure that the pattern truly resolves the problem it's supposed to resolve. These considerations are mentioned in dedicated sections of the pattern description. Make sure to carefully check them; ignoring a single one could jeopardise the security of the whole solution.

For the Authorisation pattern that we're looking at, the pattern description mentions several considerations. For example, the enforcer should only be used on authenticated requests, as access decisions rely on the subject's identity (principal). Authentication is not solved in this pattern, but in another. Furthermore, adhering to the "security by default" principle, the default decision should be to deny the request, unless the policy says otherwise. Also, because the enforcer, decider, and policy provider are involved in every request, they may become a bottleneck and target of a denial of service. This refers to another problem in the catalogue that you should consider. It's also crucial that adversaries cannot tamper with the policy itself. Finally, while the solution of the pattern already prescribes to take into account the ObjectID when making authorisation decisions, a consideration is added to emphasise the importance of this. Indeed, forgetting to check whether the subject has access to that particular ObjectID is the cause of an Insecure Direct Object Reference (or IDOR), number one of the API security top 10 flaws in 2019.

Tip

  • Keep in mind that these patterns describe the security-specific aspects of the solutions, not the most appropriate software design. That is, roles should not automatically become distinct classes or modules, and actions should not necessarily become method calls.
  • The considerations in the patterns are important, and often lead you to a related context, problem, or solution. Make sure to carefully inspect them.

What's next

You now have a good idea on how this security pattern catalogue is structured and how you can use it. A good next step is to take the software project you're currently working on and try to locate contexts from this catalogue. Once you found these, check if you addressed the associated security problems, and (if so), whether you can recognise the different roles, actions, data types and behaviours from one of the associated patterns. Finally, go over the considerations.

Just like all design patterns, you will eventually internalise these patterns and no longer need to consult the catalogue to decide what to instantiate when. Yet it's recommended to regularly check the description again, or turn it into a checklist, to make sure you didn't overlook any of the considerations.


Last update: January 13, 2022