GitHub Actions: actions/attest で成果物に provenance 証明書を付け、SLSA Level 3 に近づける
手元やプライベート環境でビルドしたバイナリをそのまま配るのはもう推奨できない。パブリックな Actions 上でビルドし、actions/attest で署名付き attestation を付け、Release を immutable にすると、利用者が gh attestation verify で来歴を検証できる。
方針(5点)
- 入力のソースはタグなど明確な ref
- ビルドは独立した reusable workflow(
workflow_call)に分離 - 透明性の高い(できればパブリックな)Actions 上でビルド
actions/attestで成果物に証明書を付与(旧actions/attest-build-provenanceは統合済み)- リポジトリ設定で 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 とは別)。