You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: learn-pr/github/manage-github-actions-enterprise/includes/manage-encrypted-secrets.md
+36-35Lines changed: 36 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,17 +65,17 @@ You can select **Update** for more details on the configured permissions for you
65
65
-**Implement role-based access control (RBAC)** to ensure only authorized team members can create, update, or delete secrets.
66
66
-**Monitor access logs regularly** to identify and respond to unauthorized usage or suspicious activity.
67
67
68
-
## Manage Encrypted Secrets at the Repository Level
68
+
## Manage encrypted secrets at the repository level
69
69
To scope a secret to a specific repository, use GitHub Enterprise Cloud or GitHub Enterprise Server.
70
70
71
-
### Create a Repository-Level Secret
71
+
### Create a repository-level secret
72
72
1.**Navigate** to the repository’s **Settings**.
73
73
2.**Select****Secrets and variables > Actions**, then **New repository secret**.
74
74
3.**Enter** a name and value for the secret.
75
75
76
76
:::image type="content" source="../media/secret-repo.png" alt-text="New secret screen for repositories." border="false":::
77
77
78
-
### Manage Repository-Level Encrypted Secrets via CLI
78
+
### Manage repository-level encrypted secrets via CLI
79
79
80
80
***List repository secrets:**
81
81
@@ -96,7 +96,7 @@ To scope a secret to a specific repository, use GitHub Enterprise Cloud or GitHu
96
96
```
97
97
98
98
99
-
## Access Encrypted Secrets Within Actions and Workflows
99
+
## Access encrypted secrets within actions and workflows
100
100
101
101
### In Workflows
102
102
@@ -154,9 +154,9 @@ Security hardening for GitHub Actions plays a role in keeping your software supp
154
154
155
155
Some best practices for mitigating script injection attacks on GitHub actions include:
156
156
157
-
1. *Use javascript actions instead of inline scripts*: Use JavaScript actions that accept context values as arguments instead of embedding those values in inline scripts. This approach reduces the risk of script injection because the context data is not used to generate or execute shell commands directly.
157
+
1. *Use Javascript actions instead of inline scripts*: Use JavaScript actions that accept context values as arguments instead of embedding those values in inline scripts. This approach reduces the risk of script injection because the context data is not used to generate or execute shell commands directly.
158
158
159
-
Passing a variable as an input to a JavaScript action helps prevent it from being used in a script injection attack.
159
+
Passing a variable as an input to a JavaScript action helps prevent it from being used in a script injection attack.
160
160
161
161
```yml
162
162
uses: fakeaction/checktitle@v3
@@ -165,7 +165,7 @@ Passing a variable as an input to a JavaScript action helps prevent it from bein
165
165
```
166
166
167
167
2. *Use intermediate environment variables in inline scripts*: When using inline scripts, evaluate variables as environment variables before using them in commands. This approach ensures the values are resolved before the script runs, reducing the risk of script injection.
168
-
For example, using `github.event.pull_request.title` as an environment variable helps protect against injection vulnerabilities:
168
+
For example, using `github.event.pull_request.title` as an environment variable helps protect against injection vulnerabilities:
169
169
170
170
```yml
171
171
- name: Check PR title
@@ -180,18 +180,18 @@ For example, using `github.event.pull_request.title` as an environment variable
180
180
exit 1
181
181
fi
182
182
```
183
-
:::image type="content" source="../media/manage-encrypted-secrets_pr.png" alt-text="Screenshot showing a pull request interface related to managing encrypted secrets." border="false":::
183
+
:::image type="content" source="../media/pull-request.png" alt-text="Screenshot showing a pull request interface related to managing encrypted secrets." border="true":::
184
184
185
-
:::image type="content" source="../media/manage-encrypted-secrets_workflow.png" alt-text="Screenshot showing a GitHub Actions workflow execution related to encrypted secrets." border="false":::
185
+
:::image type="content" source="../media/workflow.png" alt-text="Screenshot showing a GitHub Actions workflow execution related to encrypted secrets." border="true":::
186
186
187
187
3. **Leverage workflow templates to implement code scanning**:
188
188
**Navigate** to the repository’s **Actions** tab and select the **New Workflow** button on the left pane. On the **Choose a workflow** page, **locate** the **Security** section to access and apply workflow templates.
189
189
190
-
Configure the CodeQL scanner to run on specific events, enabling it to scan a branch's files and flag exposures CWEs(Common Weakness Enumerations) in actions used within workflows, including vulnerabilities such as script injection.
190
+
Configure the CodeQL scanner to run on specific events, enabling it to scan a branch's files and flag exposures CWEs(Common Weakness Enumerations) in actions used within workflows, including vulnerabilities such as script injection.
191
191
192
-
:::image type="content" source="../media/manage-encrypted-secrets_newworkflow.png" alt-text="Screenshot showing the creation of a new GitHub Actions workflow for managing encrypted secrets." border="false":::
192
+
:::image type="content" source="../media/new-workflow.png" alt-text="Screenshot showing the creation of a new GitHub Actions workflow for managing encrypted secrets." border="true":::
193
193
194
-
:::image type="content" source="../media/manage-encrypted-secrets_codeql.png" alt-text="Screenshot showing CodeQL configuration related to managing encrypted secrets." border="false":::
194
+
:::image type="content" source="../media/codeql.png" alt-text="Screenshot showing CodeQL configuration related to managing encrypted secrets." border="true":::
195
195
196
196
4. *Restrict permissions for tokens*: Ensure you always apply the `rule of least privilege` to any created token. In other words, ensure the token is assigned the minimum privileges to achieve the task for which it was created.
197
197
@@ -228,15 +228,15 @@ Use trusted actions to reduce risk in your workflows.
228
228
- **Check documentation:**
229
229
The `action.yml` file should be well documented and clearly describe how the action works.
230
230
231
-
:::image type="content" source="../media/manage-encrypted-secrets_marketplace.png" alt-text="Screenshot showing the GitHub Marketplace interface for managing encrypted secrets." border="false":::
231
+
:::image type="content" source="../media/marketplace.png" alt-text="Screenshot showing the GitHub Marketplace interface for managing encrypted secrets." border="false":::
232
232
233
233
### Use Dependabot version updates to keep actions up to date
234
234
235
235
Enable Dependabot version updates to automatically keep your GitHub Actions dependencies current and secure.
236
236
237
237
### Potential impact of a compromised runner
238
238
239
-
This section describe possible attack vectors that could be exploited if a runner is compromised.
239
+
This section describes possible attack vectors that could be exploited if a runner is compromised.
240
240
241
241
#### Exfiltration of data from a runner
242
242
@@ -287,53 +287,54 @@ When workflows require access to multiple repositories, it's important to choose
287
287
288
288
1. **`GITHUB_TOKEN`**
289
289
290
-
GitHub automatically generates the `GITHUB_TOKEN` for each workflow run. It is scoped to the single repository that triggers the workflow and provides permissions equivalent to a write-access user on that repository. The token is created at the start of each job and expires when the job completes.
290
+
GitHub automatically generates the `GITHUB_TOKEN` for each workflow run. It is scoped to the single repository that triggers the workflow and provides permissions equivalent to a write-access user on that repository. The token is created at the start of each job and expires when the job completes.
291
291
292
-
Use the `GITHUB_TOKEN` whenever possible for secure and scoped authentication.
293
-
For details, see [Automatic token authentication](https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication).
292
+
Use the `GITHUB_TOKEN` whenever possible for secure and scoped authentication.
293
+
For details, see [Automatic token authentication](https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication).
294
294
295
295
2. **Repository deploy key**
296
296
297
-
To clone or push using Git within workflows, use deploy keys that provide read or write access to a single repository.
297
+
To clone or push using Git within workflows, use deploy keys that provide read or write access to a single repository.
298
298
299
299
However, deploy keys do not support access to GitHub's REST or GraphQL APIs. Use them only when API access is not required and Git access is sufficient.
300
300
301
301
3. **GitHub App tokens**
302
302
303
-
GitHub Apps offer fine-grained permissions and can be installed on selected repositories. You can create an internal GitHub App, install it on the necessary repositories, and authenticate as the app installation within your workflow to access those repositories.
303
+
GitHub Apps offer fine-grained permissions and can be installed on selected repositories. You can create an internal GitHub App, install it on the necessary repositories, and authenticate as the app installation within your workflow to access those repositories.
304
304
305
305
This approach provides better access control and auditing compared to personal tokens.
306
306
307
307
4. **Personal access tokens (PATs)**
308
308
309
-
Avoid using classic personal access tokens in workflows. These tokens grant broad access across all personal and organizational repositories associated with the user, introducing significant risk. If the workflow runs in a repository with multiple contributors, all write-access users effectively inherit that token’s privileges.
309
+
Avoid using classic personal access tokens in workflows. These tokens grant broad access across all personal and organizational repositories associated with the user, introducing significant risk. If the workflow runs in a repository with multiple contributors, all write-access users effectively inherit that token’s privileges.
310
310
311
311
If you must use a personal token, create a **fine-grained PAT** tied to a dedicated organizational account. Restrict its access to only the specific repositories required by the workflow.
312
-
Note: This approach is difficult to scale and is best avoided in favor of deploy keys or GitHub Apps.
312
+
> [!NOTE]
313
+
> This approach is difficult to scale and is best avoided in favor of deploy keys or GitHub Apps.
313
314
314
-
:::image type="content" source="../media/manage-encrypted-secrets_personalaccesstoken.png" alt-text="Screenshot showing a button to generate new GitHub personal access token." border="false":::
315
+
:::image type="content" source="../media/personal-access-token.png" alt-text="Screenshot showing a button to generate new GitHub personal access token." border="false":::
315
316
316
317
5. **SSH keys on personal accounts**
317
318
318
-
Never use SSH keys from personal accounts in workflows. Like classic PATs, they grant access to all repositories associated with the account, including personal and organizational repositories. This mistake exposes workflows to unnecessary risk.
319
+
Never use SSH keys from personal accounts in workflows. Like classic PATs, they grant access to all repositories associated with the account, including personal and organizational repositories. This mistake exposes workflows to unnecessary risk.
319
320
320
321
If your use case involves cloning or pushing via Git, consider using deploy keys instead. They provide scoped access without exposing unrelated repositories or requiring personal credentials.
321
322
322
323
### Audit GitHub Action events
323
324
324
-
The type of action, when it was run, and which personal account performed the action are recorded in the 'security log' and the 'audit log'. The 'security log' records events related to your user account. The 'audit log' records events related to your organization. Thus by viewing both of these logs you can audit events related to github actions.
325
+
The type of action, when it was run, and which personal account performed the action are recorded in the 'security log' and the 'audit log'. The 'security log' records events related to your user account. The 'audit log' records events related to your organization. Thus by viewing both of these logs you can audit events related to Github actions.
325
326
326
327
### Using OIDC with GitHub Actions
327
328
328
329
You can configure workflows to authenticate directly with a cloud provider using OIDC (OpenID Connect). In this case, there is no longer the need to store credentials as secrets.
329
330
330
-
### Artifact attestions for GitHub Actions
331
+
### Artifact attestations for GitHub Actions
331
332
332
333
Artifact attestations help establish the provenance of builds, improving software supply chain security by verifying what was built, where, and how.
333
334
334
335
#### What to attest
335
336
336
-
With GitHub Actions, you can attest to build provenance & SBOM's (Software Bill of Materials) for binaries and container images.
337
+
With GitHub Actions, you can attest to build provenance & SBOM (Software Bill of Materials) for binaries and container images.
337
338
338
339
#### Generating artifact attestations for builds
339
340
@@ -344,7 +345,7 @@ When you generate an artifact attestation for builds, you must ensure:
344
345
345
346
The attestation establishes build provenance. You can view attestations in the repository's **Actions** tab.
346
347
347
-
:::image type="content" source="../media/manage-encrypted-secrets_attestations.png" alt-text="Screenshot showing attestations configuration in GitHub related to managing encrypted secrets." border="false":::
348
+
:::image type="content" source="../media/attestations.png" alt-text="Screenshot showing attestations configuration in GitHub related to managing encrypted secrets." border="false":::
348
349
349
350
##### Generating an attestation for build provenance of binaries
350
351
@@ -364,7 +365,8 @@ The attestation establishes build provenance. You can view attestations in the r
364
365
subject-path: 'PATH/TO/ARTIFACT'
365
366
```
366
367
367
-
>Note that the value of the `subject-path` parameter is set to the path of the binary you attest.
368
+
> [!NOTE]
369
+
> Note that the value of the `subject-path` parameter is set to the path of the binary you attest.
368
370
369
371
##### Generating an attestation for the build provenance of container images
370
372
@@ -388,14 +390,14 @@ The attestation establishes build provenance. You can view attestations in the r
388
390
subject-digest: 'sha256:fedcba0...'
389
391
push-to-registry: true
390
392
```
391
-
392
-
> * The `subject-name` value must be a fully qualified image name, such as `ghcr.io/user/app` or `acme.azurecr.io/user/app`. Do **not** include a tag.
393
-
> * The `subject-digest` must be a SHA256 digest of the image, in the format `sha256:HEX_DIGEST`.
394
-
> * If your workflow uses `docker/build-push-action`, you can retrieve the digest from its output. For details, refer to [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs).
393
+
> [!NOTE]
394
+
> * The `subject-name` value must be a fully qualified image name, such as `ghcr.io/user/app` or `acme.azurecr.io/user/app`. Do **not** include a tag.
395
+
> * The `subject-digest` must be a SHA256 digest of the image, in the format `sha256:HEX_DIGEST`.
396
+
> * If your workflow uses `docker/build-push-action`, you can retrieve the digest from its output. For details, refer to [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs).
395
397
396
398
#### Generating attestations for SBOMs
397
399
398
-
You have the ability to generate SBOM attestions for an SBOM. To generate and attest to an SBOM you must carry out the following steps:
400
+
You have the ability to generate SBOM attestations for an SBOM. To generate and attest to an SBOM you must carry out the following steps:
399
401
400
402
- Ensure you set the appropriate permissions in the workflow, as shown in the examples.
401
403
- You must generate an SBOM for the artifact in a step in the workflow. For an example, see anchore-sbom-action in the GitHub Marketplace.
@@ -446,7 +448,7 @@ Note that the value of the `subject-path` parameter should be set to the path of
446
448
push-to-registry: true
447
449
```
448
450
449
-
Note that the value of the `subject-name` parameter specifies the fully-qualified image name. For example, `ghcr.io/user/app` or `acme.azurecr.io/user/app`. Do not include a tag as part of the image name.
451
+
Note that the value of the `subject-name` parameter specifies the fullyqualified image name. For example, `ghcr.io/user/app` or `acme.azurecr.io/user/app`. Do not include a tag as part of the image name.
450
452
451
453
The value of the `subject-digest` parameter should be set to the `SHA256` digest of the subject for the attestation, in the form's `sha256:HEX_DIGEST`. If your workflow uses `docker/build-push-action`, you can use the digest output from that step to supply the value (see [build-push-action](https://github.com/docker/build-push-action?tab=readme-ov-file#outputs)). For more information on using outputs, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs).
452
454
@@ -458,7 +460,6 @@ You can validate the artifact attestations outlined above using the GitHub CLI.
458
460
459
461
> [!WARNING]
460
462
> It is important to remember that artifact attestations are not a guarantee that an artifact is secure. Instead, artifact attestations link you to the source code and the build instructions that produced them. It is up to you to define your policy criteria, evaluate that policy by evaluating the content, and make an informed risk decision when you are consuming software.
461
-
>
462
463
463
464
### Access encrypted secrets within actions and workflows
0 commit comments