Chapter 4: Controlled artifact transfer across zone and network boundaries
In this chapter you will learn:
- why networks are split into security zones and what an airlock or a data diode does,
- how to package a container image together with its SBOM and signatures as a verifiable transfer bundle,
- how a quarantine area automatically checks integrity, origin and vulnerabilities,
- how a release under the four-eyes principle works with a signed release record,
- how to prove that exactly the same image arrives in the target zone (digest comparison).
What is this about?
Picture a lab with a clean room. Nobody simply carries a cardboard box inside. Everything goes through a material airlock: the box is handed over, wiped down on the outside, inspected and logged. Only when a second person signs off does the inner door open. The two doors are never open at the same time.
The controlled transfer of software between network zones works exactly like that. Your build environment (Zone A) produces an image. The production environment (Zone B) must not simply pull it from Zone A, because there should be no direct connection between the two. Instead, the image is packaged, passed through an airlock, checked, released, and only then imported into Zone B.
Zone A: Build/Internal Airlock Zone B: Target/Production
+---------------------+ +-----------------------------+ +---------------------+
| reg-build | | eingang/ | | reg-ziel |
| localhost:5001 | | | | | localhost:5002 |
| demo-app:1.0.0 | | v | | |
| + SBOM, signature | | quarantaene/ --- check --- | | demo-app:1.0.0 |
| | | | | hash, signature, scan | | (same digest) |
| v | | v | | ^ |
| Export: OCI layout |===>| geprueft/ ---- release ---->|===>| Import | |
| + SHA256SUMS + sig | | | (2nd person) | | | |
| = transfer bundle | | +--> abgelehnt/ | | |
+---------------------+ +-----------------------------+ +---------------------+
One-way street: data flows only from left to right
The key idea: the target zone does not trust the transport path, only what it can verify itself. A bundle can be tampered with in transit, a USB stick can be swapped. That is why the airlock checks everything again, using tools and keys that live in the target zone.
The concepts in plain terms
The zone model
A security zone is a network area with uniform protection requirements and uniform rules. Typical zones in an organization:
| Zone | Example | Protection requirement |
|---|---|---|
| Internet/External | Docker Hub, PyPI | untrusted |
| Build/Internal | GitLab, runners, reg-build | medium |
| Target/Production | cluster, reg-ziel | high |
| High security/air-gapped | control center, VS-NfD network (German classified “restricted” network) | very high |
Between the zones there are boundaries: firewalls, gateways or even a physical air gap, that is, no network connection at all. The higher the protection requirement, the less may cross the boundary, and the more closely it is checked.
Remember: A zone boundary is only as strong as its exceptions. Every direct connection “just for the registry” is a hole in the boundary.
Airlock and data diode
An airlock is an intermediate area between two zones. Data lands there before it is passed on. The airlock has its own check logic and its own log. It can be a server, a directory on a file server, or a process using removable media.
A data diode is hardware that physically lets data pass in one direction only. Technically, for example, the return line of a fiber link is missing. This rules out data flowing back out of the protected zone or an attacker building a connection back. Because there is no return channel, there is no TCP handshake either. Data diodes therefore work with special proxies that transfer files one way.
For you as a platform engineer this means: you cannot run
docker pull across such a boundary. You need artifacts that
can travel as files. That is exactly what the OCI layout is for.
Pull or push across the boundary?
Who opens the connection? This question determines the attack surface.
| Model | Flow | Assessment |
|---|---|---|
| Push from A to B | Zone A writes to reg-ziel | risky: A needs write access in B |
| Pull by B from A | Zone B reads from reg-build | better: no inbound connection into B |
| Pull via airlock | B fetches from the airlock | good: no direct A-B connection |
| File via diode | A drops it off, diode pushes | very good: technically one-way |
Rule of thumb: connections are opened from the more highly protected zone outward, never inward. The data diode is an exception, because physically there is no way back.
The transfer bundle
A container image is not a single thing but a web of JSON files and layers linked by their hashes. The OCI Image Layout is a standardized directory format that stores such a web as files:
oci/
oci-layout version identifier of the format
index.json entry point: which manifests exist, under which name
blobs/sha256/<hash> all manifests, configs and layers, named after their hash
Because every file is named after its SHA-256 hash, this is called content-addressable. If a single byte changes, the name no longer matches.
A referrer is an artifact that points to an image,
for example an SBOM or a signature. It has a subject field
that contains the image’s digest. Registries with a Referrers API can
list these references. Older registries such as registry:2
cannot. Tools like oras then use a fallback: a tag named
sha256-<hex> under which an index of all referrers is
stored. Cosign v2 traditionally stores signatures under tags such as
sha256-<hex>.sig.
Our transfer bundle consists of:
| File | Purpose |
|---|---|
oci/ |
image plus referrers in OCI layout |
begleitschein.json |
the delivery note: what is inside, which digest, who sends it |
SHA256SUMS |
hash of every single file |
SHA256SUMS.sig |
the sender’s signature over the hash list |
Remember: The hash list alone only protects against accidental damage. Anyone who tampers with the bundle can also recompute the hash list. Only the sender’s signature turns it into proof of origin.
Checks in quarantine
The quarantine is a sealed-off area where a bundle stays until all checks have passed. Nothing from quarantine may be executed or used in production. Typical checks, from fast to slow:
- Transport integrity: Does the hash of the whole archive match?
- Archive hygiene: No absolute paths, no
.., no symlinks (protection against path traversal, that is, breaking out of the target directory during extraction). - Origin: Is the hash list signed by the known sender?
- Content integrity: Do all individual hashes match, and are there no extra files?
- Consistency: Does the digest in the delivery note match the image in the OCI layout?
- Content: vulnerability scan (Trivy), secret scan, optionally a malware scan (e.g., ClamAV).
- Image signature:
cosign verifyagainst your own trust anchor (see Chapter 5).
Every check produces a clear result. The overall result goes into a check record in JSON format, so machines and auditors can read it.
Thresholds
A scanner almost always finds something. The question is at what point you reject. A threshold defines that, for example “0 critical, at most 5 high vulnerabilities with an available fix”. Thresholds are a policy, not a technique. They need to be documented and agreed with the development teams (see Chapters 8 and 10).
Release under the four-eyes principle
Passing the technical checks does not yet mean “may go to production”. The release is a deliberate decision by a responsible person. Under the four-eyes principle, the person who checks and the person who releases must not be the same. That way nobody can wave something through alone, neither by accident nor on purpose.
The release is recorded as a file and signed. The release record contains at least:
- which bundle (hash) and which image (digest),
- which check record it was based on (hash of the record),
- who released it and when.
The import into Zone B verifies this signature. No valid release, no import.
Traceability and audit
An auditor typically asks: “Which image is running in production, who released it, based on which check?” You must be able to answer this chain without gaps:
Pod in cluster -> image digest -> release (signed) -> check record -> bundle hash
-> delivery note -> build in Zone A (pipeline ID, see Chapter 1)
For this, every step writes to an audit log, ideally append-only and additionally forwarded to a central SIEM (Security Information and Event Management).
Hands-on Lab: The airlock between reg-build and reg-ziel
You now rebuild the complete path: export from Zone A, transfer, quarantine, release by a second person, import into Zone B and digest comparison.
Prerequisites from Chapter 0: the registries reg-build
(localhost:5001) and reg-ziel (localhost:5002) are running,
the image localhost:5001/demo-app:1.0.0 exists, and
oras, crane, syft,
trivy, jq and openssl are
installed.
Step 1: Check the working directory and registries
mkdir -p ~/seclab/kap04/{bin,keys,bundle}
mkdir -p ~/seclab/kap04/schleuse/{eingang,quarantaene,geprueft,abgelehnt}
mkdir -p ~/seclab/kap04/schleuse/{freigegeben,protokolle,vertrauen}
cd ~/seclab/kap04
docker start reg-build reg-ziel
curl -s http://localhost:5001/v2/_catalog
curl -s http://localhost:5002/v2/_catalogExpected output (the list for reg-ziel may be empty):
reg-build
reg-ziel
{"repositories":["demo-app"]}
{"repositories":[]}
If demo-app is missing in reg-build, build and push it
as in Chapter 0:
docker build -t localhost:5001/demo-app:1.0.0 ~/seclab/demo-app
docker push localhost:5001/demo-app:1.0.0Note the digest. From now on we work only with it:
DIGEST=$(crane digest localhost:5001/demo-app:1.0.0)
echo "$DIGEST"Expected output: a line of the form sha256: followed by
64 hex characters.
Step 2: Attach an SBOM as a referrer
So that the bundle contains more than just the image, you attach an SBOM (Software Bill of Materials, a parts list of all components, see Chapter 7) to the image.
syft localhost:5001/demo-app:1.0.0 -o cyclonedx-json=sbom.cdx.json
oras attach --plain-http \
--artifact-type application/vnd.cyclonedx+json \
"localhost:5001/demo-app@${DIGEST}" \
sbom.cdx.json:application/vnd.cyclonedx+json
oras discover --plain-http "localhost:5001/demo-app@${DIGEST}"Expected output of oras discover (digests
shortened):
localhost:5001/demo-app@sha256:3f1c...
└── application/vnd.cyclonedx+json
└── sha256:9a7b...
Tip: Here
syftreads the image from the local Docker daemon, because you just built it. To read it directly from the registry, setSYFT_REGISTRY_INSECURE_USE_HTTP=trueand useregistry:localhost:5001/demo-app:1.0.0.
Take a look at the tags. Because registry:2 has no
Referrers API, oras creates a fallback tag:
crane ls localhost:5001/demo-appExpected output:
1.0.0
sha256-3f1c...
Step 3: Export the image and its referrers as an OCI layout
Now comes the export. oras cp -r copies the image and,
recursively, all referrers. The --to-oci-layout option
writes to a directory instead of a registry. Important: oras copies
manifests byte for byte, so the digest stays the same.
cd ~/seclab/kap04
rm -rf bundle && mkdir bundle
oras cp -r --from-plain-http \
"localhost:5001/demo-app@${DIGEST}" \
--to-oci-layout "bundle/oci:1.0.0"If you have already worked through Chapter 5 and signed the image
with cosign v2, the signature and attestation live under their own tags
(.sig, .att). oras cp -r does not
find them, because they are not real referrers. Take them along
explicitly:
HEX="${DIGEST#sha256:}"
for T in $(crane ls localhost:5001/demo-app \
| grep -E "^sha256-${HEX}\.(sig|att|sbom)$" || true); do
echo "nehme mit: $T"
oras cp --from-plain-http "localhost:5001/demo-app:${T}" \
--to-oci-layout "bundle/oci:${T}"
doneIf there are no such tags, nothing happens. Check the result:
jq -r '.manifests[]
| "\(.digest) \(.annotations["org.opencontainers.image.ref.name"] // "-")"' \
bundle/oci/index.json
oras discover --oci-layout "bundle/oci:1.0.0"Expected output: one line with your $DIGEST and the name
1.0.0. Depending on the oras version, further lines for the
referrers follow below it. oras discover again shows the
CycloneDX SBOM under the image.
Warning:
skopeo copy docker://... oci:...is a well-known way to copy images into an OCI layout. However, skopeo converts Docker manifests into OCI manifests in the process. The digest then changes, and none of the signatures match any more. For digest-preserving transfers, useoras cporcosign save.
Step 4: Delivery note, hash list and sender signature
The sender in Zone A needs a key pair. The public key is deposited in the airlock once, via a separate and trusted path. In the lab you simply copy it.
cd ~/seclab/kap04
openssl ecparam -name prime256v1 -genkey -noout -out keys/absender.key
openssl ec -in keys/absender.key -pubout -out schleuse/vertrauen/absender.pub
chmod 600 keys/absender.keyExpected output:
read EC key
writing EC key
Now the delivery note (begleitschein.json). It describes
what is in the bundle:
jq -n \
--arg image "demo-app" --arg tag "1.0.0" --arg digest "$DIGEST" \
--arg quelle "localhost:5001/demo-app" \
--arg erstellt "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg absender "build-team" \
'{image:$image, tag:$tag, digest:$digest, quelle:$quelle,
erstellt:$erstellt, absender:$absender}' \
> bundle/begleitschein.json
cat bundle/begleitschein.jsonNext, the hash list over all files and the signature over it. On
macOS sha256sum is not always available; there you use
shasum -a 256. Both tools produce the same format.
cd ~/seclab/kap04/bundle
SHA="sha256sum"; command -v sha256sum >/dev/null || SHA="shasum -a 256"
find . -type f ! -name 'SHA256SUMS*' | sort | xargs $SHA > SHA256SUMS
openssl dgst -sha256 -sign ../keys/absender.key -out SHA256SUMS.sig SHA256SUMS
head -3 SHA256SUMS
$SHA -c --status SHA256SUMS && echo "Hashliste ok"Expected output:
5c2e... ./begleitschein.json
0a41... ./oci/blobs/sha256/0a41...
1f9d... ./oci/blobs/sha256/1f9d...
Hashliste ok
Notice something? For the blobs, hash and file name are identical. That is the content addressing from the concepts section.
Step 5: Pack the bundle and simulate the transfer
cd ~/seclab/kap04
COPYFILE_DISABLE=1 tar -C bundle -cf demo-app-1.0.0.tar .
$SHA demo-app-1.0.0.tar > demo-app-1.0.0.tar.sha256
ls -lh demo-app-1.0.0.tar*COPYFILE_DISABLE=1 prevents macOS from packing hidden
._ files into the archive. These would later show up as
“unexpected files”. On Linux the variable does no harm.
In the lab, the “transfer” is a copy. In reality it would be a data diode, a transfer server or removable media.
cp demo-app-1.0.0.tar demo-app-1.0.0.tar.sha256 schleuse/eingang/
ls schleuse/eingang/Expected output:
demo-app-1.0.0.tar demo-app-1.0.0.tar.sha256
Step 6: The quarantine check script
From here on you are mentally inside the airlock. The script takes a
bundle from eingang/ (inbox), moves it into its own
quarantine folder, checks everything and then files it in
geprueft/ (checked) or abgelehnt/ (rejected).
There is deliberately no freigegeben/ (released): only a
human may decide that (Step 7).
Create the file
~/seclab/kap04/bin/quarantaene-pruefen.sh:
#!/usr/bin/env bash
# quarantaene-pruefen.sh - technical check of a transfer bundle
set -euo pipefail
NAME="${1:?Aufruf: $0 <bundle.tar>}"
S="${SCHLEUSE:-$HOME/seclab/kap04/schleuse}"
MAX_CRITICAL="${MAX_CRITICAL:-0}"
MAX_HIGH="${MAX_HIGH:-5}"
PRUEFER="${PRUEFER:-$(whoami)}"
sha256() {
if command -v sha256sum >/dev/null 2>&1; then sha256sum "$@"
else shasum -a 256 "$@"; fi
}
ID="${NAME%.tar}_$(date -u +%Y%m%dT%H%M%SZ)"
Q="$S/quarantaene/$ID" # working folder for this bundle
I="$Q/inhalt" # extracted content
PROT="$S/protokolle/$ID.json"
mkdir -p "$Q" "$S/protokolle" "$S/geprueft" "$S/abgelehnt"
R_HASH="offen"; R_SIG="offen"; R_DATEIEN="offen"; R_DIGEST="offen"
R_SCAN="offen"; CRIT=-1; HIGH=-1; SECRETS=-1; DIGEST=""; BUNDLE_SHA=""
abschluss() {
local ent="$1" grund="$2" ziel
if [ "$ent" = "bestanden" ]; then ziel="$S/geprueft/$ID"
else ziel="$S/abgelehnt/$ID"; fi
jq -n \
--arg id "$ID" --arg bundle "$NAME" --arg sha "$BUNDLE_SHA" \
--arg digest "$DIGEST" --arg pruefer "$PRUEFER" \
--arg zeit "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg hash "$R_HASH" --arg sig "$R_SIG" --arg dat "$R_DATEIEN" \
--arg dig "$R_DIGEST" --arg scan "$R_SCAN" \
--argjson crit "$CRIT" --argjson high "$HIGH" --argjson sec "$SECRETS" \
--argjson maxc "$MAX_CRITICAL" --argjson maxh "$MAX_HIGH" \
--arg ent "$ent" --arg grund "$grund" \
'{id:$id, bundle:$bundle, bundle_sha256:$sha, image_digest:$digest,
pruefer:$pruefer, zeitpunkt:$zeit,
pruefungen:{transport_hash:$hash, absender_signatur:$sig,
dateien:$dat, digest_abgleich:$dig,
scan:{ergebnis:$scan, critical:$crit, high:$high, secrets:$sec,
schwelle:{critical:$maxc, high:$maxh}}},
entscheidung:$ent, grund:$grund}' > "$PROT"
jq -c . "$PROT" >> "$S/protokolle/audit.jsonl"
mv "$Q" "$ziel"
echo "$ent: $grund"
echo "Protokoll: $PROT"
}
ablehnen() { abschluss "abgelehnt" "$1"; exit 1; }
# 0. Move from the inbox into quarantine
mv "$S/eingang/$NAME" "$S/eingang/$NAME.sha256" "$Q/"
# 1. Transport integrity of the archive
if (cd "$Q" && sha256 -c --status "$NAME.sha256"); then R_HASH="ok"
else R_HASH="fehler"; ablehnen "Archiv-Hash stimmt nicht"; fi
BUNDLE_SHA=$(sha256 "$Q/$NAME" | cut -d' ' -f1)
# 2. Archive hygiene: no absolute paths, no .., no links
if tar -tf "$Q/$NAME" | grep -Eq '(^/|(^|/)\.\.(/|$))'; then
ablehnen "unsichere Pfade im Archiv"; fi
if tar -tvf "$Q/$NAME" | grep -q '^[lh]'; then
ablehnen "Links im Archiv sind nicht erlaubt"; fi
mkdir -p "$I" && tar -xf "$Q/$NAME" -C "$I"
# 3. Origin: sender signature over the hash list
if openssl dgst -sha256 -verify "$S/vertrauen/absender.pub" \
-signature "$I/SHA256SUMS.sig" "$I/SHA256SUMS" >/dev/null 2>&1
then R_SIG="ok"; else R_SIG="fehler"; ablehnen "Absender-Signatur ungültig"; fi
# 4. Content integrity: all hashes, no foreign files
if ! (cd "$I" && sha256 -c --status SHA256SUMS); then
R_DATEIEN="fehler"; ablehnen "Datei-Hash stimmt nicht"; fi
GELISTET=$(awk '{print $2}' "$I/SHA256SUMS" | sort)
VORHANDEN=$(cd "$I" && find . -type f ! -name 'SHA256SUMS*' | sort)
if [ "$GELISTET" != "$VORHANDEN" ]; then
R_DATEIEN="fehler"; ablehnen "fehlende oder zusätzliche Dateien"; fi
R_DATEIEN="ok"
# 5. Consistency: digest in the delivery note = image in the OCI layout
DIGEST=$(jq -r '.digest' "$I/begleitschein.json")
TAG=$(jq -r '.tag' "$I/begleitschein.json")
IDX=$(jq -r --arg t "$TAG" '.manifests[]
| select(.annotations["org.opencontainers.image.ref.name"]==$t)
| .digest' "$I/oci/index.json")
if [ "$DIGEST" = "$IDX" ]; then R_DIGEST="ok"
else R_DIGEST="fehler"; ablehnen "Digest passt nicht zum Begleitschein"; fi
# 6. Content: vulnerabilities and secrets (image only, without referrers)
oras cp --from-oci-layout "$I/oci:$TAG" \
--to-oci-layout "$Q/scan:$TAG" >/dev/null \
|| ablehnen "Image nicht aus OCI-Layout lesbar"
trivy image --input "$Q/scan" --scanners vuln,secret --ignore-unfixed \
--quiet --format json --output "$Q/trivy.json" \
|| ablehnen "Scan fehlgeschlagen"
CRIT=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity=="CRITICAL")]
| length' "$Q/trivy.json")
HIGH=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity=="HIGH")]
| length' "$Q/trivy.json")
SECRETS=$(jq '[.Results[]?.Secrets[]?] | length' "$Q/trivy.json")
if [ "$CRIT" -gt "$MAX_CRITICAL" ] || [ "$HIGH" -gt "$MAX_HIGH" ] \
|| [ "$SECRETS" -gt 0 ]; then
R_SCAN="fehler"
ablehnen "Schwelle überschritten (critical=$CRIT high=$HIGH secrets=$SECRETS)"
fi
R_SCAN="ok"
# 7. Optional: verify the image signature (see Chapter 5)
# 8. Optional: malware scan, e.g. clamscan -r --no-summary "$I"
abschluss "bestanden" "alle technischen Prüfungen ok"Make the script executable and start the check. In the lab you set
PRUEFER (checker) by hand, so that you can simulate two
people later.
chmod +x ~/seclab/kap04/bin/quarantaene-pruefen.sh
PRUEFER=alice ~/seclab/kap04/bin/quarantaene-pruefen.sh demo-app-1.0.0.tarOn the first run, Trivy downloads its vulnerability database. After that, the output looks roughly like this (“bestanden” means “passed”):
bestanden: alle technischen Prüfungen ok
Protokoll: /home/thomas/seclab/kap04/schleuse/protokolle/demo-app-1.0.0_2026...json
If the bundle is rejected, read the reason. The number of
vulnerabilities depends on the current state of the Trivy database. The
base image and gunicorn==22.0.0 may bring high
vulnerabilities. If the number is above 5, put the files into the inbox
again and set MAX_HIGH=10 for the lab. In real life you
would fix the image instead (see Chapter 8).
Take a look at the record:
ID=$(ls ~/seclab/kap04/schleuse/geprueft/ | tail -1)
jq . ~/seclab/kap04/schleuse/protokolle/"$ID".jsonExpected output (shortened):
{
"id": "demo-app-1.0.0_20261008T091502Z",
"bundle_sha256": "7d3e...",
"image_digest": "sha256:3f1c...",
"pruefer": "alice",
"pruefungen": {
"transport_hash": "ok",
"absender_signatur": "ok",
"dateien": "ok",
"digest_abgleich": "ok",
"scan": { "ergebnis": "ok", "critical": 0, "high": 2, "secrets": 0 }
},
"entscheidung": "bestanden"
}Step 7: Release by a second person
The releasing person has their own key pair. Their public key lives
in vertrauen/ (trust), so that the import can later verify
that the release is genuine.
cd ~/seclab/kap04
openssl ecparam -name prime256v1 -genkey -noout -out keys/freigeber-bob.key
openssl ec -in keys/freigeber-bob.key -pubout \
-out schleuse/vertrauen/freigeber.pub
chmod 600 keys/freigeber-bob.keyCreate ~/seclab/kap04/bin/freigeben.sh:
#!/usr/bin/env bash
# freigeben.sh - release of a checked bundle (four-eyes principle)
set -euo pipefail
ID="${1:?Aufruf: $0 <bundle-id>}"
S="${SCHLEUSE:-$HOME/seclab/kap04/schleuse}"
FREIGEBER="${FREIGEBER:?FREIGEBER=<name> setzen}"
KEY="${FREIGEBER_KEY:?FREIGEBER_KEY=<pfad zum privaten Schlüssel> setzen}"
PROT="$S/protokolle/$ID.json"
sha256() {
if command -v sha256sum >/dev/null 2>&1; then sha256sum "$@"
else shasum -a 256 "$@"; fi
}
[ -d "$S/geprueft/$ID" ] || { echo "Bundle $ID ist nicht im Status geprüft"; exit 1; }
[ "$(jq -r .entscheidung "$PROT")" = "bestanden" ] \
|| { echo "Prüfprotokoll ist nicht bestanden"; exit 1; }
PRUEFER=$(jq -r .pruefer "$PROT")
if [ "$PRUEFER" = "$FREIGEBER" ]; then
echo "Vier-Augen-Prinzip verletzt: $FREIGEBER hat selbst geprüft"; exit 1
fi
jq . "$PROT"
read -r -p "Bundle $ID freigeben? (ja/nein) " ANTWORT
[ "$ANTWORT" = "ja" ] || { echo "Keine Freigabe."; exit 1; }
F="$S/geprueft/$ID/freigabe.json"
jq -n \
--arg id "$ID" \
--arg digest "$(jq -r .image_digest "$PROT")" \
--arg bundle_sha "$(jq -r .bundle_sha256 "$PROT")" \
--arg prot_sha "$(sha256 "$PROT" | cut -d' ' -f1)" \
--arg wer "$FREIGEBER" --arg pruefer "$PRUEFER" \
--arg zeit "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
'{id:$id, image_digest:$digest, bundle_sha256:$bundle_sha,
pruefprotokoll_sha256:$prot_sha, geprueft_von:$pruefer,
freigegeben_von:$wer, zeitpunkt:$zeit, entscheidung:"freigegeben"}' > "$F"
openssl dgst -sha256 -sign "$KEY" -out "$F.sig" "$F"
jq -c . "$F" >> "$S/protokolle/audit.jsonl"
mkdir -p "$S/freigegeben"
mv "$S/geprueft/$ID" "$S/freigegeben/$ID"
echo "Freigegeben: $S/freigegeben/$ID"First test the failure case. Alice did the check, so she must not release:
chmod +x ~/seclab/kap04/bin/freigeben.sh
FREIGEBER=alice FREIGEBER_KEY=~/seclab/kap04/keys/freigeber-bob.key \
~/seclab/kap04/bin/freigeben.sh "$ID"Expected output (“four-eyes principle violated: alice checked it herself”):
Vier-Augen-Prinzip verletzt: alice hat selbst geprüft
Now Bob releases and answers ja (yes):
FREIGEBER=bob FREIGEBER_KEY=~/seclab/kap04/keys/freigeber-bob.key \
~/seclab/kap04/bin/freigeben.sh "$ID"Expected output at the end:
Bundle demo-app-1.0.0_20261008T091502Z freigeben? (ja/nein) ja
Freigegeben: /home/thomas/seclab/kap04/schleuse/freigegeben/demo-app-1.0.0_...
Security: In the lab both keys sit in one folder, and
FREIGEBERis just a variable. That is theater. In real life Bob keeps his key on a smart card or a token, and the identity comes from a login, not from an environment variable.
Step 8: Import into reg-ziel and digest comparison
The import is the last bouncer. It does not rely on something sitting
in the freigegeben/ folder. It verifies the release
signature, checks that the release belongs to exactly this bundle, and
checks the hash list once more. Only then does it copy.
Create ~/seclab/kap04/bin/importieren.sh:
#!/usr/bin/env bash
# importieren.sh - import of a released bundle into reg-ziel
set -euo pipefail
ID="${1:?Aufruf: $0 <bundle-id>}"
S="${SCHLEUSE:-$HOME/seclab/kap04/schleuse}"
ZIEL="${ZIEL_REGISTRY:-localhost:5002}"
D="$S/freigegeben/$ID"; I="$D/inhalt"; F="$D/freigabe.json"
sha256() {
if command -v sha256sum >/dev/null 2>&1; then sha256sum "$@"
else shasum -a 256 "$@"; fi
}
# 1. Is the release genuine?
openssl dgst -sha256 -verify "$S/vertrauen/freigeber.pub" \
-signature "$F.sig" "$F" >/dev/null \
|| { echo "Freigabe-Signatur ungültig"; exit 1; }
# 2. Does the release belong to this bundle?
SOLL=$(jq -r .bundle_sha256 "$F")
IST=$(sha256 "$D"/*.tar | cut -d' ' -f1)
[ "$SOLL" = "$IST" ] || { echo "Freigabe gehört zu anderem Bundle"; exit 1; }
# 3. Content unchanged since the check?
(cd "$I" && sha256 -c --status SHA256SUMS) \
|| { echo "Inhalt nach Prüfung verändert"; exit 1; }
DIGEST=$(jq -r .image_digest "$F")
REPO=$(jq -r .image "$I/begleitschein.json")
TAG=$(jq -r .tag "$I/begleitschein.json")
# 4. Copy the image with all referrers, then additional tags (e.g. .sig)
oras cp -r --from-oci-layout "$I/oci:$TAG" \
--to-plain-http "$ZIEL/$REPO:$TAG"
for REF in $(jq -r '.manifests[].annotations["org.opencontainers.image.ref.name"]
// empty' "$I/oci/index.json"); do
[ "$REF" = "$TAG" ] && continue
oras cp --from-oci-layout "$I/oci:$REF" --to-plain-http "$ZIEL/$REPO:$REF"
done
# 5. Digest comparison
ANGEKOMMEN=$(crane digest "$ZIEL/$REPO:$TAG")
if [ "$ANGEKOMMEN" = "$DIGEST" ]; then
echo "OK: $ZIEL/$REPO@$ANGEKOMMEN ist identisch mit der Freigabe"
else
echo "FEHLER: erwartet $DIGEST, angekommen $ANGEKOMMEN"; exit 1
fiRun it:
chmod +x ~/seclab/kap04/bin/importieren.sh
~/seclab/kap04/bin/importieren.sh "$ID"Expected output (shortened; the format of the oras messages varies by version):
Copied [oci-layout] .../inhalt/oci:1.0.0 => [registry] localhost:5002/demo-app:1.0.0
Digest: sha256:3f1c...
OK: localhost:5002/demo-app@sha256:3f1c... ist identisch mit der Freigabe
To be safe, compare both zones once more by hand and check that the SBOM traveled along:
crane digest localhost:5001/demo-app:1.0.0
crane digest localhost:5002/demo-app:1.0.0
oras discover --plain-http "localhost:5002/demo-app@${DIGEST}"Both digests must be identical character for character. In reg-ziel,
oras discover shows the same CycloneDX SBOM as in
reg-build.
Remember: Same digest means same content. Everything else builds on this: signatures (Chapter 5), SBOM mapping (Chapter 7) and policies in the cluster (Chapter 9) always refer to the digest.
Step 9: Review the audit trail
jq -r '[.zeitpunkt, .id, (.entscheidung // ""), (.pruefer // .freigegeben_von)]
| @tsv' ~/seclab/kap04/schleuse/protokolle/audit.jsonlExpected output:
2026-10-08T09:15:02Z demo-app-1.0.0_20261008T091502Z bestanden alice
2026-10-08T09:21:40Z demo-app-1.0.0_20261008T091502Z freigegeben bob
Now you can answer the auditor’s question: which image, who checked it, who released it, when.
Step 10: Clean up
You will need the registries again in Chapter 5. You can stop them; their data stays in the container.
rm -rf ~/seclab/kap04/schleuse/quarantaene/*
docker stop reg-build reg-zielLeave the freigegeben/, protokolle/ and
keys/ folders in place. The exercise builds on them.
Save your progress? Sign up for free
Common pitfalls
| Symptom | Cause | Fix |
|---|---|---|
| Digest in reg-ziel differs | Export with skopeo or Docker converted the manifest | Work with oras cp or cosign save/load |
http: server gave HTTP response to HTTPS client |
Registry speaks HTTP only | Set --plain-http, --from-plain-http,
--to-plain-http |
| Script reports additional files | macOS packed ._* files into the tar |
COPYFILE_DISABLE=1 tar ... |
| Signature missing after import | cosign v2 signature under a .sig tag, not as a
referrer |
Take .sig/.att tags along explicitly (Step
3) |
| Trivy hangs in Zone B | No internet for the database download | Mirror the DB in advance, --skip-db-update or
--db-repository |
sha256sum: command not found |
macOS | Use shasum -a 256 (same format) |
| Release signature invalid | File changed after signing (e.g., editor) | Create the release again, never edit it by hand |
Exercise: Detect tampering and a threshold violation
You are now the attacker, and afterwards the checker again. From your bundle from Step 5, create two tampered variants and send them through the airlock:
- Variant A: In the delivery note, change the
absender(sender) field toangreifer(attacker), recompute the hash list and repack the bundle, but without a new signature. - Variant B: Send the unchanged original, but set a
strict threshold
MAX_HIGH=0for the check.
For each variant, answer: at which check does the bundle fail, and what does the check record say? Bonus question: what would an attacker additionally need for Variant A to get through?
Hint 1: Work in a copy:
cp -r ~/seclab/kap04/bundle ~/seclab/kap04/bundle-a. After
the change you need SHA256SUMS again, a new tar and the
outer .sha256 file. Write the tampered tar directly into
the inbox, so your original bundle stays intact. The old
SHA256SUMS.sig simply stays where it is.
Hint 2: Pay attention to the order of the checks in the script. For Variant A, the outer checksum and the individual hashes match, because you recomputed them. Which check can the attacker not forge without the private key? In Variant B everything is genuine. Which check depends on a policy instead of on cryptography?
Solution
Variant A:
cp -r ~/seclab/kap04/bundle ~/seclab/kap04/bundle-a
cd ~/seclab/kap04/bundle-a
jq '.absender = "angreifer"' begleitschein.json > b.tmp && mv b.tmp begleitschein.json
SHA="sha256sum"; command -v sha256sum >/dev/null || SHA="shasum -a 256"
find . -type f ! -name 'SHA256SUMS*' | sort | xargs $SHA > SHA256SUMS
cd ~/seclab/kap04
COPYFILE_DISABLE=1 tar -C bundle-a -cf schleuse/eingang/demo-app-1.0.0.tar .
(cd schleuse/eingang && $SHA demo-app-1.0.0.tar > demo-app-1.0.0.tar.sha256)
PRUEFER=alice ~/seclab/kap04/bin/quarantaene-pruefen.sh demo-app-1.0.0.tarExpected output (“rejected: sender signature invalid”):
abgelehnt: Absender-Signatur ungültig
The record says transport_hash: "ok", but
absender_signatur: "fehler" (error). The attacker was able
to recompute all hashes, but not the signature. So the outer checksum
was of no use. It only protects against transmission errors. For Variant
A to get through, the attacker would need the sender’s private key, or
would have to smuggle their own public key into vertrauen/.
That is why trust anchors belong under strict control (see Chapter
5).
Variant B:
cd ~/seclab/kap04
cp demo-app-1.0.0.tar demo-app-1.0.0.tar.sha256 schleuse/eingang/Then check with a strict threshold:
MAX_HIGH=0 PRUEFER=alice ~/seclab/kap04/bin/quarantaene-pruefen.sh demo-app-1.0.0.tarExpected output if at least one high vulnerability with a fix exists (“threshold exceeded”):
abgelehnt: Schwelle überschritten (critical=0 high=2 secrets=0)
All cryptographic checks are ok; only
scan.ergebnis is fehler. The bundle is
genuine, but it does not meet the policy. In practice this does not lead
to an argument with the airlock, but to a ticket for the development
team or to a documented, time-limited exception (see Chapter 10).
Save your progress? Sign up for free
In practice
Organizational separation. In regulated environments (public authorities, operators of critical infrastructure (KRITIS), networks for classified information), sender, checker and releaser are different roles, often in different teams. The build team may not write to the airlock, except to the inbox. The airlock has its own admins. The release lies with operations or with the information security officer. This separation is laid down in the operations concept and is checked during audits.
Technical implementation. Instead of a folder of Bash scripts, in practice you will find:
- A quarantine registry or quarantine project, for example a Harbor project that blocks pulls as long as the scan reports vulnerabilities above the threshold. After release, the image is copied into the production project via replication or promotion.
- Repository promotion in Nexus or Artifactory: the artifact moves
from
stagingtoreleasewhen all checks are green. - Transfer servers at the zone boundary that accept files, check them and pass them on through a data diode.
- At public authorities, often a security gateway architecture according to BSI guidelines (BSI is the German Federal Office for Information Security), for example following the pattern packet filter, application-level gateway, packet filter (P-A-P).
Signed releases. Instead of
openssl dgst, people use cosign sign-blob, GPG
or a ticket system with a workflow and digital signature. What matters
is not the tool, but that the release is bound to the digest. A release
“for demo-app:1.0.0” is worthless, because a tag can change.
Offline databases. Scanners need current data. In
air-gapped zones, the Trivy database itself is transported through the
airlock, typically daily. Trivy can load its database from an internal
registry (--db-repository). Outdated scan data is an audit
finding. So monitor the age of the database.
Validity of releases. A release should expire. An image released six months ago may have known critical vulnerabilities today. Many organizations regularly rescan the inventory in the target zone and revoke releases when new critical findings appear.
Monitoring and audit. Good operational metrics:
- lead time from inbox to import (median, 95th percentile),
- rejection rate and most frequent rejection reasons,
- number of open bundles in
geprueft/waiting for release, - age of the scanner database.
The audit log belongs on tamper-proof storage, for example WORM storage (Write Once, Read Many), or at least a logging system to which the airlock admins have no write access.
Emergencies. Plan a documented fast lane for security updates, for example with a shortened release, but still with two people. Otherwise, when it really matters, the airlock gets bypassed, and that is exactly what you want to prevent.
Interview questions
Q: Why is a SHA-256 checksum next to the bundle not enough?
A: It only detects accidental damage. Anyone who can change the bundle can also recompute the checksum. For proof of origin, the hash list must be signed with a key whose public part is deposited in the target zone as a trust anchor.
Q: What is the difference between pull and push across a zone boundary, and which do you prefer?
A: With push, the less protected zone opens a connection into the more protected one and needs write access there. With pull, the more protected zone fetches by itself. I prefer pulling from an airlock or one-way transfer via a data diode, so that no inbound connections into the protected zone are needed.
Q: How do you make sure exactly the released image runs in production?
A: Work with digests end to end: bind the release to the digest, transfer in a digest-preserving way (OCI layout with oras), compare the digest after import, and in the cluster reference images by digest or enforce it via policy (Chapter 9).
Q: Why can an export with docker save
or skopeo cause problems?
A: Both can change the manifest, for example when converting between Docker and OCI format. Then the digest changes, and signatures and releases tied to the old digest no longer match. In addition, they do not take referrers such as SBOMs and signatures along.
Q: What belongs in a check record?
A: A unique ID, bundle hash, image digest, all individual checks with their results, the thresholds and tool versions used, the checker, the timestamp and the decision with its reasoning. Machine-readable, so that release and audit can build on it.
Q: How do you enforce the four-eyes principle technically?
A: Separate identities and keys for checking and releasing, a technical block against self-release, and an import that only runs with a validly signed release. The roles are assigned via groups in identity management, not via variables.
Q: A team complains that the airlock is too slow. What do you do?
A: First measure where the time is lost: scan, waiting for release, or transport. Then improve in a targeted way, for example with an automatic pre-check already in Zone A, clear release hours or deputy rules. Do not abolish the checks themselves; move them earlier.
Summary
Here is what you learned:
- Zones separate areas with different protection requirements. Data flows via airlocks or data diodes, preferably one-way and without inbound connections into the protected zone.
- A transfer bundle consists of an OCI layout, a delivery note, a hash
list and a sender signature.
oras cp -rexports image and referrers in a digest-preserving way. - The quarantine checks in a fixed order: transport hash, archive hygiene, sender signature, individual hashes, digest consistency, and content via Trivy with a threshold.
- The result is a machine-readable check record. Technically passed does not yet mean released.
- The release is done by a second person, is signed, and is bound to the bundle hash, image digest and check record.
- The import verifies the release again and then compares the digest in the target zone. Only if they are equal is the transfer successful.
- A gap-free audit log connects the running pod with build, check and release.