.nh .TH CONTAINERS-POLICY.JSON 5 policy.json Man Page Miloslav Trmač September 2016 .SH NAME .PP containers-policy.json - syntax for the signature verification policy file .SH DESCRIPTION .PP Signature verification policy files are used to specify policy, e.g. trusted keys, applicable when deciding whether to accept an image, or individual signatures of that image, as valid. .PP By default, the policy is read from \fB$HOME/.config/containers/policy.json\fR, if it exists, otherwise from \fB/etc/containers/policy.json\fR; applications performing verification may allow using a different policy instead. .SH FORMAT .PP The signature verification policy file, usually called \fBpolicy.json\fR, uses a JSON format. Unlike some other JSON files, its parsing is fairly strict: unrecognized, duplicated or otherwise invalid fields cause the entire file, and usually the entire operation, to be rejected. .PP The purpose of the policy file is to define a set of \fIpolicy requirements\fP for a container image, usually depending on its location (where it is being pulled from) or otherwise defined identity. .PP Policy requirements can be defined for: .RS .IP \(bu 2 An individual \fIscope\fP in a \fItransport\fP\&. The \fItransport\fP values are the same as the transport prefixes when pushing/pulling images (e.g. \fBdocker:\fR, \fBatomic:\fR), and \fIscope\fP values are defined by each transport; see below for more details. .RE .PP Usually, a scope can be defined to match a single image, and various prefixes of such a most specific scope define namespaces of matching images. .RS .IP \(bu 2 A default policy for a single transport, expressed using an empty string as a scope .IP \(bu 2 A global default policy. .RE .PP If multiple policy requirements match a given image, only the requirements from the most specific match apply, the more general policy requirements definitions are ignored. .PP This is expressed in JSON using the top-level syntax .EX { "default": [/* policy requirements: global default */] "transports": { transport_name: { "": [/* policy requirements: default for transport $transport_name */], scope_1: [/* policy requirements: default for $scope_1 in $transport_name */], scope_2: [/*…*/] /*…*/ }, transport_name_2: {/*…*/} /*…*/ } } .EE .PP The global \fBdefault\fR set of policy requirements is mandatory; all of the other fields (\fBtransports\fR itself, any specific transport, the transport-specific default, etc.) are optional. .SH Supported transports and their scopes .PP See containers-transports(5) for general documentation about the transports and their reference syntax. .SS \fBatomic:\fR .PP The deprecated \fBatomic:\fR transport refers to images in an Atomic Registry. .PP Supported scopes use the form \fIhostname\fP[\fB:\fR\fIport\fP][\fB/\fR\fInamespace\fP[\fB/\fR\fIimagestream\fP [\fB:\fR\fItag\fP]]], i.e. either specifying a complete name of a tagged image, or prefix denoting a host/namespace/image stream, or a wildcarded expression starting with \fB*.\fR for matching all subdomains. For wildcarded subdomain matching, \fB*.example.com\fR is a valid case, but \fBexample*.*.com\fR is not. .PP \fINote:\fP The \fIhostname\fP and \fIport\fP refer to the container registry host and port (the one used e.g. for \fBdocker pull\fR), \fInot\fP to the OpenShift API host and port. .SS \fBcontainers-storage:\fR .PP Supported scopes have the form \fB[\fR\fIstorage-specifier\fP\fB]\fR\fIimage-scope\fP\&. .PP \fB[\fR\fIstorage-specifier\fP\fB]\fR is usually \fB[\fR\fIgraph-driver-name\fP\fB@\fR\fIgraph-root\fP\fB]\fR, e.g. \fB[overlay@/var/lib/containers/storage]\fR\&. .PP \fIimage-scope\fP matching the individual image is - a named Docker reference \fIin the fully expanded form\fP, either using a tag or digest. For example, \fBdocker.io/library/busybox:latest\fR (\fInot\fP \fBbusybox:latest\fR) - and/or (depending on which one the user’s input provides) \fB@\fR\fIimage-id\fP .PP More general scopes are prefixes of individual-image scopes, and specify a less-precisely-specified image, or a repository (by omitting first the image ID, if any; then the digest, if any; and finally a tag, if any), a repository namespace, or a registry host (by only specifying the host name and possibly a port number). .PP Finally, two full-store specifiers matching all images in the store are valid scopes: - \fB[\fR\fIgraph-driver-name\fP\fB@\fR\fIgraph-root\fP\fB]\fR and - \fB[\fR\fIgraph-root\fP\fB]\fR .PP Note that some tools like Podman and Buildah hard-code overrides of the signature verification policy for “push” operations, allowing these operations regardless of configuration in \fBpolicy.json\fR\&. .SS \fBdir:\fR .PP The \fBdir:\fR transport refers to images stored in local directories. .PP Supported scopes are paths of directories (either containing a single image or subdirectories possibly containing images). .PP \fINote:\fP - The paths must be absolute and contain no symlinks. Paths violating these requirements may be silently ignored. - The top-level scope \fB"/"\fR is forbidden; use the transport default scope \fB""\fR, for consistency with other transports. .SS \fBdocker:\fR .PP The \fBdocker:\fR transport refers to images in a registry implementing the "Docker Registry HTTP API V2". .PP Scopes matching individual images are named Docker references \fIin the fully expanded form\fP, either using a tag or digest. For example, \fBdocker.io/library/busybox:latest\fR (\fInot\fP \fBbusybox:latest\fR). .PP More general scopes are prefixes of individual-image scopes, and specify a repository (by omitting the tag or digest), a repository namespace, or a registry host (by only specifying the host name and possibly a port number) or a wildcarded expression starting with \fB*.\fR, for matching all subdomains (not including a port number). For wildcarded subdomain matching, \fB*.example.com\fR is a valid case, but \fBexample*.*.com\fR is not. .SS \fBdocker-archive:\fR .PP Only the default \fB""\fR scope is supported. .SS \fBdocker-daemon:\fR .PP For references using the \fIalgo:digest\fP format (referring to an image ID), only the default \fB""\fR scope is used. .PP For images using a named reference, scopes matching individual images are \fIin the fully expanded form\fP, either using a tag or digest. For example, \fBdocker.io/library/busybox:latest\fR (\fInot\fP \fBbusybox:latest\fR). .PP More general named scopes are prefixes of individual-image scopes, and specify a repository (by omitting the tag or digest), a repository namespace, or a registry host (by only specifying the host name and possibly a port number) or a wildcarded expression starting with \fB*.\fR, for matching all subdomains (not including a port number). For wildcarded subdomain matching, \fB*.example.com\fR is a valid case, but \fBexample*.*.com\fR is not. .SS \fBoci:\fR .PP The \fBoci:\fR transport refers to images in directories compliant with "Open Container Image Layout Specification". .PP Supported scopes are paths to directories (either containing an OCI layout, or subdirectories possibly containing OCI layout directories). The \fIreference\fP annotation value, if any, is not used. .PP \fINote:\fP - The paths must be absolute and contain no symlinks. Paths violating these requirements may be silently ignored. - The top-level scope \fB"/"\fR is forbidden; use the transport default scope \fB""\fR, for consistency with other transports. .SS \fBoci-archive:\fR .PP Supported scopes are paths to OCI archives, and their parent directories (either containing a single archive, or subdirectories possibly containing archives). The \fIreference\fP annotation value, if any, is not used. .PP \fINote:\fP - The paths must be absolute and contain no symlinks. Paths violating these requirements may be silently ignored. - The top-level scope \fB"/"\fR is forbidden; use the transport default scope \fB""\fR, for consistency with other transports. .SS \fBostree\fR: .PP Supported scopes have the form \fIrepo-path\fP\fB:\fR\fIimage-scope\fP; _repo\fIpath\fP is the path to the OSTree repository. .PP \fIimage-scope\fP is the _docker\fIreference\fP part of the reference, with with a \fB:latest\fR tag implied if no tag is present, and parent namespaces of the _docker\fIreference\fP value (by omitting the tag, or a prefix specifying a higher-level namespace). .PP \fINote:\fP - The _repo\fIpath\fP must be absolute and contain no symlinks. Paths violating these requirements may be silently ignored. .SS \fBsif:\fR .PP Supported scopes are paths to Singularity images, and their parent directories (either containing images, or subdirectories possibly containing images). .PP \fINote:\fP - The paths must be absolute and contain no symlinks. Paths violating these requirements may be silently ignored. - The top-level scope \fB"/"\fR is forbidden; use the transport default scope \fB""\fR, for consistency with other transports. .SS \fBtarball:\fR .PP The \fBtarball:\fR transport is an implementation detail of some import workflows. Only the default \fB""\fR scope is supported. .SH Policy Requirements .PP Using the mechanisms above, a set of policy requirements is looked up. The policy requirements are represented as a JSON array of individual requirement objects. For an image to be accepted, \fIall\fP of the requirements must be satisfied simultaneously. .PP The policy requirements can also be used to decide whether an individual signature is accepted (= is signed by a recognized key of a known author); in that case some requirements may apply only to some signatures, but each signature must be accepted by \fIat least one\fP requirement object. .PP The following requirement objects are supported: .SS \fBinsecureAcceptAnything\fR .PP A simple requirement with the following syntax .EX {"type":"insecureAcceptAnything"} .EE .PP This requirement accepts any image (but note that other requirements in the array still apply). .PP When deciding to accept an individual signature, this requirement does not have any effect; it does \fInot\fP cause the signature to be accepted, though. .PP This is useful primarily for policy scopes where no signature verification is required; because the array of policy requirements must not be empty, this requirement is used to represent the lack of requirements explicitly. .SS \fBreject\fR .PP A simple requirement with the following syntax: .EX {"type":"reject"} .EE .PP This requirement rejects every image, and every signature. .SS \fBsignedBy\fR .PP This requirement requires an image to be signed using “simple signing” with an expected identity, or accepts a signature if it is using an expected identity and key. .EX { "type": "signedBy", "keyType": "GPGKeys", /* The only currently supported value */ "keyPath": "/path/to/local/keyring/file", "keyPaths": ["/path/to/local/keyring/file1","/path/to/local/keyring/file2"…], "keyData": "base64-encoded-keyring-data", "signedIdentity": identity_requirement } .EE .PP Exactly one of \fBkeyPath\fR, \fBkeyPaths\fR and \fBkeyData\fR must be present, containing a GPG keyring of one or more public keys. Only signatures made by these keys are accepted. .PP The \fBsignedIdentity\fR field, a JSON object, specifies what image identity the signature claims about the image. One of the following alternatives are supported: .RS .IP \(bu 2 The identity in the signature must exactly match the image identity. Note that with this, referencing an image by digest (with a signature claiming a \fIrepository\fP\fB:\fR\fItag\fP identity) will fail. .RE .EX {"type":"matchExact"} .EE .RS .IP \(bu 2 If the image identity carries a tag, the identity in the signature must exactly match; if the image identity uses a digest reference, the identity in the signature must be in the same repository as the image identity (using any tag). .RE .PP (Note that with images identified using digest references, the digest from the reference is validated even before signature verification starts.) .EX {"type":"matchRepoDigestOrExact"} .EE .RS .IP \(bu 2 The identity in the signature must be in the same repository as the image identity. This is useful e.g. to pull an image using the \fB:latest\fR tag when the image is signed with a tag specifying an exact image version. .RE .EX {"type":"matchRepository"} .EE .RS .IP \(bu 2 The identity in the signature must exactly match a specified identity. This is useful e.g. when locally mirroring images signed using their public identity. .RE .EX { "type": "exactReference", "dockerReference": docker_reference_value } .EE .RS .IP \(bu 2 The identity in the signature must be in the same repository as a specified identity. This combines the properties of \fBmatchRepository\fR and \fBexactReference\fR\&. .RE .EX { "type": "exactRepository", "dockerRepository": docker_repository_value } .EE .RS .IP \(bu 2 Prefix remapping: .RE .PP If the image identity matches the specified prefix, that prefix is replaced by the specified “signed prefix” (otherwise it is used as unchanged and no remapping takes place); matching then follows the \fBmatchRepoDigestOrExact\fR semantics documented above (i.e. if the image identity carries a tag, the identity in the signature must exactly match, if it uses a digest reference, the repository must match). .PP The \fBprefix\fR and \fBsignedPrefix\fR values can be either host[:port] values (matching exactly the same host[:port], string), repository namespaces, or repositories (i.e. they must not contain tags/digests), and match as prefixes \fIof the fully expanded form\fP\&. For example, \fBdocker.io/library/busybox\fR (\fInot\fP \fBbusybox\fR) to specify that single repository, or \fBdocker.io/library\fR (not an empty string) to specify the parent namespace of \fBdocker.io/library/busybox\fR==\fBbusybox\fR). .PP The \fBprefix\fR value is usually the same as the scope containing the parent \fBsignedBy\fR requirement. .EX { "type": "remapIdentity", "prefix": prefix, "signedPrefix": prefix, } .EE .PP If the \fBsignedIdentity\fR field is missing, it is treated as \fBmatchRepoDigestOrExact\fR\&. .PP \fINote\fP: \fBmatchExact\fR, \fBmatchRepoDigestOrExact\fR and \fBmatchRepository\fR can be only used if a Docker-like image identity is provided by the transport. In particular, the \fBdir:\fR and \fBoci:\fR transports can be only used with \fBexactReference\fR or \fBexactRepository\fR\&. .SS \fBsigstoreSigned\fR .PP This requirement requires an image to be signed using a sigstore signature with an expected identity and key. .EX { "type": "sigstoreSigned", "keyPath": "/path/to/local/public/key/file", "keyData": "base64-encoded-public-key-data", "fulcio": { "caPath": "/path/to/local/CA/file", "caData": "base64-encoded-CA-data", "oidcIssuer": "https://expected.OIDC.issuer/", "subjectEmail", "expected-signing-user@example.com", }, "rekorPublicKeyPath": "/path/to/local/public/key/file", "rekorPublicKeyData": "base64-encoded-public-key-data", "signedIdentity": identity_requirement } .EE .PP Exactly one of \fBkeyPath\fR, \fBkeyData\fR and \fBfulcio\fR must be present. .PP If \fBkeyPath\fR or \fBkeyData\fR is present, it contains a sigstore public key. Only signatures made by this key are accepted. .PP If \fBfulcio\fR is present, the signature must be based on a Fulcio-issued certificate. One of \fBcaPath\fR and \fBcaData\fR must be specified, containing the public key of the Fulcio instance. Both \fBoidcIssuer\fR and \fBsubjectEmail\fR are mandatory, exactly specifying the expected identity provider, and the identity of the user obtaining the Fulcio certificate. .PP At most one of \fBrekorPublicKeyPath\fR and \fBrekorPublicKeyData\fR can be present; it is mandatory if \fBfulcio\fR is specified. If a Rekor public key is specified, the signature must have been uploaded to a Rekor server and the signature must contain an (offline-verifiable) “signed entry timestamp” proving the existence of the Rekor log record, signed by the provided public key. .PP The \fBsignedIdentity\fR field has the same semantics as in the \fBsignedBy\fR requirement described above. Note that \fBcosign\fR-created signatures only contain a repository, so only \fBmatchRepository\fR and \fBexactRepository\fR can be used to accept them (and that does not protect against substitution of a signed image with an unexpected tag). .PP To use this with images hosted on image registries, the \fBuse-sigstore-attachments\fR option needs to be enabled for the relevant registry or repository in the client's containers-registries.d(5). .SH Examples .PP It is \fIstrongly\fP recommended to set the \fBdefault\fR policy to \fBreject\fR, and then selectively allow individual transports and scopes as desired. .SS A reasonably locked-down system .PP (Note that the \fB/*\fR…\fB*/\fR comments are not valid in JSON, and must not be used in real policies.) .EX { "default": [{"type": "reject"}], /* Reject anything not explicitly allowed */ "transports": { "docker": { /* Allow installing images from a specific repository namespace, without cryptographic verification. This namespace includes images like openshift/hello-openshift and openshift/origin. */ "docker.io/openshift": [{"type": "insecureAcceptAnything"}], /* Similarly, allow installing the “official” busybox images. Note how the fully expanded form, with the explicit /library/, must be used. */ "docker.io/library/busybox": [{"type": "insecureAcceptAnything"}], /* Allow installing images from all subdomains */ "*.temporary-project.example.com": [{"type": "insecureAcceptAnything"}], /* A sigstore-signed repository */ "hostname:5000/myns/sigstore-signed-with-full-references": [ { "type": "sigstoreSigned", "keyPath": "/path/to/sigstore-pubkey.pub" } ], /* A sigstore-signed repository using the community Fulcio+Rekor servers. The community servers’ public keys can be obtained from https://github.com/sigstore/sigstore/tree/main/pkg/tuf/repository/targets . */ "hostname:5000/myns/sigstore-signed-fulcio-rekor": [ { "type": "sigstoreSigned", "fulcio": { "caPath": "/path/to/fulcio_v1.crt.pem", "oidcIssuer": "https://github.com/login/oauth", "subjectEmail": "test-user@example.com" }, "rekorPublicKeyPath": "/path/to/rekor.pub", } ], /* A sigstore-signed repository, accepts signatures by /usr/bin/cosign */ "hostname:5000/myns/sigstore-signed-allows-malicious-tag-substitution": [ { "type": "sigstoreSigned", "keyPath": "/path/to/sigstore-pubkey.pub", "signedIdentity": {"type": "matchRepository"} } ], /* A sigstore-signed repository using the community Fulcio+Rekor servers, accepts signatures by /usr/bin/cosign. The community servers’ public keys can be obtained from https://github.com/sigstore/sigstore/tree/main/pkg/tuf/repository/targets . */ "hostname:5000/myns/sigstore-signed-fulcio-rekor- allows-malicious-tag-substitution": [ { "type": "sigstoreSigned", "fulcio": { "caPath": "/path/to/fulcio_v1.crt.pem", "oidcIssuer": "https://github.com/login/oauth", "subjectEmail": "test-user@example.com" }, "rekorPublicKeyPath": "/path/to/rekor.pub", "signedIdentity": { "type": "matchRepository" } } ] /* Other docker: images use the global default policy and are rejected */ }, "dir": { "": [{"type": "insecureAcceptAnything"}] /* Allow any images originating in local directories */ }, "atomic": { /* The common case: using a known key for a repository or set of repositories */ "hostname:5000/myns/official": [ { "type": "signedBy", "keyType": "GPGKeys", "keyPath": "/path/to/official-pubkey.gpg" } ], /* A more complex example, for a repository which contains a mirror of a third-party product, which must be signed-off by local IT */ "hostname:5000/vendor/product": [ { /* Require the image to be signed by the original vendor, using the vendor's repository location. */ "type": "signedBy", "keyType": "GPGKeys", "keyPath": "/path/to/vendor-pubkey.gpg", "signedIdentity": { "type": "exactRepository", "dockerRepository": "vendor-hostname/product/repository" } }, { /* Require the image to _also_ be signed by a local reviewer. */ "type": "signedBy", "keyType": "GPGKeys", "keyPath": "/path/to/reviewer-pubkey.gpg" } ], /* A way to mirror many repositories from a single vendor */ "private-mirror:5000/vendor-mirror": [ { /* Require the image to be signed by the original vendor, using the vendor's repository location. For example, private-mirror:5000/vendor-mirror/productA/image1:latest needs to be signed as vendor.example/productA/image1:latest . */ "type": "signedBy", "keyType": "GPGKeys", "keyPath": "/path/to/vendor-pubkey.gpg", "signedIdentity": { "type": "remapIdentity", "prefix": "private-mirror:5000/vendor-mirror", "signedPrefix": "vendor.example.com" } } ] } } } .EE .SS Completely disable security, allow all images, do not trust any signatures .EX { "default": [{"type": "insecureAcceptAnything"}] } .EE .SH SEE ALSO .PP atomic(1) .SH HISTORY .PP August 2018, Rename to containers-policy.json(5) by Valentin Rothberg vrothberg@suse.com \[la]mailto:vrothberg@suse.com\[ra] .PP September 2016, Originally compiled by Miloslav Trmač mitr@redhat.com \[la]mailto:mitr@redhat.com\[ra]