Skip to content

Commit d4611c1

Browse files
authored
Update manage-encrypted-secrets.md
1 parent 126ddc3 commit d4611c1

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

learn-pr/github/manage-github-actions-enterprise/includes/manage-encrypted-secrets.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ You can select **Update** for more details on the configured permissions for you
6565
- **Implement role-based access control (RBAC)** to ensure only authorized team members can create, update, or delete secrets.
6666
- **Monitor access logs regularly** to identify and respond to unauthorized usage or suspicious activity.
6767

68-
## Manage Encrypted Secrets at the Repository Level
68+
## Manage encrypted secrets at the repository level
6969
To scope a secret to a specific repository, use GitHub Enterprise Cloud or GitHub Enterprise Server.
7070

71-
### Create a Repository-Level Secret
71+
### Create a repository-level secret
7272
1. **Navigate** to the repository’s **Settings**.
7373
2. **Select** **Secrets and variables > Actions**, then **New repository secret**.
7474
3. **Enter** a name and value for the secret.
7575

7676
:::image type="content" source="../media/secret-repo.png" alt-text="New secret screen for repositories." border="false":::
7777

78-
### Manage Repository-Level Encrypted Secrets via CLI
78+
### Manage repository-level encrypted secrets via CLI
7979

8080
* **List repository secrets:**
8181

@@ -96,7 +96,7 @@ To scope a secret to a specific repository, use GitHub Enterprise Cloud or GitHu
9696
```
9797

9898

99-
## Access Encrypted Secrets Within Actions and Workflows
99+
## Access encrypted secrets within actions and workflows
100100

101101
### In Workflows
102102

@@ -154,9 +154,9 @@ Security hardening for GitHub Actions plays a role in keeping your software supp
154154

155155
Some best practices for mitigating script injection attacks on GitHub actions include:
156156

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.
158158

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.
160160

161161
```yml
162162
uses: fakeaction/checktitle@v3
@@ -165,7 +165,7 @@ Passing a variable as an input to a JavaScript action helps prevent it from bein
165165
```
166166

167167
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:
169169

170170
```yml
171171
- name: Check PR title
@@ -180,18 +180,18 @@ For example, using `github.event.pull_request.title` as an environment variable
180180
exit 1
181181
fi
182182
```
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":::
184184

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":::
186186

187187
3. **Leverage workflow templates to implement code scanning**:
188188
**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.
189189

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.
191191

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":::
193193

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":::
195195

196196
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.
197197

@@ -228,15 +228,15 @@ Use trusted actions to reduce risk in your workflows.
228228
- **Check documentation:**
229229
The `action.yml` file should be well documented and clearly describe how the action works.
230230

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":::
232232

233233
### Use Dependabot version updates to keep actions up to date
234234

235235
Enable Dependabot version updates to automatically keep your GitHub Actions dependencies current and secure.
236236

237237
### Potential impact of a compromised runner
238238

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.
240240

241241
#### Exfiltration of data from a runner
242242

@@ -287,53 +287,54 @@ When workflows require access to multiple repositories, it's important to choose
287287

288288
1. **`GITHUB_TOKEN`**
289289

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.
291291

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).
294294

295295
2. **Repository deploy key**
296296

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.
298298

299299
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.
300300

301301
3. **GitHub App tokens**
302302

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.
304304

305305
This approach provides better access control and auditing compared to personal tokens.
306306

307307
4. **Personal access tokens (PATs)**
308308

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.
310310

311311
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.
313314

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":::
315316

316317
5. **SSH keys on personal accounts**
317318

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.
319320

320321
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.
321322

322323
### Audit GitHub Action events
323324

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.
325326

326327
### Using OIDC with GitHub Actions
327328

328329
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.
329330

330-
### Artifact attestions for GitHub Actions
331+
### Artifact attestations for GitHub Actions
331332

332333
Artifact attestations help establish the provenance of builds, improving software supply chain security by verifying what was built, where, and how.
333334

334335
#### What to attest
335336

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.
337338

338339
#### Generating artifact attestations for builds
339340

@@ -344,7 +345,7 @@ When you generate an artifact attestation for builds, you must ensure:
344345

345346
The attestation establishes build provenance. You can view attestations in the repository's **Actions** tab.
346347

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":::
348349

349350
##### Generating an attestation for build provenance of binaries
350351

@@ -364,7 +365,8 @@ The attestation establishes build provenance. You can view attestations in the r
364365
subject-path: 'PATH/TO/ARTIFACT'
365366
```
366367

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.
368370

369371
##### Generating an attestation for the build provenance of container images
370372

@@ -388,14 +390,14 @@ The attestation establishes build provenance. You can view attestations in the r
388390
subject-digest: 'sha256:fedcba0...'
389391
push-to-registry: true
390392
```
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).
395397

396398
#### Generating attestations for SBOMs
397399

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:
399401

400402
- Ensure you set the appropriate permissions in the workflow, as shown in the examples.
401403
- 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
446448
push-to-registry: true
447449
```
448450

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 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.
450452

451453
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).
452454

@@ -458,7 +460,6 @@ You can validate the artifact attestations outlined above using the GitHub CLI.
458460

459461
> [!WARNING]
460462
> 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-
>
462463

463464
### Access encrypted secrets within actions and workflows
464465

0 commit comments

Comments
 (0)