SlideShare a Scribd company logo
OpenPubKey によるイメージの署名と検証
NTT ソフトウェアイノベーションセンタ
須⽥ 瑛⼤
DockerCon 2023 ハイライト (2023/11/2)
• Moby (Docker Engineのupstream)、BuildKit、containerd、runc などの
OSSのコミッタ
• 今年のDockerConでは “Reproducible builds with BuildKit for software
supply chain security” に関して登壇
– https://medium.com/nttlabs/dockercon-2023-reproducible-builds-with-buildkit-
for-software-supply-chain-security-0e5aedd1aaa7
• 今⽇は⾃⾝の取り組みについてではなく、 Docker社・BastionZero 社に
よる OpenPubKey への取り組みについて紹介
• Reproducible builds にも OpenPubKey を応⽤していきたいと思っている
2
⾃⼰紹介
• 2023/10/4: Demystify Secure Supply Chain Metadata
– Christian Dupuis, Sr Principal Engineer, Docker
• 2023/10/5: Building the Software Supply Chain on Docker
Official Images
– Ethan Heilman, CTO & Co-Founder, BastionZero
James Carnegie, Computer Programmer, Docker
• https://www.dockercon.com/ からまだ視聴可能
3
DockerCon での OpenPubKey 関連セッション
4
Linux Foundation プロジェクト化のアナウンス
https://www.linuxfoundation.org/press/announcing-openpubkey-project
• OpenID Connect (OIDC) を応⽤し、公開鍵基盤として使えるようにしたもの
“In essence, OpenPubkey is a protocol for getting OpenID Providers (OPs) to bind
identities to public keys.” ( https://github.com/openpubkey/openpubkey )
• 例えば、GitHub Actions 上でDockerイメージをビルドする際に、GitHubリポジト
リのorganization IDを含む署名を付加できる
• GitHub Actions の Secrets に秘密鍵をアップロードしたりしなくてよい
• GitHub Actions 以外の OpenID プロバイダ への対応も容易。
プロバイダ側での対応作業は(原則的に)不要。
• Sigstore の Cosign (keyless) に似ているが、よりシンプルな構成
5
OpenPubKey
• GitHub ActionsのYAML:
https://github.com/openpubkey/demo
• BuildKit へのパッチ (未マージ):
https://github.com/openpubkey/buildkit/tree/opk-signing
• docker verify コマンド:
https://github.com/openpubkey/verify-docker-cli-plugin
6
DockerConでのOpenPubKeyのデモ
7
GitHub Actions の YAML
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3.0.0
with:
driver-opts: |
image=openpubkey/buildkit:opk-signing
env.ACTIONS_ID_TOKEN_REQUEST_URL=${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }}
env.ACTIONS_ID_TOKEN_REQUEST_TOKEN=${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN }}
- name: Build and push Docker image on push
id: build-and-push
uses: docker/build-push-action@v4.0.0
with:
context: .
push: true
…
sbom: true
provenance: true
…
https://github.com/openpubkey/demo/blob/6b29027/.github/workflows/docker-build.yaml
8
GitHub Actions の YAML
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3.0.0
with:
driver-opts: |
image=openpubkey/buildkit:opk-signing
env.ACTIONS_ID_TOKEN_REQUEST_URL=${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }}
env.ACTIONS_ID_TOKEN_REQUEST_TOKEN=${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN }}
- name: Build and push Docker image on push
id: build-and-push
uses: docker/build-push-action@v4.0.0
with:
context: .
push: true
…
sbom: true
provenance: true
…
https://github.com/openpubkey/demo/blob/6b29027/.github/workflows/docker-build.yaml
GitHub により⾃動的に設定される
OIDC関連の環境変数を
BuildKit デーモン に伝播させる
OpenPubKeyに対応した fork を指定する
https://github.com/openpubkey/buildkit
SBOMおよびSLSA Provenance (ビルド情報) を
イメージに付加する。
併せて、SBOMやSLSA Provenance に対する署名
(i.e., イメージに対する署名) も付加する。
• Docker CLI プラグインとして提供
https://github.com/openpubkey/verify-docker-cli-plugin
• Docker Hub 上のイメージ “openpubkey/demo@sha256…” が、GitHub
organization “openpubkey” の GitHub Actions でビルドされたことを確認
できた
• ただし、GitHub Actions のキーセット
(https://token.actions.githubusercontent.com/.well-known/jwks) を信頼で
きる前提
9
docker verify コマンド
$ gh api /orgs/openpubkey | jq .id
145685596
$ docker verify openpubkey/demo@sha256:6acf54fca0e7f9e9ef3d23c9b9ee306ce3c56b8315aa756643e4df25032bcdbe 
--repo-owner-id 145685596
…
Verified all required attestations are present
10
docker verify コマンド (出⼒全体)
$ docker verify openpubkey/demo@sha256:6acf54fca0e7f9e9ef3d23c9b9ee306ce3c56b8315aa756643e4df25032bcdbe 
--repo-owner-id 145685596
Verifying 2 attestations for
pkg:docker/openpubkey/demo?digest=sha256:6acf54fca0e7f9e9ef3d23c9b9ee306ce3c56b8315aa756643e4df25032bcdbe&platform
=linux/amd64
Verifying https://spdx.dev/Document attestation
✓ Verified attestation refers to digest sha256:6fbb78f2482a527575558d85147aee5f5f9f5288133bb0af316f91ed525a7246
✓ Verified OIDC token was signed by https://token.actions.githubusercontent.com
✓ Verified attestation digest was signed on a Github Actions run:
https://github.com/openpubkey/demo/actions/runs/6628798402
✓ Verified repository owner 145685596 (openpubkey)
Verifying https://slsa.dev/provenance/v0.2 attestation
✓ Verified attestation refers to digest sha256:6fbb78f2482a527575558d85147aee5f5f9f5288133bb0af316f91ed525a7246
✓ Verified OIDC token was signed by https://token.actions.githubusercontent.com
✓ Verified attestation digest was signed on a Github Actions run:
https://github.com/openpubkey/demo/actions/runs/6628798402
✓ Verified repository owner 145685596 (openpubkey)
✓ Verified signed git sha provenance 6b29027d7ddae1c2dcdcfb88ab402473af5d20c8
✓ Verified signed git repo provenance openpubkey/demo
Verified all required attestations are present
11
フロー (1/2)
BuildKit
(OpenPubKey対応版) GitHub Actions
$ACTIONS_ID_TOKEN_REQUEST_TOKEN
$ACTIONS_ID_TOKEN_REQUEST_URL
HTTP GET
$ACTIONS_ID_TOKEN_REQUEST_URL
&audience=$AUDIENCE
“Authorization: bearer
$ACTIONS_ID_TOKEN_REQUEST_TOKEN”
• ID Token を発⾏するための
Bearer Token を発⾏
• イメージをビルドし、
provenanceを⽣成
• ⼀回限りの鍵ペアを⽣成
• Client-Instance Claim (CIC) を
⽣成
{‘rz’: random(),
‘upk’: publicKey,
‘alg’: ‘EC256’,
‘att’: provenenceHash}
• CIC のハッシュを “audience”
としてID Tokenの発⾏を要求
※CIC のハッシュは、GitHub Actions などの workload identity では audience に含めるが、user identity では nonce に含める。
audience (GHAのデフォルトでは リポジトリ
のURL) には任意の⽂字列をいれてよいので
OIDCのAPIを変更せずにCICのハッシュを送る
ことができる
12
フロー (2/2)
BuildKit
(OpenPubKey対応版) GitHub Actions
ID Token: “SUBSTR0.SUBSTR1.SUBSTR2”
• SUBSTR0: ヘッダ の base64
• SUBSTR1: ペイロードの base64
(“aud” などを含む)
• SUBSTR2: ”SUBST0.SUBST1” に対する
署名
• 受け取った Bearer Token が
合っていれば、ID Token を発
⾏する
• ID Tokenの主なペイロード:
• “aud” (audience)
• “repository_owner_id”
(GitHubのorgのID)
• “run_id” (GHAのjobの
実⾏ID)
• ID Tokenは、GHA⾃⾝が持っ
ている鍵で署名される
• ⼿持ちのCICと、GHAから受
け取ったID Tokenとを組み合
わせ、署名し、 PK Token を
構成する。これをイメージに
付加する。
• Guillou-Quisquater (GQ) 署名
により、元のID Tokenの値は
隠蔽される (ペイロードの
部分は公開される)
(前掲)
CIC: Client-Instance Claim: {‘rz’: random(), ‘upk’: publicKey, ‘alg’: ‘EC256, ‘att’: provenanceHash}
audience: ここでは CICのハッシュ
ID Token が鍵ペアに紐づく
※GQ署名はworkload identityでは必須、user identity では任意
GHAの場合はペイロードが公開されて問題ないが、
他のOpenIDプロバイダでは検討が必要そう
13
実際のデータ
https://oci.dag.dev/?image=openpubkey%2Fdemo%40sha256%3A6acf54fca0e7f9e9ef3d23c9b9ee306ce3c56b8315aa756643e4df25032bcdbe
14
実際のデータ
https://oci.dag.dev/?image=openpubkey%2Fdemo%40sha256%3A6acf54fca0e7f9e9ef3d23c9b9ee306ce3c56b8315aa756643e4df25032bcdbe
application/vnd.oci.image.manifest.v1+json
application/vnd.oci.image.manifest.v1+json
application/vnd.in-toto.provenance+dsse
15
実際のデータ
https://oci.dag.dev/blob/openpubkey/demo@sha256:f5daba3a4bcd7f76563a5ff36f6dab8f6e5e705d7b23e541a5913946a3a08bde/?
mt=application%2Fvnd.in-toto.provenance%2Bdsse&size=16563
デコードしないと読めない
https://onlinejsontools.com/convert-base64-to-json
16
{
"payloadType":"application/vnd.in-toto+json",
"payload": …,
"signatures":[{"keyid":"OPK","sig": …}]
}
{
"payload": …,
"signatures": [
{"protected": …, "header": {"sig_type":
"cic"}, "signature": …},
{"protected": …, "header": {"sig_type":
"oidc_gq"}, "signature": …}
]
}
.signatures[0].sig
{
"jti": "66e345cc-0806-42a0-a346-7b98dc8ab2c0",
"sub": "repo:openpubkey/demo:ref:refs/heads/main",
"aud": "5km4t6i4IPk-tnv4qlmCcryfY0O-4PCNWOmFCJZJrzI",
"ref": "refs/heads/main",
"sha": "6b29027d7ddae1c2dcdcfb88ab402473af5d20c8",
"repository": "openpubkey/demo",
"repository_owner": "openpubkey",
"repository_owner_id": "145685596",
"run_id": "6628798402",
"repository_id": "698282570",
"iss": https://token.actions.githubusercontent.com
…,
}
.payload
{
"alg": "ES256",
"att": …
"rz": …,
"upk": {"alg": "ES256", "crv": "P-256",
"kty": "EC", "x": …, "y": … }
}
{
"typ": "JWT",
"alg": "RS256",
"x5t": "AB3c0BSoSOiCRXez5POu2zvPX_0",
"kid": "001DDCD014A848E8824577B3E4F3AEDB3BCF5FFD"
}
.signatures[0].protected .signatures[1].protected
application/vnd.in-toto.provenance+dsse
(SLSA Provenance)
.payload
• OpenID Connect (OIDC) を応⽤し、公開鍵基盤として使えるようにしたもの
“In essence, OpenPubkey is a protocol for getting OpenID Providers (OPs) to bind identities to
public keys.” ( https://github.com/openpubkey/openpubkey )
• 例えば、GitHub Actions 上でDockerイメージをビルドする際に、GitHubリポジトリの
organization IDを含む署名を付加できる
• GitHub Actions の Secrets に秘密鍵をアップロードしたりしなくてよい
• GitHub Actions 以外の OpenID プロバイダ への対応も容易。
プロバイダ側での対応作業は(原則的に)不要。
• Sigstore の Cosign (keyless) に似ているが、よりシンプルな構成
17
まとめ (再掲)
スライド: https://github.com/AkihiroSuda
(“Presentation slides” → “2023” → “20231102 …”)

More Related Content

Similar to [DockerConハイライト] OpenPubKeyによるイメージの署名と検証.pdf

GitHubの機能を活用したGitHub Flowによる開発の進め方
GitHubの機能を活用したGitHub Flowによる開発の進め方GitHubの機能を活用したGitHub Flowによる開発の進め方
GitHubの機能を活用したGitHub Flowによる開発の進め方Takeshi Mikami
 
DevOps on Azure Kubernetes
DevOps on Azure KubernetesDevOps on Azure Kubernetes
DevOps on Azure KubernetesIssei Hiraoka
 
Metahub for github
Metahub for githubMetahub for github
Metahub for githubSuguru Oho
 
Docker事始めと最新動向 2015年6月
Docker事始めと最新動向 2015年6月Docker事始めと最新動向 2015年6月
Docker事始めと最新動向 2015年6月Emma Haruka Iwao
 
PlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC Webアプリケーション
PlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC WebアプリケーションPlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC Webアプリケーション
PlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC WebアプリケーションKazuhiro Hara
 
CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜
CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜
CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜Masaya Aoyama
 
DockerCon '17 Feedback at PaaS JP
DockerCon '17 Feedback at PaaS JPDockerCon '17 Feedback at PaaS JP
DockerCon '17 Feedback at PaaS JPGo Chiba
 
Recap: Modern CI/CD with Tekton and Prow Automated via Jenkins X - Kubernetes...
Recap: Modern CI/CD with Tekton and Prow Automated via Jenkins X - Kubernetes...Recap: Modern CI/CD with Tekton and Prow Automated via Jenkins X - Kubernetes...
Recap: Modern CI/CD with Tekton and Prow Automated via Jenkins X - Kubernetes...JUNICHI YOSHISE
 
はてなにおける継続的デプロイメントの現状と Docker の導入
はてなにおける継続的デプロイメントの現状と Docker の導入はてなにおける継続的デプロイメントの現状と Docker の導入
はてなにおける継続的デプロイメントの現状と Docker の導入Yu Nobuoka
 
GitLab から GitHub + CircleCI に乗り換えてチーム運用を改善しつつある話
GitLab から GitHub + CircleCI に乗り換えてチーム運用を改善しつつある話GitLab から GitHub + CircleCI に乗り換えてチーム運用を改善しつつある話
GitLab から GitHub + CircleCI に乗り換えてチーム運用を改善しつつある話R S
 
Getting Started With Ore-Ore Swift Standard Library +
Getting Started With Ore-Ore Swift Standard Library +Getting Started With Ore-Ore Swift Standard Library +
Getting Started With Ore-Ore Swift Standard Library +Tomohiro Kumagai
 
CircleCIを使ったSpringBoot/GAEアプリ開発の効率化ノウハウ
CircleCIを使ったSpringBoot/GAEアプリ開発の効率化ノウハウCircleCIを使ったSpringBoot/GAEアプリ開発の効率化ノウハウ
CircleCIを使ったSpringBoot/GAEアプリ開発の効率化ノウハウTakeshi Mikami
 
2021/03/19 パブリッククラウドを活かす運用プロセス自動化
2021/03/19 パブリッククラウドを活かす運用プロセス自動化2021/03/19 パブリッククラウドを活かす運用プロセス自動化
2021/03/19 パブリッククラウドを活かす運用プロセス自動化Issei Hiraoka
 
Dockerイメージの理解とコンテナのライフサイクル
Dockerイメージの理解とコンテナのライフサイクルDockerイメージの理解とコンテナのライフサイクル
Dockerイメージの理解とコンテナのライフサイクルMasahito Zembutsu
 
Yocto Project ハンズオン プレゼン用資料
Yocto Project ハンズオン プレゼン用資料Yocto Project ハンズオン プレゼン用資料
Yocto Project ハンズオン プレゼン用資料Nobuhiro Iwamatsu
 
Docker & Kubernetes基礎
Docker & Kubernetes基礎Docker & Kubernetes基礎
Docker & Kubernetes基礎Daisuke Hiraoka
 
今だからこそ知りたい Docker Compose/Swarm 入門
今だからこそ知りたい Docker Compose/Swarm 入門今だからこそ知りたい Docker Compose/Swarm 入門
今だからこそ知りたい Docker Compose/Swarm 入門Masahito Zembutsu
 
地味だけど劇的に便利になるGitHubリポジトリ設定あれこれ
地味だけど劇的に便利になるGitHubリポジトリ設定あれこれ地味だけど劇的に便利になるGitHubリポジトリ設定あれこれ
地味だけど劇的に便利になるGitHubリポジトリ設定あれこれKazumi IWANAGA
 
Developing inside a Container
Developing inside a ContainerDeveloping inside a Container
Developing inside a Containerarukoh
 

Similar to [DockerConハイライト] OpenPubKeyによるイメージの署名と検証.pdf (20)

GitHubの機能を活用したGitHub Flowによる開発の進め方
GitHubの機能を活用したGitHub Flowによる開発の進め方GitHubの機能を活用したGitHub Flowによる開発の進め方
GitHubの機能を活用したGitHub Flowによる開発の進め方
 
DevOps on Azure Kubernetes
DevOps on Azure KubernetesDevOps on Azure Kubernetes
DevOps on Azure Kubernetes
 
Metahub for github
Metahub for githubMetahub for github
Metahub for github
 
Docker事始めと最新動向 2015年6月
Docker事始めと最新動向 2015年6月Docker事始めと最新動向 2015年6月
Docker事始めと最新動向 2015年6月
 
PlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC Webアプリケーション
PlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC WebアプリケーションPlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC Webアプリケーション
PlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC Webアプリケーション
 
CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜
CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜
CI/CD Pipeline を考える 〜KubeCon 2017 + CyberAgent の最大公倍数〜
 
DockerCon '17 Feedback at PaaS JP
DockerCon '17 Feedback at PaaS JPDockerCon '17 Feedback at PaaS JP
DockerCon '17 Feedback at PaaS JP
 
Recap: Modern CI/CD with Tekton and Prow Automated via Jenkins X - Kubernetes...
Recap: Modern CI/CD with Tekton and Prow Automated via Jenkins X - Kubernetes...Recap: Modern CI/CD with Tekton and Prow Automated via Jenkins X - Kubernetes...
Recap: Modern CI/CD with Tekton and Prow Automated via Jenkins X - Kubernetes...
 
Tekton 入門
Tekton 入門Tekton 入門
Tekton 入門
 
はてなにおける継続的デプロイメントの現状と Docker の導入
はてなにおける継続的デプロイメントの現状と Docker の導入はてなにおける継続的デプロイメントの現状と Docker の導入
はてなにおける継続的デプロイメントの現状と Docker の導入
 
GitLab から GitHub + CircleCI に乗り換えてチーム運用を改善しつつある話
GitLab から GitHub + CircleCI に乗り換えてチーム運用を改善しつつある話GitLab から GitHub + CircleCI に乗り換えてチーム運用を改善しつつある話
GitLab から GitHub + CircleCI に乗り換えてチーム運用を改善しつつある話
 
Getting Started With Ore-Ore Swift Standard Library +
Getting Started With Ore-Ore Swift Standard Library +Getting Started With Ore-Ore Swift Standard Library +
Getting Started With Ore-Ore Swift Standard Library +
 
CircleCIを使ったSpringBoot/GAEアプリ開発の効率化ノウハウ
CircleCIを使ったSpringBoot/GAEアプリ開発の効率化ノウハウCircleCIを使ったSpringBoot/GAEアプリ開発の効率化ノウハウ
CircleCIを使ったSpringBoot/GAEアプリ開発の効率化ノウハウ
 
2021/03/19 パブリッククラウドを活かす運用プロセス自動化
2021/03/19 パブリッククラウドを活かす運用プロセス自動化2021/03/19 パブリッククラウドを活かす運用プロセス自動化
2021/03/19 パブリッククラウドを活かす運用プロセス自動化
 
Dockerイメージの理解とコンテナのライフサイクル
Dockerイメージの理解とコンテナのライフサイクルDockerイメージの理解とコンテナのライフサイクル
Dockerイメージの理解とコンテナのライフサイクル
 
Yocto Project ハンズオン プレゼン用資料
Yocto Project ハンズオン プレゼン用資料Yocto Project ハンズオン プレゼン用資料
Yocto Project ハンズオン プレゼン用資料
 
Docker & Kubernetes基礎
Docker & Kubernetes基礎Docker & Kubernetes基礎
Docker & Kubernetes基礎
 
今だからこそ知りたい Docker Compose/Swarm 入門
今だからこそ知りたい Docker Compose/Swarm 入門今だからこそ知りたい Docker Compose/Swarm 入門
今だからこそ知りたい Docker Compose/Swarm 入門
 
地味だけど劇的に便利になるGitHubリポジトリ設定あれこれ
地味だけど劇的に便利になるGitHubリポジトリ設定あれこれ地味だけど劇的に便利になるGitHubリポジトリ設定あれこれ
地味だけど劇的に便利になるGitHubリポジトリ設定あれこれ
 
Developing inside a Container
Developing inside a ContainerDeveloping inside a Container
Developing inside a Container
 

More from Akihiro Suda

20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
20240321 [KubeCon EU Pavilion] Lima.pdf_
20240321 [KubeCon EU Pavilion] Lima.pdf_20240321 [KubeCon EU Pavilion] Lima.pdf_
20240321 [KubeCon EU Pavilion] Lima.pdf_Akihiro Suda
 
20240320 [KubeCon EU Pavilion] containerd.pdf
20240320 [KubeCon EU Pavilion] containerd.pdf20240320 [KubeCon EU Pavilion] containerd.pdf
20240320 [KubeCon EU Pavilion] containerd.pdfAkihiro Suda
 
20240201 [HPC Containers] Rootless Containers.pdf
20240201 [HPC Containers] Rootless Containers.pdf20240201 [HPC Containers] Rootless Containers.pdf
20240201 [HPC Containers] Rootless Containers.pdfAkihiro Suda
 
[Podman Special Event] Kubernetes in Rootless Podman
[Podman Special Event] Kubernetes in Rootless Podman[Podman Special Event] Kubernetes in Rootless Podman
[Podman Special Event] Kubernetes in Rootless PodmanAkihiro Suda
 
[KubeConNA2023] Lima pavilion
[KubeConNA2023] Lima pavilion[KubeConNA2023] Lima pavilion
[KubeConNA2023] Lima pavilionAkihiro Suda
 
[KubeConNA2023] containerd pavilion
[KubeConNA2023] containerd pavilion[KubeConNA2023] containerd pavilion
[KubeConNA2023] containerd pavilionAkihiro Suda
 
[CNCF TAG-Runtime] Usernetes Gen2
[CNCF TAG-Runtime] Usernetes Gen2[CNCF TAG-Runtime] Usernetes Gen2
[CNCF TAG-Runtime] Usernetes Gen2Akihiro Suda
 
[DockerCon 2023] Reproducible builds with BuildKit for software supply chain ...
[DockerCon 2023] Reproducible builds with BuildKit for software supply chain ...[DockerCon 2023] Reproducible builds with BuildKit for software supply chain ...
[DockerCon 2023] Reproducible builds with BuildKit for software supply chain ...Akihiro Suda
 
The internals and the latest trends of container runtimes
The internals and the latest trends of container runtimesThe internals and the latest trends of container runtimes
The internals and the latest trends of container runtimesAkihiro Suda
 
[KubeConEU2023] Lima pavilion
[KubeConEU2023] Lima pavilion[KubeConEU2023] Lima pavilion
[KubeConEU2023] Lima pavilionAkihiro Suda
 
[KubeConEU2023] containerd pavilion
[KubeConEU2023] containerd pavilion[KubeConEU2023] containerd pavilion
[KubeConEU2023] containerd pavilionAkihiro Suda
 
[Container Plumbing Days 2023] Why was nerdctl made?
[Container Plumbing Days 2023] Why was nerdctl made?[Container Plumbing Days 2023] Why was nerdctl made?
[Container Plumbing Days 2023] Why was nerdctl made?Akihiro Suda
 
[FOSDEM2023] Bit-for-bit reproducible builds with Dockerfile
[FOSDEM2023] Bit-for-bit reproducible builds with Dockerfile[FOSDEM2023] Bit-for-bit reproducible builds with Dockerfile
[FOSDEM2023] Bit-for-bit reproducible builds with DockerfileAkihiro Suda
 
[CNCF TAG-Runtime 2022-10-06] Lima
[CNCF TAG-Runtime 2022-10-06] Lima[CNCF TAG-Runtime 2022-10-06] Lima
[CNCF TAG-Runtime 2022-10-06] LimaAkihiro Suda
 
[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOSAkihiro Suda
 
Dockerからcontainerdへの移行
Dockerからcontainerdへの移行Dockerからcontainerdへの移行
Dockerからcontainerdへの移行Akihiro Suda
 
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...Akihiro Suda
 
[Docker Tokyo #35] Docker 20.10
[Docker Tokyo #35] Docker 20.10[Docker Tokyo #35] Docker 20.10
[Docker Tokyo #35] Docker 20.10Akihiro Suda
 
[KubeCon EU 2021] Introduction and Deep Dive Into Containerd
[KubeCon EU 2021] Introduction and Deep Dive Into Containerd[KubeCon EU 2021] Introduction and Deep Dive Into Containerd
[KubeCon EU 2021] Introduction and Deep Dive Into ContainerdAkihiro Suda
 

More from Akihiro Suda (20)

20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
20240321 [KubeCon EU Pavilion] Lima.pdf_
20240321 [KubeCon EU Pavilion] Lima.pdf_20240321 [KubeCon EU Pavilion] Lima.pdf_
20240321 [KubeCon EU Pavilion] Lima.pdf_
 
20240320 [KubeCon EU Pavilion] containerd.pdf
20240320 [KubeCon EU Pavilion] containerd.pdf20240320 [KubeCon EU Pavilion] containerd.pdf
20240320 [KubeCon EU Pavilion] containerd.pdf
 
20240201 [HPC Containers] Rootless Containers.pdf
20240201 [HPC Containers] Rootless Containers.pdf20240201 [HPC Containers] Rootless Containers.pdf
20240201 [HPC Containers] Rootless Containers.pdf
 
[Podman Special Event] Kubernetes in Rootless Podman
[Podman Special Event] Kubernetes in Rootless Podman[Podman Special Event] Kubernetes in Rootless Podman
[Podman Special Event] Kubernetes in Rootless Podman
 
[KubeConNA2023] Lima pavilion
[KubeConNA2023] Lima pavilion[KubeConNA2023] Lima pavilion
[KubeConNA2023] Lima pavilion
 
[KubeConNA2023] containerd pavilion
[KubeConNA2023] containerd pavilion[KubeConNA2023] containerd pavilion
[KubeConNA2023] containerd pavilion
 
[CNCF TAG-Runtime] Usernetes Gen2
[CNCF TAG-Runtime] Usernetes Gen2[CNCF TAG-Runtime] Usernetes Gen2
[CNCF TAG-Runtime] Usernetes Gen2
 
[DockerCon 2023] Reproducible builds with BuildKit for software supply chain ...
[DockerCon 2023] Reproducible builds with BuildKit for software supply chain ...[DockerCon 2023] Reproducible builds with BuildKit for software supply chain ...
[DockerCon 2023] Reproducible builds with BuildKit for software supply chain ...
 
The internals and the latest trends of container runtimes
The internals and the latest trends of container runtimesThe internals and the latest trends of container runtimes
The internals and the latest trends of container runtimes
 
[KubeConEU2023] Lima pavilion
[KubeConEU2023] Lima pavilion[KubeConEU2023] Lima pavilion
[KubeConEU2023] Lima pavilion
 
[KubeConEU2023] containerd pavilion
[KubeConEU2023] containerd pavilion[KubeConEU2023] containerd pavilion
[KubeConEU2023] containerd pavilion
 
[Container Plumbing Days 2023] Why was nerdctl made?
[Container Plumbing Days 2023] Why was nerdctl made?[Container Plumbing Days 2023] Why was nerdctl made?
[Container Plumbing Days 2023] Why was nerdctl made?
 
[FOSDEM2023] Bit-for-bit reproducible builds with Dockerfile
[FOSDEM2023] Bit-for-bit reproducible builds with Dockerfile[FOSDEM2023] Bit-for-bit reproducible builds with Dockerfile
[FOSDEM2023] Bit-for-bit reproducible builds with Dockerfile
 
[CNCF TAG-Runtime 2022-10-06] Lima
[CNCF TAG-Runtime 2022-10-06] Lima[CNCF TAG-Runtime 2022-10-06] Lima
[CNCF TAG-Runtime 2022-10-06] Lima
 
[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS
 
Dockerからcontainerdへの移行
Dockerからcontainerdへの移行Dockerからcontainerdへの移行
Dockerからcontainerdへの移行
 
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
 
[Docker Tokyo #35] Docker 20.10
[Docker Tokyo #35] Docker 20.10[Docker Tokyo #35] Docker 20.10
[Docker Tokyo #35] Docker 20.10
 
[KubeCon EU 2021] Introduction and Deep Dive Into Containerd
[KubeCon EU 2021] Introduction and Deep Dive Into Containerd[KubeCon EU 2021] Introduction and Deep Dive Into Containerd
[KubeCon EU 2021] Introduction and Deep Dive Into Containerd
 

[DockerConハイライト] OpenPubKeyによるイメージの署名と検証.pdf

  • 2. • Moby (Docker Engineのupstream)、BuildKit、containerd、runc などの OSSのコミッタ • 今年のDockerConでは “Reproducible builds with BuildKit for software supply chain security” に関して登壇 – https://medium.com/nttlabs/dockercon-2023-reproducible-builds-with-buildkit- for-software-supply-chain-security-0e5aedd1aaa7 • 今⽇は⾃⾝の取り組みについてではなく、 Docker社・BastionZero 社に よる OpenPubKey への取り組みについて紹介 • Reproducible builds にも OpenPubKey を応⽤していきたいと思っている 2 ⾃⼰紹介
  • 3. • 2023/10/4: Demystify Secure Supply Chain Metadata – Christian Dupuis, Sr Principal Engineer, Docker • 2023/10/5: Building the Software Supply Chain on Docker Official Images – Ethan Heilman, CTO & Co-Founder, BastionZero James Carnegie, Computer Programmer, Docker • https://www.dockercon.com/ からまだ視聴可能 3 DockerCon での OpenPubKey 関連セッション
  • 5. • OpenID Connect (OIDC) を応⽤し、公開鍵基盤として使えるようにしたもの “In essence, OpenPubkey is a protocol for getting OpenID Providers (OPs) to bind identities to public keys.” ( https://github.com/openpubkey/openpubkey ) • 例えば、GitHub Actions 上でDockerイメージをビルドする際に、GitHubリポジト リのorganization IDを含む署名を付加できる • GitHub Actions の Secrets に秘密鍵をアップロードしたりしなくてよい • GitHub Actions 以外の OpenID プロバイダ への対応も容易。 プロバイダ側での対応作業は(原則的に)不要。 • Sigstore の Cosign (keyless) に似ているが、よりシンプルな構成 5 OpenPubKey
  • 6. • GitHub ActionsのYAML: https://github.com/openpubkey/demo • BuildKit へのパッチ (未マージ): https://github.com/openpubkey/buildkit/tree/opk-signing • docker verify コマンド: https://github.com/openpubkey/verify-docker-cli-plugin 6 DockerConでのOpenPubKeyのデモ
  • 7. 7 GitHub Actions の YAML - name: Setup Docker buildx uses: docker/setup-buildx-action@v3.0.0 with: driver-opts: | image=openpubkey/buildkit:opk-signing env.ACTIONS_ID_TOKEN_REQUEST_URL=${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }} env.ACTIONS_ID_TOKEN_REQUEST_TOKEN=${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN }} - name: Build and push Docker image on push id: build-and-push uses: docker/build-push-action@v4.0.0 with: context: . push: true … sbom: true provenance: true … https://github.com/openpubkey/demo/blob/6b29027/.github/workflows/docker-build.yaml
  • 8. 8 GitHub Actions の YAML - name: Setup Docker buildx uses: docker/setup-buildx-action@v3.0.0 with: driver-opts: | image=openpubkey/buildkit:opk-signing env.ACTIONS_ID_TOKEN_REQUEST_URL=${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }} env.ACTIONS_ID_TOKEN_REQUEST_TOKEN=${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN }} - name: Build and push Docker image on push id: build-and-push uses: docker/build-push-action@v4.0.0 with: context: . push: true … sbom: true provenance: true … https://github.com/openpubkey/demo/blob/6b29027/.github/workflows/docker-build.yaml GitHub により⾃動的に設定される OIDC関連の環境変数を BuildKit デーモン に伝播させる OpenPubKeyに対応した fork を指定する https://github.com/openpubkey/buildkit SBOMおよびSLSA Provenance (ビルド情報) を イメージに付加する。 併せて、SBOMやSLSA Provenance に対する署名 (i.e., イメージに対する署名) も付加する。
  • 9. • Docker CLI プラグインとして提供 https://github.com/openpubkey/verify-docker-cli-plugin • Docker Hub 上のイメージ “openpubkey/demo@sha256…” が、GitHub organization “openpubkey” の GitHub Actions でビルドされたことを確認 できた • ただし、GitHub Actions のキーセット (https://token.actions.githubusercontent.com/.well-known/jwks) を信頼で きる前提 9 docker verify コマンド $ gh api /orgs/openpubkey | jq .id 145685596 $ docker verify openpubkey/demo@sha256:6acf54fca0e7f9e9ef3d23c9b9ee306ce3c56b8315aa756643e4df25032bcdbe --repo-owner-id 145685596 … Verified all required attestations are present
  • 10. 10 docker verify コマンド (出⼒全体) $ docker verify openpubkey/demo@sha256:6acf54fca0e7f9e9ef3d23c9b9ee306ce3c56b8315aa756643e4df25032bcdbe --repo-owner-id 145685596 Verifying 2 attestations for pkg:docker/openpubkey/demo?digest=sha256:6acf54fca0e7f9e9ef3d23c9b9ee306ce3c56b8315aa756643e4df25032bcdbe&platform =linux/amd64 Verifying https://spdx.dev/Document attestation ✓ Verified attestation refers to digest sha256:6fbb78f2482a527575558d85147aee5f5f9f5288133bb0af316f91ed525a7246 ✓ Verified OIDC token was signed by https://token.actions.githubusercontent.com ✓ Verified attestation digest was signed on a Github Actions run: https://github.com/openpubkey/demo/actions/runs/6628798402 ✓ Verified repository owner 145685596 (openpubkey) Verifying https://slsa.dev/provenance/v0.2 attestation ✓ Verified attestation refers to digest sha256:6fbb78f2482a527575558d85147aee5f5f9f5288133bb0af316f91ed525a7246 ✓ Verified OIDC token was signed by https://token.actions.githubusercontent.com ✓ Verified attestation digest was signed on a Github Actions run: https://github.com/openpubkey/demo/actions/runs/6628798402 ✓ Verified repository owner 145685596 (openpubkey) ✓ Verified signed git sha provenance 6b29027d7ddae1c2dcdcfb88ab402473af5d20c8 ✓ Verified signed git repo provenance openpubkey/demo Verified all required attestations are present
  • 11. 11 フロー (1/2) BuildKit (OpenPubKey対応版) GitHub Actions $ACTIONS_ID_TOKEN_REQUEST_TOKEN $ACTIONS_ID_TOKEN_REQUEST_URL HTTP GET $ACTIONS_ID_TOKEN_REQUEST_URL &audience=$AUDIENCE “Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN” • ID Token を発⾏するための Bearer Token を発⾏ • イメージをビルドし、 provenanceを⽣成 • ⼀回限りの鍵ペアを⽣成 • Client-Instance Claim (CIC) を ⽣成 {‘rz’: random(), ‘upk’: publicKey, ‘alg’: ‘EC256’, ‘att’: provenenceHash} • CIC のハッシュを “audience” としてID Tokenの発⾏を要求 ※CIC のハッシュは、GitHub Actions などの workload identity では audience に含めるが、user identity では nonce に含める。 audience (GHAのデフォルトでは リポジトリ のURL) には任意の⽂字列をいれてよいので OIDCのAPIを変更せずにCICのハッシュを送る ことができる
  • 12. 12 フロー (2/2) BuildKit (OpenPubKey対応版) GitHub Actions ID Token: “SUBSTR0.SUBSTR1.SUBSTR2” • SUBSTR0: ヘッダ の base64 • SUBSTR1: ペイロードの base64 (“aud” などを含む) • SUBSTR2: ”SUBST0.SUBST1” に対する 署名 • 受け取った Bearer Token が 合っていれば、ID Token を発 ⾏する • ID Tokenの主なペイロード: • “aud” (audience) • “repository_owner_id” (GitHubのorgのID) • “run_id” (GHAのjobの 実⾏ID) • ID Tokenは、GHA⾃⾝が持っ ている鍵で署名される • ⼿持ちのCICと、GHAから受 け取ったID Tokenとを組み合 わせ、署名し、 PK Token を 構成する。これをイメージに 付加する。 • Guillou-Quisquater (GQ) 署名 により、元のID Tokenの値は 隠蔽される (ペイロードの 部分は公開される) (前掲) CIC: Client-Instance Claim: {‘rz’: random(), ‘upk’: publicKey, ‘alg’: ‘EC256, ‘att’: provenanceHash} audience: ここでは CICのハッシュ ID Token が鍵ペアに紐づく ※GQ署名はworkload identityでは必須、user identity では任意 GHAの場合はペイロードが公開されて問題ないが、 他のOpenIDプロバイダでは検討が必要そう
  • 16. 16 { "payloadType":"application/vnd.in-toto+json", "payload": …, "signatures":[{"keyid":"OPK","sig": …}] } { "payload": …, "signatures": [ {"protected": …, "header": {"sig_type": "cic"}, "signature": …}, {"protected": …, "header": {"sig_type": "oidc_gq"}, "signature": …} ] } .signatures[0].sig { "jti": "66e345cc-0806-42a0-a346-7b98dc8ab2c0", "sub": "repo:openpubkey/demo:ref:refs/heads/main", "aud": "5km4t6i4IPk-tnv4qlmCcryfY0O-4PCNWOmFCJZJrzI", "ref": "refs/heads/main", "sha": "6b29027d7ddae1c2dcdcfb88ab402473af5d20c8", "repository": "openpubkey/demo", "repository_owner": "openpubkey", "repository_owner_id": "145685596", "run_id": "6628798402", "repository_id": "698282570", "iss": https://token.actions.githubusercontent.com …, } .payload { "alg": "ES256", "att": … "rz": …, "upk": {"alg": "ES256", "crv": "P-256", "kty": "EC", "x": …, "y": … } } { "typ": "JWT", "alg": "RS256", "x5t": "AB3c0BSoSOiCRXez5POu2zvPX_0", "kid": "001DDCD014A848E8824577B3E4F3AEDB3BCF5FFD" } .signatures[0].protected .signatures[1].protected application/vnd.in-toto.provenance+dsse (SLSA Provenance) .payload
  • 17. • OpenID Connect (OIDC) を応⽤し、公開鍵基盤として使えるようにしたもの “In essence, OpenPubkey is a protocol for getting OpenID Providers (OPs) to bind identities to public keys.” ( https://github.com/openpubkey/openpubkey ) • 例えば、GitHub Actions 上でDockerイメージをビルドする際に、GitHubリポジトリの organization IDを含む署名を付加できる • GitHub Actions の Secrets に秘密鍵をアップロードしたりしなくてよい • GitHub Actions 以外の OpenID プロバイダ への対応も容易。 プロバイダ側での対応作業は(原則的に)不要。 • Sigstore の Cosign (keyless) に似ているが、よりシンプルな構成 17 まとめ (再掲) スライド: https://github.com/AkihiroSuda (“Presentation slides” → “2023” → “20231102 …”)