Skip to content

Commit 3c50a33

Browse files
committed
GH Actions: do not persist credentials
> By default, using `actions/checkout` causes a credential to be persisted in the checked-out repo's `.git/config`, so that subsequent `git` operations can be authenticated. > > Subsequent steps may accidentally publicly persist `.git/config`, e.g. by including it in a publicly accessible artifact via `actions/upload-artifact`. > > However, even without this, persisting the credential in the `.git/config` is non-ideal unless actually needed. > > **Remediation** > > Unless needed for `git` operations, `actions/checkout` should be used with `persist-credentials: false`. > > If the persisted credential is needed, it should be made explicit with `persist-credentials: true`. This has now been addressed in all workflows. Refs: * https://unit42.paloaltonetworks.com/github-repo-artifacts-leak-tokens/ * https://docs.zizmor.sh/audits/#artipacked
1 parent dc00a37 commit 3c50a33

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

.github/workflows/basics.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
steps:
2727
- name: Checkout code
2828
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
29+
with:
30+
persist-credentials: false
2931

3032
- name: Install PHP
3133
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # 2.35.4
@@ -110,6 +112,8 @@ jobs:
110112
steps:
111113
- name: Checkout code
112114
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
115+
with:
116+
persist-credentials: false
113117

114118
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
115119
# This should not be blocking for this job, so ignore any errors from this step.

.github/workflows/quicktest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ jobs:
4646
steps:
4747
- name: Checkout code
4848
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
49+
with:
50+
persist-credentials: false
4951

5052
- name: Install PHP
5153
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # 2.35.4

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
steps:
3535
- name: Checkout code
3636
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
37+
with:
38+
persist-credentials: false
3739

3840
- name: Install PHP
3941
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # 2.35.4
@@ -132,6 +134,8 @@ jobs:
132134
steps:
133135
- name: Checkout code
134136
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
137+
with:
138+
persist-credentials: false
135139

136140
# On stable PHPCS versions, allow for PHP deprecation notices.
137141
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
@@ -235,6 +239,8 @@ jobs:
235239
steps:
236240
- name: Checkout code
237241
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
242+
with:
243+
persist-credentials: false
238244

239245
- name: Install PHP
240246
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # 2.35.4

0 commit comments

Comments
 (0)