テック技報最新号へ →
コード

GitHub Actions: actions/attest で成果物に provenance 証明書を付け、SLSA Level 3 に近づける

手元やプライベート環境でビルドしたバイナリをそのまま配るのはもう推奨できない。パブリックな Actions 上でビルドし、actions/attest で署名付き attestation を付け、Release を immutable にすると、利用者が gh attestation verify で来歴を検証できる。

@songmu · 投稿 2026-10-11
#github-actions#security#slsa#attest#サプライチェーン

方針(5点)

  1. 入力のソースはタグなど明確な ref
  2. ビルドは独立した reusable workflow(workflow_call)に分離
  3. 透明性の高い(できればパブリックな)Actions 上でビルド
  4. actions/attest で成果物に証明書を付与(旧 actions/attest-build-provenance は統合済み)
  5. リポジトリ設定で Immutable releases を有効化

ワークフロー例(要点)

yaml
# release-build.yaml(reusable)
permissions:
  attestations: write
  contents: read
  id-token: write
steps:
  - uses: actions/checkout@<sha>
    with:
      persist-credentials: false
  # ... ビルドして dist に成果物を出す ...
  - uses: actions/attest@<sha>
    with:
      subject-path: "dist/*"
  - uses: actions/upload-artifact@<sha>
    with:
      name: release-${{ github.ref_name }}
      path: "dist/*"

呼び出し側はタグでのみ起動し、artifact を落として gh release create する構成にする(build と publish を分離)。

検証

bash
gh attestation verify "$artifact.tar.gz" \
  --hostname github.com \
  --repo "$REPO" \
  --source-digest "$commit" \
  --signer-digest "$commit" \
  --signer-workflow "$REPO/.github/workflows/release-build.yaml"

注意点

  • id-token: write と attestations: write が必要。署名鍵の自己管理は不要(Sigstore の短命証明書)。
  • 再現性(OS/runner 固定、Actions の SHA pin、タイムスタンプ固定など)も合わせて進めると効く。Actions の pin は GitHub Actions: pinact で uses: をコミット SHA に固定する も参照。
  • プライベートリポジトリは GitHub 側 Sigstore インスタンスを使う(公開の transparency log とは別)。

出典

X の元の投稿を開く