Skip to content

Components

Design each component with its threats, interfaces, and access as code.

A component is the part of the software that one team designs, delivers, and runs on its own: its design models the threats that it faces and chooses the controls that counter them, declares the interfaces through which users and other components reach it, and decides what each user and component may do through them (see OWASP SAMM). Every component goes through the same stages, so every change to it keeps its threats, interfaces, and access up to date, whether a person or an agent makes it.

Stage Description
Assess Settle the threats that each component faces and the controls that counter them.
Specify Declare the interfaces that each component provides and keep them compatible.
Authorize Verify who is behind each request and what they may do.

The principles apply to the components themselves:

  • Everything as code: the threats, interfaces, and access of each component are files that change with its code.
  • Shift left: people and agents settle the threats, interfaces, and access of each change while they make it.
  • Zero trust: each component verifies who is behind every request and what they may do before it acts on it.

Users sign in through OpenID Connect with the users’ identity provider, and every request that a component serves for a user carries a short-lived OAuth 2.0 access token from it. A component that calls another one without a user proves its identity with its service account, which the environment verifies on every call. Trusting an identity that the gateway or the caller passes on is faster to start with, but lets one compromised component act as any user or component.

Each component keeps its design in its repository next to its code: its threats in an OWASP Threat Dragon model, its controls as OWASP ASVS requirements, its interfaces as OpenAPI documents and gRPC services, and its access in an OpenFGA authorization model. People and agents change the design in the same pull request as the code that it describes, and review both together. Keeping designs in a wiki is faster to start with, but lets them drift from the code that they describe.

The assess stage settles the threats that each component faces and the controls that counter them.

It applies Everything as code and Shift left and relies on Explicit interface: each component models its threats at the interfaces through which it’s reached, updates the model with each change that alters them, and covers each control with a test, a rule, or a policy of the platform.

Model the threats to each component with STRIDE in an OWASP Threat Dragon diagram of its interfaces, data stores, and trust boundaries. Update the model with each change that adds an interface, a data store, or a call across a trust boundary. Record a mitigation in the model for each threat, or open an issue for it in the component’s repository.

Choose the OWASP ASVS level of each component from the data that it handles and the users who can reach it, and list the requirements of that level that apply to it. Cover each requirement and each mitigation in its threat model with a test of the component, a rule of the shared rulesets, or a policy that the platform enforces.

The specify stage declares the interfaces that each component provides and keeps them compatible.

It applies Everything as code and Shift left and relies on Explicit interface: each interface is a specification in its component’s repository, checked where each change is made, and each change to it stays compatible with its consumers, so its component deploys and rolls back on its own.

Declare every interface of each component that users reach as an OpenAPI document, and every interface that only other components call as a gRPC service, each with the schemas of its requests and responses and the scopes that each operation requires. Register each specification in the Backstage software catalog as an API that the component provides. Lint each OpenAPI document with Spectral and each gRPC service with Buf, against the shared rulesets. Generate the component’s server interfaces and its consumers’ clients from each OpenAPI document with OpenAPI Generator and from each gRPC service with Buf.

Keep each change to an interface backward compatible, and check each gRPC service for breaking changes with Buf. Ship each breaking change as a new major version of the interface, and serve it beside the old one. Mark the operations of each old version as deprecated in its specification, and remove them once no consumer’s contract in the Pact broker uses them and the component’s metrics show no calls to them.

The authorize stage verifies who is behind each request and what they may do.

It applies Everything as code, Shift left, and Zero trust and relies on Explicit interface and External state: each component authenticates every request at its interface rather than trusting its caller, and authorizes it using the user relations that a backing service holds and the authorization model and grants from its repository, tested where each change is made.

For each user request, validate that its OAuth 2.0 access token was issued for the component and has the scopes that the operation requires. For each call to another component on behalf of the user, exchange the token through OAuth 2.0 token exchange for one issued for that component. For each request without a user, take the caller’s identity from the service account that the environment verified for it.

Declare in an OpenFGA authorization model how users and other components can use the resources of each component. Declare next to it the access that the component grants to each of its consumers. Test the allowed and denied cases of the model with the OpenFGA CLI on each change, and require a person from the owning team to approve each change to the authorization model and its grants. On each deployment, write both from the component to its own OpenFGA store, which the platform offers as a backing service. Write the relations of its users to the store from the component as its resources change. Check each request against the store in the component, and act on it only when the store allows it.

Frameworks:

Standards:

Code tools:

Platform tools: