Skip to content

Commit 2dcfb33

Browse files
authored
[Security] Pin GitHub Actions to a full-length commit SHA (#1104)
## Pin GitHub Actions to SHA hashes This automated PR pins third-party GitHub Actions references from mutable tag versions (e.g., `@v4`) to their corresponding SHA hashes (e.g., `@abc123...`). The original tag is preserved as a comment for readability. Your workflows will work exactly the same way. Internal actions (under the `DataDog` organization) are not pinned. Read https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions for more details and info on how to configure this for entire repos. ### Why pin GitHub Actions? Git tags are mutable: they can be moved to point to different commits at any time. A compromised or malicious action maintainer could update a tag to inject arbitrary code into your CI workflows (see the [tj-actions incident](https://www.wiz.io/blog/github-action-tj-actions-changed-files-supply-chain-attack-cve-2025-30066)). Pinning to SHA hashes ensures you always run the exact code you reviewed, protecting your repository from supply chain attacks such as the tj-actions incident. ### What if something breaks? If a pinned action doesn't work for your use case, you can push a commit directly to this branch to fix it. As a last resort, reach out to **#sdlc-security** on Slack. ### Set up Dependabot or Renovate for automatic updates Once actions are pinned to SHA hashes, you should configure Dependabot or Renovate to receive weekly update PRs when new versions are available. In the case of Dependabot, create or update `.github/dependabot.yml`: ```yaml version: 2 updates: - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" groups: github-actions: patterns: - "*" open-pull-requests-limit: 10 ``` Dependabot will automatically propose PRs that update both the SHA hash and the version comment like [in this example](DataDog/datadog-agent#46761). --- *This PR was automatically generated by the GitHub Actions Pinning tool, owned by #sdlc-security.*
1 parent 647f1a7 commit 2dcfb33

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525

2626
steps:
2727
- name: Checkout repository
28-
uses: actions/checkout@v6.0.2
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2929

3030
# Initializes the CodeQL tools for scanning.
3131
- name: Initialize CodeQL
32-
uses: github/codeql-action/init@v4
32+
uses: github/codeql-action/init@b1bff81932f5cdfc8695c7752dcee935dcd061c8 # v4.33.0
3333
with:
3434
languages: ${{ matrix.language }}
3535
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -38,7 +38,7 @@ jobs:
3838
# queries: ./path/to/local/query, your-org/your-repo/queries@main
3939

4040
- name: Autobuild
41-
uses: github/codeql-action/autobuild@v4
41+
uses: github/codeql-action/autobuild@b1bff81932f5cdfc8695c7752dcee935dcd061c8 # v4.33.0
4242

4343
- name: Perform CodeQL Analysis
44-
uses: github/codeql-action/analyze@v4
44+
uses: github/codeql-action/analyze@b1bff81932f5cdfc8695c7752dcee935dcd061c8 # v4.33.0

.github/workflows/publish-serverless-init-to-ghcr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
crane version
4444
4545
- name: Login to GHCR
46-
uses: docker/login-action@v4
46+
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
4747
with:
4848
registry: ghcr.io
4949
username: ${{ github.actor }}

.github/workflows/release-serverless-init.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ jobs:
4545
]
4646
name: "Release Serverless Init (isAlpine: ${{ matrix.arrays.isAlpine }})"
4747
steps:
48-
- uses: actions/checkout@v6.0.2
48+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4949

50-
- uses: actions/checkout@v6.0.2
50+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5151
with:
5252
repository: DataDog/datadog-agent
5353
ref: ${{ github.event.inputs.agentBranch }}
@@ -66,7 +66,7 @@ jobs:
6666
image: tonistiigi/binfmt:qemu-v10.1.3
6767

6868
- name: Set up Docker Buildx
69-
uses: docker/setup-buildx-action@v4
69+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
7070

7171
- name: Build binaries
7272
working-directory: ./scripts
@@ -87,15 +87,15 @@ jobs:
8787
cp ./scripts/serverless_init_dotnet.sh ./scripts/bin/
8888
8989
- name: Login to GHCR
90-
uses: docker/login-action@v4
90+
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
9191
with:
9292
registry: ${{ env.REGISTRY }}
9393
username: ${{ github.actor }}
9494
password: ${{ secrets.GITHUB_TOKEN }}
9595

9696
- name: Build and push
9797
id: docker_build
98-
uses: docker/build-push-action@v7
98+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
9999
with:
100100
context: ./scripts
101101
file: ./scripts/${{ matrix.arrays.dockerFile }}
@@ -106,7 +106,7 @@ jobs:
106106

107107
- name: Build and push latest
108108
id: docker_build_latest
109-
uses: docker/build-push-action@v7
109+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
110110
if: ${{ github.event.inputs.latestTag == 'yes' }}
111111
with:
112112
context: ./scripts

.github/workflows/rs_ci.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-22.04
1919
timeout-minutes: 3
2020
steps:
21-
- uses: styfle/cancel-workflow-action@0.13.1
21+
- uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # v0.13.1
2222
with:
2323
access_token: ${{ secrets.GITHUB_TOKEN }}
2424
all_but_latest: true # can cancel workflows scheduled later
@@ -31,7 +31,7 @@ jobs:
3131
SCCACHE_GHA_ENABLED: "true"
3232
RUSTC_WRAPPER: "sccache"
3333
steps:
34-
- uses: actions/checkout@v6.0.2
34+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3535

3636
# Install protobuf compiler for linux. The versions bundled with Ubuntu
3737
# 20.04 and 22.04 are too old -- our messages require protobuf >= 3.15 --
@@ -44,10 +44,10 @@ jobs:
4444
unzip "protoc-${{ env.PB_VERSION }}-${{ env.PB_TARGET }}.zip" -d "$HOME/.local"
4545
export PATH="$PATH:$HOME/.local/bin"
4646
47-
- uses: actions-rust-lang/setup-rust-toolchain@v1.15.3
47+
- uses: actions-rust-lang/setup-rust-toolchain@a0b538fa0b742a6aa35d6e2c169b4bd06d225a98 # v1.15.3
4848
with:
4949
cache: false
50-
- uses: mozilla-actions/sccache-action@v0.0.9
50+
- uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
5151
- working-directory: bottlecap
5252
run: cargo check --workspace
5353

@@ -59,7 +59,7 @@ jobs:
5959
SCCACHE_GHA_ENABLED: "true"
6060
RUSTC_WRAPPER: "sccache"
6161
steps:
62-
- uses: actions/checkout@v6.0.2
62+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6363

6464
# Install protobuf compiler for linux. The versions bundled with Ubuntu
6565
# 20.04 and 22.04 are too old -- our messages require protobuf >= 3.15 --
@@ -72,11 +72,11 @@ jobs:
7272
unzip "protoc-${{ env.PB_VERSION }}-${{ env.PB_TARGET }}.zip" -d "$HOME/.local"
7373
export PATH="$PATH:$HOME/.local/bin"
7474
75-
- uses: actions-rust-lang/setup-rust-toolchain@v1.15.3
75+
- uses: actions-rust-lang/setup-rust-toolchain@a0b538fa0b742a6aa35d6e2c169b4bd06d225a98 # v1.15.3
7676
with:
7777
components: clippy
7878
cache: false
79-
- uses: mozilla-actions/sccache-action@v0.0.9
79+
- uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
8080
# We need to do these separately because the fips feature is incompatible with the default feature.
8181
- working-directory: bottlecap
8282
run: cargo clippy --workspace --all-targets --features default
@@ -91,7 +91,7 @@ jobs:
9191
SCCACHE_GHA_ENABLED: "true"
9292
RUSTC_WRAPPER: "sccache"
9393
steps:
94-
- uses: actions/checkout@v6.0.2
94+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
9595

9696
# Install protobuf compiler for linux. The versions bundled with Ubuntu
9797
# 20.04 and 22.04 are too old -- our messages require protobuf >= 3.15 --
@@ -104,10 +104,10 @@ jobs:
104104
unzip "protoc-${{ env.PB_VERSION }}-${{ env.PB_TARGET }}.zip" -d "$HOME/.local"
105105
export PATH="$PATH:$HOME/.local/bin"
106106
107-
- uses: actions-rust-lang/setup-rust-toolchain@v1.15.3
107+
- uses: actions-rust-lang/setup-rust-toolchain@a0b538fa0b742a6aa35d6e2c169b4bd06d225a98 # v1.15.3
108108
with:
109109
cache: false
110-
- uses: mozilla-actions/sccache-action@v0.0.9
110+
- uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
111111
- working-directory: bottlecap
112112
run: cargo build --all
113113

@@ -119,7 +119,7 @@ jobs:
119119
SCCACHE_GHA_ENABLED: "true"
120120
RUSTC_WRAPPER: "sccache"
121121
steps:
122-
- uses: actions/checkout@v6.0.2
122+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
123123

124124
# Install protobuf compiler for linux. The versions bundled with Ubuntu
125125
# 20.04 and 22.04 are too old -- our messages require protobuf >= 3.15 --
@@ -132,13 +132,13 @@ jobs:
132132
unzip "protoc-${{ env.PB_VERSION }}-${{ env.PB_TARGET }}.zip" -d "$HOME/.local"
133133
export PATH="$PATH:$HOME/.local/bin"
134134
135-
- uses: actions-rust-lang/setup-rust-toolchain@v1.15.3
135+
- uses: actions-rust-lang/setup-rust-toolchain@a0b538fa0b742a6aa35d6e2c169b4bd06d225a98 # v1.15.3
136136
with:
137137
cache: false
138-
- uses: taiki-e/install-action@v2
138+
- uses: taiki-e/install-action@cbb1dcaa26e1459e2876c39f61c1e22a1258aac5 # v2.68.33
139139
with:
140140
tool: nextest@0.9
141-
- uses: mozilla-actions/sccache-action@v0.0.9
141+
- uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
142142
- working-directory: bottlecap
143143
run: cargo nextest run --workspace
144144

@@ -149,8 +149,8 @@ jobs:
149149
matrix:
150150
os: [ubuntu-22.04, macos-latest]
151151
steps:
152-
- uses: actions/checkout@v6.0.2
153-
- uses: actions-rust-lang/setup-rust-toolchain@v1.15.3
152+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
153+
- uses: actions-rust-lang/setup-rust-toolchain@a0b538fa0b742a6aa35d6e2c169b4bd06d225a98 # v1.15.3
154154
with:
155155
components: rustfmt
156156
cache: false
@@ -163,7 +163,7 @@ jobs:
163163
name: "Valid LICENSE-3rdparty.csv"
164164
steps:
165165
- name: Checkout sources
166-
uses: actions/checkout@v6.0.2
166+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
167167
- run: cargo install dd-rust-license-tool --locked
168168
- run: dd-rust-license-tool check
169169
working-directory: bottlecap
@@ -176,7 +176,7 @@ jobs:
176176
checks: write
177177
steps:
178178
- name: Checkout repository
179-
uses: actions/checkout@v6.0.2
179+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
180180
- name: Scan Rust dependencies with cargo-audit
181181
uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2.0.0
182182
with:

.github/workflows/test-qemu-versions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
- "tonistiigi/binfmt:qemu-v7.0.0-28"
8484
name: "QEMU ${{ matrix.qemu_image }}"
8585
steps:
86-
- uses: actions/checkout@v6.0.2
86+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
8787

8888
- name: Set up QEMU
8989
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a #v4.0.0
@@ -94,7 +94,7 @@ jobs:
9494
run: docker run --rm --privileged ${{ matrix.qemu_image }} --version
9595

9696
- name: Set up Docker Buildx
97-
uses: docker/setup-buildx-action@v4
97+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
9898

9999
# Simple docker run tests — catches deterministically broken versions
100100
# (v9.2.0 and v8.1.5 consistently fail here; v8.1.4 is flaky).

0 commit comments

Comments
 (0)