OCI registries#
shirudo delivers packages and upatch trees through OCI registries, the
servers that also hold container images. This page explains what a
registry stores and how a client talks to it, and then which parts of
what shirudo bpm fetches are signed and which are only
content-addressed.
Why a registry#
A target has to fetch signed artifacts from somewhere. A dedicated update server would be one more service to build, authenticate and keep available, and a plain web server has no notion of versions or of immutable content. Most organizations already run an OCI registry, or rent one, with access control, replication and mirrors in place.
We do not trust the registry. Whoever controls it, or the network path to it, can change what it serves. Everything that decides what a target loads is therefore either signed with the operator’s key or named by a digest inside something signed.
Manifests, configs and layers#
An image manifest, media type
application/vnd.oci.image.manifest.v1+json, names a config blob
and a list of layers. Each entry is a descriptor: a mediaType
that says what the blob is, its digest and size, and optional
annotations such as org.opencontainers.image.title. In a
container image the config holds runtime settings and the layers are
file system archives. Because the manifest names each blob by digest,
the manifest’s own digest pins everything it references.
An image index, application/vnd.oci.image.index.v1+json, is a
manifest of manifests, used mostly to publish one image for several
platforms under one tag. shirudo bpm reads image manifests only.
Version 1.1 of the image specification describes how to store content
other than container images. artifactType names the kind of
artifact. When there is no configuration to store, the config
descriptor points at the two-byte blob {} with media type
application/vnd.oci.empty.v1+json, and artifactType is then
required. A manifest can also name another manifest as its
subject; registries list such referrers, for example a signature,
through the referrers API.
Talking to a registry#
The Distribution Specification is an HTTP API under /v2/. A client
pulls a manifest with GET /v2/<name>/manifests/<reference>, where
the reference is a tag or a digest. It pulls a blob with
GET /v2/<name>/blobs/<digest>, which registries often redirect to
object storage. To push a blob, it opens an upload with
POST /v2/<name>/blobs/uploads/ and sends the bytes with a PUT
to the returned Location, adding ?digest=<digest>. The registry
refuses bytes that do not match. A PUT to
/v2/<name>/manifests/<tag> pushes a manifest and moves the tag.
Authentication is outside the OCI specifications. Most registries
implement the bearer token flow of the Distribution project. A request
without credentials gets 401 with a challenge such as
WWW-Authenticate: Bearer realm="...",service="...",scope="...". The
client asks the realm for a token, presenting a user name and password
if it has them, and repeats the request with
Authorization: Bearer <token>. Some registries accept HTTP Basic
authentication instead. Container tools keep one base64
user:password per registry host in the auths object of a
config.json.
How shirudo uses a registry#
The operator publishes with shirudo bpm push and
shirudo bpm tree append, which run in the shirudo-build helper.
A target fetches with shirudo bpm repo update, install,
upgrade, pull and tree sync. Every object is an image
manifest with shirudo’s own media types:
Object |
Location |
Content |
|---|---|---|
Package |
|
One |
Package certificate |
Referrer of the package manifest |
The signing certificate as |
Repository index |
|
|
Tree publication |
|
|
Tree artifact |
|
One |
The index, the tree publication and the tree artifacts use the empty
config and set artifactType.
bpm push uploads the blobs, the package manifest by digest and the
certificate referrer, then, given signing material, a new signed index,
and moves the version tag last. The index lists every package version
pushed to that registry host with signing material, each with its
repository, manifest digest, package digest and size. bpm push
refuses to list a version again with different digests.
On a target, the repository definitions and their certificates come
from the signed config image. bpm repo update fetches each
repository’s index, checks both layers against their digests, verifies
the signature and caches the index. bpm install <source>/<name>
then fetches the package manifest by the digest the index names, checks
the package layer against the index and loads the upatches inside
through the signed load path. bpm tree sync verifies the
publication and fetches each artifact by the manifest and layer digests
the publication names.
The client follows redirects for blob requests only and never sends
the Authorization header to another host. It reads no response
larger than 16 MiB into memory and writes no package larger than 256 MiB
to disk. Each transfer ends after a minute plus the time the most it may
carry takes at 128 KiB a second, so that a registry that answers a few
bytes at a time cannot hold a command, and the config operation lock it
holds, any longer. Credentials come from BPM_OCI_USERNAME and
BPM_OCI_PASSWORD, or from the registry’s auth entry in
REGISTRY_AUTH_FILE, $DOCKER_CONFIG/config.json or
$HOME/.docker/config.json, and BPM_OCI_BEARER_TOKEN supplies a
token directly. Credential helpers are not supported.
What is signed and what is only addressed#
Three kinds of objects carry a signature a target checks:
The
.upatchfiles inside packages and tree artifacts are signed loaders and unload directives. The kernel verifies their ML-DSA-87 signature atBPF_PROG_LOADagainst the.bpfkeyring.A repository index is verified against the certificate its repository definition names in the signed config.
A tree publication is verified against the active config’s trusted set: the runtime image’s primary certificate and the certificates the config vouches for, less those it revokes, the primary included. Every member must also be in the
.bpfkeyring.
Everything else is content-addressed only: manifests, configs, package archives and artifact blobs. They are trusted because a signed document names their digests, and Figure 1 shows which document names which object. A package installed from the index is therefore the one the operator pushed, but the registry decides whether to serve it at all: a target reaches each signed document through a tag, which the registry resolves.
Figure 1. Which object names which by digest. Solid arrows are digests a target checks, dashed arrows are tags the registry resolves.#
Limits#
A signature shows who wrote a document, not that it is current. A
validly signed older index replaces the cached one: repo update
does not read the signed generated_at. A registry can serve an old
index, or none, and hide newer versions. A target refuses a changed
tree publication whose generation is not higher than the one it applied
last, but the registry can keep serving an unchanged publication, and
the first sync accepts any generation.
An index names repositories, not the registry. An index signed for one registry verifies on any other whose repository definition names the same certificate.
repo update is not measured. The register records upatch loads,
unloads and tree operations, not which index or package version a
target saw, and bpm list reports the target’s own state.
bpm install and bpm pull also take a direct
oci://<registry>/<repository>:<tag>. That path has no index: the
registry resolves the tag, and only the layer digest from that manifest
is checked. The kernel’s signature check still applies to each upatch,
so the registry can choose only among artifacts a trusted key once
signed, old ones included.
Environment variables select the transport, and processes with runtime
authority honor them: BPM_OCI_SCHEME=http turns TLS off,
BPM_OCI_CA_FILE adds a trust anchor, and libcurl’s proxy variables
redirect traffic. The repository update and tree sync units read
/etc/shirudo/bpm/environment, which root can write. Signatures
still bind what a target loads, so this gives root the position of a
hostile registry.
On the operator host, shirudo bpm config update --base-package
oci://... without --file downloads the base package by tag, checks it
only against its manifest’s layer digest, and runs the updater
commands of the Beefile inside it. Whoever can move that tag can run
commands on the operator host. Pass -f with a Beefile you control,
or a package file you built.