ratify

Framework Overview

This specification outlines a workflow of artifact verification which can be utilized by artifact consumers and provides a framework for the Notary project to be consumed by clients that consume these artifacts. The RATIFY framework enables composition of various verifiers and referrer stores to build verification framework into projects like GateKeeper. This framework serves as an orchestrator of various verifiers that are coordinated to get a consolidated verification result using a policy. This verification result can be used to make decisions in admission controllers at different stages like build, deployment or runtime like Kubernetes using OPA Gatekeeper.

This is a DRAFT specification and is a guidance for the prototype.

The framework defines concepts involved in the verification process and provides interfaces to them. The main concepts are referrer store, referrer provider, reference verifier , worlflow executor & policy engine. It uses plugin architecture to implement some of these concepts and thereby enables extensibility and interoperability to support both the existing and new emerging needs of the artifact verification problem. The different sections of this document describes each of these concepts in detail.

Glossary

Provider architecture

This framework will use a provider model for extensibility to support different types of stores & verifiers. It supports two types of providers.

Built-In/Internal providers are available in the source of the framework and are registered during startup using the init function. Referrer store using ORAS and signature verification using notaryv2 will be available as the built-in providers that are managed by the framework.

External/Plugin providers are external to the source and process of the framework. These providers will be registered as binaries that the framework will locate in the configured paths and execute as per the corresponding plugin specification. The following section outlines the plugin architecture used for supporting external providers into the framework.

Plugin architecture

This framework will use a plugin architecture to integrate custom stores & verifiers. Individual plugins can be registered by declaring them in the framework’s configuration.

Requirements

Open Questions

Artifact references

An artifact is defined by a manifest and identified by a reference as per the OCI {DNS/IP}/{Repository}:[name|digest]. A reference artifact is linked to another artifact through descriptor and enables forming a chain of artifacts as shown below. An artifact that has reference types is termed as subject against which verification can be triggered using this framework.

tree view of artifact hierarchy

This new way of defining reference types to artifacts and creating relationships is described in the spec. This framework queries for this graph of reference types artifacts for a subject to verify it. For existing systems that do not support these reference types, there will be storage wrappers that can adapt the corresponding supply chain objects as reference types. The advantage is to have a uniform data format that can be consumed by different components of the framework.

Example

Cosign signatures are stored as specially formatted tags that are queried using cosign libraries during verification. There will be an adapter that can represent these signatures as reference type on fly if exists, so that it can be consumed by the cosign verifier that is registered in the framework.

Referrer Store

A referrer store is an interface that defines the following capabilities

Sample Interface

type ReferrerStore interface {
 Name() string
 ListReferrers(ctx context.Context, subjectReference common.Reference, artifactTypes []string, nextToken string, subjectDesc *ocispecs.SubjectReference) (ListReferrersResult, error)
 // Used for small objects.
 GetBlobContent(ctx context.Context, subjectReference common.Reference, digest digest.Digest) ([]byte, error)
 GetReferenceManifest(ctx context.Context, subjectReference common.Reference, referenceDesc ocispecs.ReferenceDescriptor) (ocispecs.ReferenceManifest, error)
}

Requirements

Open Questions

Referrer Store Plugin and Framework contract specification

Referrer/Reference Provider

The framework can be configured with multiple referrer stores. A referrers provider provides a capability to query one or more underlying referrer stores to obtain a list of possible refererence artifacts of a particular artifact type. Given an artifact, a set of registered stores will be queried to retrieve all the references. Every reference will be associated with the details of the store it is retrieved from. This can be used to query further metadata related to a reference like manifest & blobs as part of verifying it.

Requirements

MatchingLables might become the construct that we chose to detemine which stores to query for references.

Sample interface

type ReferrerProvider interface {
 ListAllReferrers(ctx context.Context, subjectReference common.Reference, artifactTypes []string, nextToken string) (ListAllReferrersResult, error)
}

Open Questions

Reference Verifier

A reference verifier is an interface that defines the following capabilities

Sample Interface

type ReferenceVerifier interface {
 Name() string
 CanVerify(ctx context.Context, referenceDescriptor ocispecs.ReferenceDescriptor) bool
 Verify(ctx context.Context,
  subjectReference common.Reference,
  referenceDescriptor ocispecs.ReferenceDescriptor
  ) (VerifierResult, error)
}

Requirements

Open Questions

Reference Verifier Plugin & Framework contract specification

Executor

The executor is responsible for composing multiple verifiers with multiple stores to create a workflow of verification for an artifact. For a given subject, it fetches all referrers from multiple stores and ensures multiple verifiers can be chained and executed one after the other. It is also responsible for handling nested verification as required for some artifact types.

Sample Interface

type VerifyParameters struct {
 Subject        string   `json:"subjectReference"`
 ReferenceTypes []string `json:"referenceTypes,omitempty"`
}

type Executor interface {
 VerifySubject(ctx context.Context, verifyParameters VerifyParameters) (types.VerifyResult, error)
}

Requirements

Nested Verification

For some artifact types, nested verification MAY be required for hierarchical verification. For e.g. when verifying an SBOM, we first need to ensure that the attestation for SBOM is validated before validating the actual SBOM.

IMAGE
└── SBOM
    └── SIGNATURE

There could be a tree of references that needs to be traversed and verified before verifying a reference artifact. Verification of nested references creates a recursive process of verification within the workflow. The final verification result should include the results of each and every verifier that is invoked as part of nested verification.

Sample Data Flow for executor

Sample Data flow with gatekeeper

Open Questions

Models of executor

There are two different models of execution for the artifact verification.

Model 1: Standalone verifiers

In this model, every verifier that is registered with the framework is standalone and is responsible for complete verification process including query of references using the reference provider. The executor iterates through the registered verifiers in the given order and invokes each of them for verification of the subject. Every verifier will be invoked with the plugins configuration for the stores so that they can create a provider that helps with querying the reference types.

Pros

Cons

Model 2: Light weight verifiers

In this model, a verifier is only responsible for the verification of a reference. The executor will query for the references and walk them in the order of the registered verifiers. Some notable points are

Pros

Cons

Executor Policy Specification

The executor policy determines the chained outcome of execution of the multiple verifiers through the executor. The workflow with multiple stores & verifiers has different points of decisions that can be resolved using a policy.

Policy Engine

The framework will define interface for different decisions that govern the executor flow. A policy engine can implement this interface using different methodologies. It can be a simple configuration based engine that evaluates these decisions using the configuration parameters. For more advanced scenarios, the engine can offload the decision making to OPA.

Break Glass

For any kind of policy enforcement, it is recommended to do have dynamic overrides to support break glass scenarios in case of emergencies. This can be achieved by dynamically updating the policies for an engine at any point in time.

Common Decisions using Policies

For each of the decision queries, the following sections gives some examples of how to evaluate it using either configuration or OPA based policy engines.

Query 1: Is verify needed for this artifact?

This query can filter artifacts for which verification has to be triggered or skipped.

Example

As an incremental strategy of adopting container security, teams can choose to verify images from their private registries like ACR only.

policy:
    type: config
    artifactMatchingLabels: ["*.azurecr.io"]

OPA

policy:
    type: config
    rego: |
        package ratify.rules
        
        verify_artifact{
            regex.match(".+.azurecr.io$", input.subject)
        }
    

Query 2: Is verify needed for this reference of an artifact?

This query can filter references to artifacts based on the current state of the workflow and any other matching conditions.

Example

When an artifact has multiple signatures, teams can choose to ensure any one of them is valid. If the verification of one signature is success, teams can configure a policy to skip verification of all other signatures.

policy:
    type: config
    skipAfterFirstSuccess: ["org.cncf.notary.v2"]
policy:
    type: config
    rego: |
        package ratify.rules
        
        verify_reference{
            not input.reference.artifactType == "org.cncf.notary.v2"
        }
        
        verify_reference {
           not notary_success
        }
        
        notary_success{
            result := input.results[_]           
            result.artifactType ==  input.reference.artifactType
            result.isSuccess == "true"
        }
    

Query 3: Is this verifier in the workflow needed for this reference or artifact?

This query can help with customizing the verifiers in the workflow for a given reference or artifact.

Example

Teams can choose to skip vulnerability scan verifier for images from a private container registry but would like to enforce it for public registries like MCR.

policy:
    type: config
    skipVerifiers:
        - name : "scan"
          matchingArtifacts: ["*.azurecr.io"]
policy:
    type: config
    rego: |
        package ratify.rules
        
        default skip_verifier = false
        
        skip_verifier{
            input.verifier.name == "scan"
            regex.match("*.azurecr.io", input.subject)
        }
    

Query 4: Continue with the next step/task in the workflow? This covers decisions around ignoring any/specific failures from verifiers or stores

This query can help with customizing the flow of the workflow for a given reference or artifact based on multiple conditions.

Example 1

Teams can choose to continue verification even if certain verifiers fails with certain types(or all) of errors especially during testing or break glass scenarios.

policy:
    type: config
    continueOnErrors:
        - name : "notaryv2"
          errorCodes: ["CERT_EXPIRED"]
          matchingArtifacts: [*.azurecr.io]
policy:
    type: config
    rego: |
        package ratify.rules
        
        continue_workflow {
            not any_failed
        }        
        continue_workflow {
           is_cert_expired
        }
        any_failed {
         input.results[_].isSuccess == "false"
        }
        
        is_cert_expired {
            regex.match(".+.azurecr.io$", input.subject)
            result := input.results[_]
            input.verifier.name == "notaryv2"
            input.verifier.artifactTypes[_] == result.artifactType
            result.error.code == "CERT_EXPIRED"
        }
    

Example 2

Teams usually configure verifiers for different reference types. To invoke a verifier, the executor queries for the artifacts of type(s) that are configured for that verifier. If no artifacts of that type exist in the store, the executor can throw a well defined error REFERRERS_NOT_FOUND for example. By default, when a verifier is configured with the framework, the executor ensures that the corresponding artifact type should be present in the store else it fails the verification. However, teams can choose to ignore the absence of certain artifact types for a subject through a policy.

Configuration

policy:
    type: config
    continueOnErrors:
        - name : "sbom"
          errorCodes: ["REFERRERS_NOT_FOUND"]
          matchingArtifacts: [*.azurecr.io]

OPA

policy:
    type: config
    rego: |
        package ratify.rules
        
        continue_workflow {
            not any_failed
        }        
        continue_workflow {
           is_SBOMs_not_found_ACR
        }
        any_failed {
        	input.results[_].isSuccess == "false"
        }
        
        is_SBOMs_not_found_ACR {
            regex.match(".+.azurecr.io$", input.subject)
            result := input.results[_]
            input.verifier.name == "sbom"
            input.verifier.artifactTypes[_] == result.artifactType
            result.error.code == "REFERRERS_NOT_FOUND"
        }
    

Query 5: Determining the final outcome of the verification using the results from multiple verifiers

This query will help with consolidating the outcomes from all verifiers to an aggregated result that will be used in admission controllers

Example

Teams can choose to continue with k8s deployment even if the outcomes from certain verifiers are not successful. This is useful during experimentation or development phase and can also help with break glass scenarios. The below policy evaluates the final outcome as success even where there are errors from a particular verifier newverifier

policy:
    type: config
    ignoreFailuresForVerifiers : ["newverifier"]
policy:
    type: config
    rego: |
        package ratify.rules
        
        final_verification_success{
            not any_failed                        
        }
        
        final_verification_success{
            not other_verifier_failure         
        }
        
        any_failed {
           input.results[_].isSuccess == "false"
        }
        
        other_verifier_failure{
            some i
            input.results[i].isSuccess == "false"
            input.results[i].name != "newverifier"
        }    

Framework Configuration

The configuration for the framework includes multiple sections that allows configuring referrer stores, verifiers, executor and policy engine.

Referrer Store Configuration

The section stores encompasses the registration of multiple referrer stores to the framework. It includes two main properties

Property Type IsRequired Description
version string true The version of the API contract between the framework and the plugin.
plugins array true The array of store plugins that are registered with the framework.

A store will be registered as a plugin with the following configuration parameters

Property Type IsRequired Description
name string true The name of the plugin
pluginBinDirs array false The list of paths to look for the plugin binaries to execute. Default: the home path of the framework.

Any other parameters specified for a plugin other than the above mentioned are considered as opaque and will be passed to the plugin when invoked.

Verifier Configuration

The section verifiers encompasses the registration of multiple verifiers to the framework. It includes two main properties

Property Type IsRequired Description
version string true The version of the API contract between the framework and the plugin.
plugins array true The array of verifier plugins that are registered with the framework.

A verifier will be registered as a plugin with the following configuration parameters

Property Type IsRequired Description
name string true The name of the plugin
pluginBinDirs array false The list of paths to look for the plugin binary to execute. Default: the home path of the framework.
artifactTypes array true The list of artifact types for which this verifier plugin has to be invoked. [TBD] May change to matchingLabels
nestedReferences array false The list of artifact types for which this verifier should initiate nested verification. [TBD] This is subject to change as it is under review

Any other parameters specified for a plugin other than the above mentioned are considered as opaque and will be passed to the plugin when invoked.

Executor Configuration

The section executor defines the configuration of the framework executor component.

Property Type IsRequired Description
cache bool false Default: false. Determines if in-memory cache can be used to cache the executor outcomes for an artifact.
cacheExpiry string false Default: [TBD]. Determines the TTL for the executor cache item.

Policy Engine Configuration

The section policy defines the configuration of the policy engine used by the framework.

Open Questions

Sample Configuration

stores:
  version: 1.0.0
  plugins:
  - name: ociregistry
    useHttp: true
verifiers:
  version: 1.0.0
  plugins:
  - name: nv2verifier
    artifactTypes: application/vnd.cncf.notary.v2
    verificationCerts:
    - "/home/user/.notary/keys/wabbit-networks.crt"
  - name: sbom
    artifactTypes: application/x.example.sbom.v0
    nestedReferences: application/vnd.cncf.notary.v2
executor:
  cache: false
policy:
  type: opa
  policy: |
    package ratify.rules
        
        verify_artifact{
            regex.match(".+.azurecr.io$", input.subject)
        }