From ada07d98757b1b78de49277b9747a13c55ad5a44 Mon Sep 17 00:00:00 2001 From: RII6 Date: Sun, 28 Jun 2026 18:49:13 +0300 Subject: [PATCH 1/2] feat(lab8): cosign sign + SBOM/provenance attestations + blob signing --- labs/lab8/keys/cosign.pub | 4 ++ submissions/lab8.md | 115 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 labs/lab8/keys/cosign.pub create mode 100644 submissions/lab8.md diff --git a/labs/lab8/keys/cosign.pub b/labs/lab8/keys/cosign.pub new file mode 100644 index 00000000..9618890f --- /dev/null +++ b/labs/lab8/keys/cosign.pub @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAErdgDC0Vbqi9v9GmKO8H5Yu95JZDS +Z2tdy1Ik6fFI6kF5Jd2UT9KdlrpuB4giefXw6+QmjA3E9fLy9m8B5aHy7w== +-----END PUBLIC KEY----- diff --git a/submissions/lab8.md b/submissions/lab8.md new file mode 100644 index 00000000..9c1a7c62 --- /dev/null +++ b/submissions/lab8.md @@ -0,0 +1,115 @@ +# Lab 8 — Submission + +## Task 1: Sign + Tamper Demo + +### Registry + image push +- Registry container: `lab8-registry` running on `localhost:5001` +- Image pushed: `localhost:5001/juice-shop:v20.0.0` +- Image digest: localhost:5001/juice-shop@sha256:cbdfc00de875926f20ff603fac73c5b68577e37680cf2e0c324adda42ffc1113 + +### Signing +- Output of `cosign sign` (just the success line is fine): +``` +Pushing signature to: localhost:5001/juice-shop +``` + +### Verification (PASSED) +Output of `cosign verify` on original digest: +```json +[{"critical":{"identity":{"docker-reference":"localhost:5001/juice-shop@sha256:cbdfc00de875926f20ff603fac73c5b68577e37680cf2e0c324adda42ffc1113"},"image":{"docker-manifest-digest":"sha256:cbdfc00de875926f20ff603fac73c5b68577e37680cf2e0c324adda42ffc1113"},"type":"https://sigstore.dev/cosign/sign/v1"},"optional":{}}] +``` + +### Tamper Demo (FAILED — correctly) +Output of `cosign verify` on tampered digest: +``` +WARNING: Skipping tlog verification is an insecure practice that lacks transparency and auditability verification for the signature. +Error: no signatures found +error during command execution: no signatures found +``` + +### Sanity — original still verifies +``` +WARNING: Skipping tlog verification is an insecure practice that lacks transparency and auditability verification for the signature. + +Verification for localhost:5001/juice-shop@sha256:cbdfc00de875926f20ff603fac73c5b68577e37680cf2e0c324adda42ffc1113 -- +The following checks were performed on each of these signatures: + - The cosign claims were validated + - Existence of the claims in the transparency log was verified offline + - The signatures were verified against the specified public key +``` + +### Why digest binding matters (Lecture 8 slide 6) +Digest binding guarantees that we are signing the exact immutable bits of an image rather than a mutable tag pointer. If Cosign had signed the tag, an attacker could push a malicious image to the same tag (like `v20.0.0`), and naive verification tools would trust the compromised image because the tag name itself would have a valid signature attached to it, leading to a supply-chain compromise. + +--- + +## Task 2: SBOM + Provenance Attestations + +### SBOM attestation +- Attached: yes (`cosign attest --type cyclonedx` exit 0) +- Verify-attestation output (first 30 lines of decoded payload): +```json +{ + "_type": "https://in-toto.io/Statement/v0.1", + "predicateType": "https://cyclonedx.org/bom", + "subject": [ + { + "name": "localhost:5001/juice-shop", + "digest": { + "sha256": "cbdfc00de875926f20ff603fac73c5b68577e37680cf2e0c324adda42ffc1113" + } + } + ], + "predicate": { + "bomFormat": "CycloneDX", + "specVersion": "1.6", + "serialNumber": "urn:uuid:155e81f1-3958-45e0-b615-1a8dbb5df200", + "version": 1, + "metadata": { + "timestamp": "2026-06-28T14:33:00Z", + "tools": { + "components": [ + { + "type": "application", + "author": "aquasecurity", + "name": "trivy", + "version": "0.50.1" + } + ] + } + } + } +} +``` +- Component count matches Lab 4 source: yes +- diff between Lab 4 SBOM and the extracted-from-attestation SBOM: (empty diff = success) + +### Provenance attestation +- Attached: yes +- Builder ID in predicate: `https://localhost/lab8-student` +- buildType in predicate: `https://example.com/lab8/local-build` + +### What this gives a Lab 9 verifier (2-3 sentences) +Having both signatures and attestations позволяет Kubernetes admission controller (например, Kyverno) проверять не только то, кем был собран образ, но и его содержимое (SBOM). Когда появляется новая уязвимость (Log4Shell), аттестованный образ гарантирует, что встроенный SBOM является подлинным и не был подменен. Это позволяет службам безопасности моментально опрашивать запущенные приложения на наличие уязвимых компонентов, не доверяя слепо непроверенным спецификациям от сторонних поставщиков. + +--- + +## Bonus: Blob Signing (Codecov 2021 mitigation) + +### Sign + verify +- Signed: `my-tool.tar.gz` + `my-tool.tar.gz.bundle` +- Verify-blob success output: +``` +WARNING: Skipping tlog verification is an insecure practice that lacks transparency and auditability verification for the blob. +Verified OK +``` + +### Tamper test failed (correctly) +``` +WARNING: Skipping tlog verification is an insecure practice that lacks transparency and auditability verification for the blob. +Error: failed to verify signature: could not verify message: invalid signature when validating ASN.1 encoded signature +error during command execution: failed to verify signature: could not verify message: invalid signature when validating ASN.1 encoded signature +``` + +### Codecov 2021 mitigation (2-3 sentences) +Компрометация Codecov произошла потому, что клиенты скачивали bash-скрипт и напрямую выполняли его (`curl | bash`) без какой-либо криптографической проверки целостности. Если бы CI-пайплайны требовали скачивания самого скрипта и его бандла с подписью, а затем перед выполнением запускали `cosign verify-blob`, то подмененный хакерами скрипт мгновенно не прошел бы проверку (invalid signature), что полностью предотвратило бы атаку на цепочку поставок сотен компаний. From 0fae20e1f85911b30d2930aa4c89a89e90d04a4d Mon Sep 17 00:00:00 2001 From: RII <104525820+RII6@users.noreply.github.com> Date: Mon, 29 Jun 2026 17:18:13 +0300 Subject: [PATCH 2/2] feat(lab8): fixed lab8.md Translated sections from Russian to English for clarity and accessibility. --- submissions/lab8.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/submissions/lab8.md b/submissions/lab8.md index 9c1a7c62..620c8cce 100644 --- a/submissions/lab8.md +++ b/submissions/lab8.md @@ -90,7 +90,7 @@ Digest binding guarantees that we are signing the exact immutable bits of an ima - buildType in predicate: `https://example.com/lab8/local-build` ### What this gives a Lab 9 verifier (2-3 sentences) -Having both signatures and attestations позволяет Kubernetes admission controller (например, Kyverno) проверять не только то, кем был собран образ, но и его содержимое (SBOM). Когда появляется новая уязвимость (Log4Shell), аттестованный образ гарантирует, что встроенный SBOM является подлинным и не был подменен. Это позволяет службам безопасности моментально опрашивать запущенные приложения на наличие уязвимых компонентов, не доверяя слепо непроверенным спецификациям от сторонних поставщиков. +Having both signatures and attestations allows a Kubernetes admission controller (such as Kyverno) to verify not only who built the image, but also its contents (SBOM). When a new vulnerability (like Log4Shell) emerges, an attested image guarantees that the embedded SBOM is genuine and has not been tampered with. This enables security teams to instantly query running applications for vulnerable components without blindly trusting unverified specifications from third-party vendors. --- @@ -112,4 +112,4 @@ error during command execution: failed to verify signature: could not verify mes ``` ### Codecov 2021 mitigation (2-3 sentences) -Компрометация Codecov произошла потому, что клиенты скачивали bash-скрипт и напрямую выполняли его (`curl | bash`) без какой-либо криптографической проверки целостности. Если бы CI-пайплайны требовали скачивания самого скрипта и его бандла с подписью, а затем перед выполнением запускали `cosign verify-blob`, то подмененный хакерами скрипт мгновенно не прошел бы проверку (invalid signature), что полностью предотвратило бы атаку на цепочку поставок сотен компаний. +The Codecov compromise occurred because clients were downloading a bash script and executing it directly (`curl | bash`) without any cryptographic integrity checks. If CI pipelines had required downloading both the script and its signature bundle, and then ran `cosign verify-blob` before execution, the hacker-modified script would have instantly failed verification (invalid signature). This would have completely prevented the supply chain attack from impacting hundreds of companies.