Artifact attestations

19 Aug 2024

Boosting supply chain security

3 minutes reading time

Palm ReaderUnabridged

#Overview

I have been waiting for something like this for quite some time, and a few months ago, GitHub rolled out its Artifact Attestations (still in beta). Powered by Sigstore, the idea is simple—these attestations ensure the build environment and the source code. Artifacts are linked to their repositories and the build process with cryptographically signed claims—attestations. Consumers then use these attestations to verify binaries (packages, images, SBOM, etc.) with GitHub's CLI application (v2.49.0 or higher). Presently, there is no other tool besides gh that could be used to verify attestations. But this should change soon.

Ian Lewis wrote an informative breakdown in which he expands on the internals of the main utility action (actions/attest-build-provenance).

#Basic deployment

The attest-build-provenance action is the main tool required for basic integration.

permissions:
  id-token: write
  contents: read
  attestations: write
- name: Attest
  uses: actions/attest-build-provenance@v1
  with:
    subject-path: 'PATH/TO/BINARY'

All set! Swell!

#Software Bill Of Materials

Use sbom-action with attest-sbom to process files like cargo.lock or requirements.txt:

- name: Generate SBOM
  uses: anchore/sbom-action@v0
  with:
    path: ./
    artifact-name: sbom.spdx
 
- name: Attest SBOM
  uses: actions/attest-sbom@v1
  with:
    subject-path: 'PATH/TO/BINARY'
    sbom-path: 'sbom.spdx'

#Container images

This setup will push images to the container registry (push-to-registry). Docker's build-push-action could be used to build the image and provide outputs.digest to the attestation step.

permissions:
  id-token: write
  contents: read
  attestations: write
  packages: write
- name: Attest
  uses: actions/attest-build-provenance@v1
  with:
    subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
    subject-digest: ${{ steps.build.outputs.digest }}
    push-to-registry: true

#Verification

Verify attestations prior usage:

- name: Verify attestation
  shell: bash
  env:
    GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  run: |
    gh attestation verify PATH/TO/BINARY \
      --owner "$GITHUB_REPOSITORY_OWNER"

#SLSA Build L3

The attest-build-provenance action by itself in the regular workflow can meet the requirements for SLSA Build Level 2. To harden the build to L3, the attesting workflow must be isolated from the main workflow:

Prevent secret material used to sign the provenance from being accessible to the user-defined build steps.

This could be achieved with reusable workflows that are executed in separate VMs. I will use my xtxf repository as an example.

Move all release steps to a new workflow, set on to a workflow_call trigger, and add required permissions.

cd.yml:

name: CD
on:
  workflow_call:
    inputs:
      tag_name:
        required: true
        type: string

permissions:
  id-token: write
  contents: read
  attestations: read

env:
  ZIG_VERSION: 0.13.0

jobs:
  release:
    name: Create release
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false

      - uses: taiki-e/create-gh-release-action@v1
        with:
          changelog: CHANGELOG.md
          token: ${{ secrets.GITHUB_TOKEN }}

  build-linux:
    name: Build / Linux
    runs-on: ubuntu-latest
    needs: [release]
    permissions:
      id-token: write
      contents: write
      attestations: write

    strategy:
      fail-fast: false
      matrix:
        target:
          - "x86-linux"
          - "x86_64-linux"
          - "aarch64-linux"

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          persist-credentials: false

      - name: Install Zig
        uses: goto-bus-stop/setup-zig@v2
        with:
          version: ${{ env.ZIG_VERSION }}

      - name: Build
        run: |
          zig build -Dtarget=${{ matrix.target }} --release=safe
          mv zig-out/bin/xtxf xtxf
          tar -czvf xtxf-${{ matrix.target}}.tar.gz xtxf

      - name: Attest
        uses: actions/attest-build-provenance@v1
        with:
          subject-path: 'xtxf-${{ matrix.target}}.tar.gz'

      - name: Upload
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

        run: |
          gh release upload ${{ inputs.tag_name }} \
          xtxf-${{ matrix.target }}.tar.gz

      - name: Verify attestation
        shell: bash
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

        run: |
          gh attestation verify xtxf-${{ matrix.target}}.tar.gz \
          --owner "$GITHUB_REPOSITORY_OWNER"

Call CD from a test workflow if all release requirements are met. In this case, version tags, successful test jobs, and repository owner are used to trigger the release workflow.

ci.yml:

name: CI
on: [push, pull_request]

permissions:
  id-token: write
  contents: read
  attestations: read

env:
  ZIG_VERSION: 0.13.0

jobs:
  test:
    name: Test
    strategy:
      matrix:
        os: [ubuntu, macos]
        mode: ["fast", "safe", "small", "off"]

    runs-on: ${{ matrix.os }}-latest
    steps:
      - uses: actions/checkout@v4
      - uses: goto-bus-stop/setup-zig@v2
        with:
          version: ${{ env.ZIG_VERSION }}

      - name: Build
        run: zig build --release=${{ matrix.mode }} \
        --verbose --summary all
      - name: Test
        run: zig build test --release=${{ matrix.mode }} \
        --summary all

  release:
    name: Release
    needs: [test]
    permissions:
      contents: write
      id-token: write
      attestations: write

    if: |
      github.repository_owner == 'charlesrocket' &&
      startsWith(github.ref, 'refs/tags/')

    uses: ./.github/workflows/cd.yml
    with:
      tag_name: ${{ github.ref_name }}

Now the attestation steps are isolated in a reusable workflow, satisfying salsa L3 requirements. This workflow will be triggered only by tags in the original repository.

A live version of the example is available here.

Use the repository's Actions management section or a direct link to access the attestations (API).

Documentation

#Conclusion

With forge-proof paper trails, artifact attestations bring new levels of transparency and security to the modern trust model. On the other hand, all attestation workflows have to be executed exclusively by GitHub-owned runners; this would be a dealbreaker for many operations.



/sw-load.js?v=e5ae5a1ed170f4499ac6292e7164b68528c51f6d6518cd75a49e6a6b737831d5728da21fc14dcbc7a91328e53858c6ff7195cc3fc8b25f0feeaef2af151d6686 /fireball.gif?v=569e393374f2af74d6c575090904aaf51e641e5eb5ea89ae7c7de01f7293abc165b3a7e8685690a8b951c778603fec98ae6822ff2f7ea86a536776966cb65d5d /favicon.ico?v=567b2c46a088e63823e13b652b92da58704c6b16553c24233c4a278ed10bc140dbc33abeedca5a1d405573e969bb60817c486af44965523ef2b2728d95fa16bf /favicon-16x16.png?v=766c396392bdc878b2c7523f62c2dcf2ad032d6cd8e358929b01f3d818f2004d9b0e5373f238531610fc76213f0baf4277d2829bce99fc0f320acaa409a0a8a5 /favicon-32x32.png?v=d352b969ba7272dad6f633a7680be1c3aa69812969bb3cc30d309b2191aad9f15056fe02b7a5ec7ecdd60129c928aada7ac9ed7f91b75c0c3789d09d271dbb02 /icon-192x192.png?v=3820c1b1e6d755d2b7c2a04a65f0f1feef793b297f7ee995947137ccd8f73ec304457f6ce1df987a9a0a13ed7dacd203225505b832ccd2318b530ae53a55cebc /icon-512x512.png?v=de62ae905479fd813300d286ed1d2fe6bb6f6292623a5d918691642f6dd09a68943c69ed2a95a1820076919e69ff4fda668bb79e610ebc1d3200fedd7f634443 /apple-touch-icon.png?v=7d58193104489f7a38359ca1e259f555d9b694d60b67b4f718f2bc71f9c21afd87329bc492bd760b112a1900d545e1472858c0e079aec7986afc4e1801561a98 /main.css?v=8ab3ba2ea49a89d1cee56b62a947c88597785d0842586199965b60438f9430279525aef9d01320077a32656df3e7435d48ccd7228cfc9bcd6a97ff0a4cc79358 /nerd-fonts.css?v=4213ecfcacca379b433c0fd135281c627c074e42d243cca41777df5738649704db63d448a19b13f80dfc9337485d8a1eb1a4b77cf2fa9d1fe2d3b6768c66e7bb /unstyle.css?v=b14bd48a2efbd463d973763aa3184c69aa02164c0891acacc9eab49ddd275f98f0050b4c31d2093e4671e7abe04f9459a041f0064384a90d97b8ff21b6824825 /langs.css?v=12474958ee314a9fde4704e1f5a032dc632d41f9461faca326ac284297766c4ceb07b45fec7fbc09fa72b0f21dcc64f0c31e64fc2e5e838b1d30f5fe540afd78 /syntax-theme-light.css?v=ccdddc2d2d88953c6d7d0376777b8409028ef625a7321dfa41619547b4f5eddbe89aa95ff5e7e2620da0ea13fbabebe2fd544620bc7e81e3294776b3425df48a /syntax-theme-dark.css?v=dfede4879841e4a58e5fc71115aa5f5b82e206d85eb771ff4e5a40a1d82621570aad2458f637365ae4370d9a1cf5070edc9765f7c2d4506e12e2ba3c6081ffd5 /sw-style.css?v=352cab856807e725351d62a9cae9dc445a675ab7e0bb0d3b12440b08dd574526c62827a5f4af706f7ad74df996a7f71f2c2a306fc1b188e1560007f0d4eda4fc /posts/page/2/ /categories/ /categories/hardware/ /categories/software/ /categories/thoughts/ /tags/ /tags/8bit/ /tags/arduino/ /tags/backup/ /tags/blockchain/ /tags/btc/ /tags/c/ /tags/cli/ /tags/crystal/ /tags/defcon/ /tags/desktop/ /tags/esp32/ /tags/freebsd/ /tags/game/ /tags/git/ /tags/github/ /tags/gtk/ /tags/gui/ /tags/hyprland/ /tags/javascript/ /tags/mtg/ /tags/netlify/ /tags/ops/ /tags/p2p/ /tags/photo/ /tags/pwa/ /tags/rpi/ /tags/rust/ /tags/security/ /tags/sigstore/ /tags/slsa/ /tags/ssg/ /tags/sway/ /tags/tera/ /tags/wayland/ /tags/web3/ /tags/zola/ /posts/artifact-attestations/ /posts/capable-pwa/ /posts/halve-zola/ /posts/halve-zola/halve-z.png?v=105df2d052e797d8013e44e7b2f968b3486122ef9528ed943b77c71cf34f9173a993b98a5b0387d162813f6ee68b12373ed9c517de510e9772d35e88fa61a0a1 /posts/salton-sea/ /posts/salton-sea/sltn.png?v=334fa312698c6d28ab5227118a994c3a4cf5c49b7d978280699aa46ebf1ab8eef6a04bdebc994c3ef2646d8e9ee53dbf537213c4e6ade4f83479e4914866f71d /posts/structs-5x/ /posts/structs-5x/asteroid.png?v=e5091cedbe1600a1c0da533a84f584ad054eeb67f66b224538258d2b49fe2b478a37afb8e9b30f52f16574c4dbfec6d1acf66665348756a650a92d55c195f446 /posts/structs-5x/guild-world.png?v=ae1b0e6ad7e8322a91a64cf024e3780f4cf239b40fe9ad177266d137970c148c7f978f84531d28c101d143817cefd839ac8dd73c19bd78f94f4fc858d53fd6d4 /posts/structs-5x/mech.png?v=0a0cd66081c651a6398da5d92cfbe27a709b7434533846757bad12c1a0625b75a044d345b1c3a0c41b58b19fd68a7b066e84abd4644be130945f409f5f2812b8 /posts/structs-5x/planet.png?v=49df2ea23f07b3c578ef2c58321923c5720b31fbc6e9df5f0173dcbb7f6697d380d5ac3effffd8a94b36e1ac02387ce0194e87dcc8125118a768690e182bf506 /posts/structs-5x/player.png?v=55aeef8f35fd3d590c1deda9c298590f4d73be8adc9e890d5dba16688e3db31df5e6132c66d40d10671c74cd8f4d3aedd696363470758834e7111b5b0585c54c /posts/structs-5x/structs-logo.png?v=96d9115f9d33f8042ea9e138812910443009aaf502cacd49a997a713fe45b712609fc4ca9c2dae57fdee4f5263f96e78d786ada4fecee5549739680a45a69f97 /posts/structs-5x/structure.png?v=c7b137796752843b19d6d73774fe4bd227a355f65dcfe4eb4f650cff419196e1c65bf807c81aa625e0abfbdb027c07791659824af9724e3fa29bc257d9fc839f /posts/structs-5x/unit-damaged.png?v=f0e21d0094ba57f23c4f395bdde12bde2593a201103e4e21efb145255429eae236638b6e91b464d2bb0b35849912799c6807e981d26aa248fa246306bcf9c119 /posts/jekyll-to-zola/ /posts/dorst/ /posts/dorst/dorst-v0.9.mov?v=4576efb3aad712332935c0a6782ce518d7178d5dc2a347f7a0e04c97c0b629d45c9e70b3a07bcb446c590cea82f0854e7fc34abd09935b7204555ca21cf84dd1 /posts/dorst/dorst-v0.9.mp4?v=bd4f08b57071073f9ea59cf66549ade66bab761e85dacf908741d2638fc9cae0f5521b55f8d413692743c91793ec9495d7a396f3dd9d95e317b913895d2131f8 /posts/dorst/dorst.png?v=1b7ab6363cc1c5165f8db8e5397da846eef566b0082d2ab8e56db7efe3c64b12fb12b6fbbee70c4a2fc6923aa27c40eb8db74c1095428c332e45522bfd305433 /posts/dorst/dorst_cli-v0.8.png?v=848afd24e25a589250e10b1a1136bf3282abc3fe7822cf5551b843c32f4fefa6df311e7a613e7389a4873f8233551af87c0df08a621aef177fe5c70cf9edc4b9 /posts/dorst/dorst_gui-v0.8.png?v=f8020de9e04f7120fc4e49b7a99018113065af639eec786c23050a2f9985dd1f870dee7f27402fdc5293f08974549fc03471c6169d9b2968417a3c7004c78563 /posts/eww/ /posts/eww/eww-bar.gif?v=7e007841131a309c6193d4437177830b2f4b81f7e1eda2b8a24d1d1081c9787aa1be8346de480263f643999fbf6b7a41d308317cb6cca1033571402ec09d68d8 /posts/eww/eww-fbsd.png?v=92b9cd257ea986e1672be69da6e6c3767b60a21b734b91712d3dd630fef85c4b3ad4e7d41404864bf80fdabe90c63cee5399a1dd71264db759d6ae82b94d6e07 /posts/fbsd-sway/ /posts/fbsd-sway/fbsd-scrn0.gif?v=fdb3953c2aa5e50f62cae4498551dabffdc5188a9841592d6c5cd88ee58a6d2aaf94553b3659e03cbb32e897699362b2a8d7b6c30d4b9bb56ac0515a43c9f4b3 /posts/fbsd-sway/fbsd-scrn1.gif?v=002b4ba61f4b0f97c5fbf1a26531ae285d937caff1db372358a21bd1c39cc41464e5dfb429e3ce3ce5b22f259bbfda6c87aff28511ea09b5366c52c9272928a1 /posts/fbsd-sway/fbsd-scrn2.gif?v=dc950dc1fc551edd48edb95ae1ac7764efd1f10542349e38c8ba07db0106df825014456be11d8438a2ea47222a8c8384569ac2b8da034509e1ee53dfa706589d /posts/fbsd-sway/fbsd-scrn3.gif?v=10bef3c146682734274eec93c9126c0ccb01f5604dd0a4d9ab5c573fd6c272d3feb4e44fcc9c11acbd88693797558acd9ee2900e61adca305e362d559e37d68c /posts/fbsd-sway/fbsd.png?v=3f8879dd19d9ba41b3bcf2a26f39651908e01d2a4c09c69481172092d6b6ded6721d7136d94b8727627e63ddd76093922268a4d15bae80dc71864615e05c5181 /posts/frightcrawler/ /posts/frightcrawler/frightcrawler.gif?v=23c7a6ca57472965b04aab8cfbcaf63cb00d03409796968faa3e55af4fb3d09f43b66b7ee27079a565b4212053feed4c3540b82b79281131b93ad5158eac4c2c /posts/frightcrawler/frightcrawler.png?v=e494742b0056a58d1ca95f167267954f57b26404d2f6f8f55e1652cb564964e411bdd6c4de2c016856831ae5978e8ac446ae7d105429ed11b92d2053f1d8d7e4 /posts/watchy/ /posts/watchy/watchy-skully.jpg?v=61f09412064a217e425f804315e8d93744fb25425a68a555d871fe733ab7a321b67eeea4b75154f6737cae4ec73cfb02c2f006b6eed2b15e7422cf9396c68fe7 /posts/watchy/watchy.gif?v=e48d6903f4b488803fc961da2ebd88c7055314d9faa19d622356aade85f5d06a9fa8a3edf12468cbfea1b39b9916628b91bce192add85cf0d6491be2224760d7 /posts/raspiblitz/ /posts/raspiblitz/rpi-mbp.gif?v=3cac257ea0e433ac84f7ab561da1734d248056def2555f91d50637a5538c5d2117f39ed89492a4245d3cfa5bd54a33dc75ff79fb597f1ba1786ef650473d3fc6 /posts/raspiblitz/rpi-mbp.jpg?v=ec925c52095b0e9172af2b4e5426e7bfbc386a0a952dec8475b669d30c0540459af7070632ac0aa781f0d2fa0c6a645812a18a7dd389b92901291444e211a943 /projects/ https://failsafe.monster/pgp/ /posts/ hcw.png?v=dcafb57f895230771fe523da42bc8a7cc9dc7c2a8aedad2c3b8a1067d53848365e47cc29c9386689004a1377d463a9937458f62378c31161186b6d8bbbe7c2d0 lab02.png?v=718c294e0f34b9acf53545dc2b27da9cec0cba7b87b04bc65e480944448e57843ff35a41a3bed62d79596640372c13aaca55738d501704b6779ea996d32ea639 ca-desktop.png?v=5c719e31f2f292fc44e6c97502d4aeae2f7a95f9454edf5bbb4535aafedffe125a21f22c6e2cd540253d08c75061fd42f16cfd0bf8e1a9dbe6cf5a90703b3c2d c1tyh4ll.png?v=ec315485b21d56fc61d2e61ad3770132ee4be0092f03c147b2633ab21e7301b0929c1e33e1b3009d041245b5ec3c28425753671631658a3e8990c670886f515a bk-prk.jpg?v=897a5eb8ebf4bcb7f2fae7f66c635e015fe06d456bf0b966ac85978477514710c16669240bf96166fda750b7099183f4bf45c0135569eb8442ab95e4bef681e4 bk-prk.jpg?v=897a5eb8ebf4bcb7f2fae7f66c635e015fe06d456bf0b966ac85978477514710c16669240bf96166fda750b7099183f4bf45c0135569eb8442ab95e4bef681e4 /avatar.png?v=c20e8c14263600f7303296d95a0fadc69211353358ed873b15c0050f7a07f3d6fee2b88897a557c85ca59264f2586bd90382270c09efff6204e1361f1860b2c6 /glitch.css?v=0b9b7f8691385df5b832251e9cf4c56d68cbcfc98c6e4c27e015f6fb29d2f0c18c358c98c0e7e0a1da9f263d6b355b811e49aac099b70889090912a5040f754a /sitemap.xml /search_index.en.json /search.js /elasticlunr.min.js?v=b9be63b71422cbfde9f14310b397d9a7092f2946bffec11811a831398ace978c1c592e9a578f1fa32041e6c0dde68657fe58d3c30b0eaa758c63c5fd45117336">