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: practices/actions-best-practices.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,8 @@ This guide outlines best practices for securing your GitHub Actions workflows an
19
19
20
20
## Secrets Management
21
21
22
+
This section describes how secrets in GitHub Actions should be managed, teams should ensure that they are using robust secrets management tools such as Azure Key Vault and AWS Secrets Manager for securely storing secrets.
23
+
22
24
### Use GitHub Secrets
23
25
24
26
- Store sensitive data (API tokens, credentials, etc.) as [GitHub Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets)
@@ -55,7 +57,7 @@ jobs:
55
57
56
58
### Use Least Privilege Principle
57
59
58
-
Limit the GitHub token permissions to only what's necessary:
60
+
Limit the GitHub token permissions to only what's necessary please [see here](https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#permissions-for-the-github_token) for details on the default permissions that the github token is given when the permissions block is not used:
59
61
60
62
```yaml
61
63
permissions:
@@ -66,6 +68,8 @@ permissions:
66
68
67
69
### Use Fine-Grained Tokens
68
70
71
+
Fine grained tokens *must* only be used if the GitHub token can not be used.
72
+
69
73
- Create custom GitHub Apps with limited scopes when possible
70
74
- Use repository-scoped tokens instead of organization-wide tokens
71
75
@@ -83,7 +87,7 @@ To mitigate these risks, always follow best practices, such as pinning actions t
83
87
84
88
### Pin Actions to Specific Versions
85
89
86
-
When including a GitHub Action within your workflow you should perform due diligence checks to ensure that the action achieves the aims you are intending it to, and that it doesn't do anything unintended, this would include performing a code review of the GitHub action code. To prevent the underlying code being changed without your awareness always use specific commit SHAs instead of tags or branches:
90
+
When including a GitHub Action within your workflow you should perform due diligence checks to ensure that the action achieves the aims you are intending it to, and that it doesn't do anything unintended, this would include performing a code review of the GitHub action code. To prevent the underlying code being changed without your awareness always use specific commit SHAs instead of tags or branches as tags can be modified if the upstream repository is compromised:
87
91
88
92
```yaml
89
93
# Not secure - can change unexpectedly
@@ -96,6 +100,8 @@ When including a GitHub Action within your workflow you should perform due dilig
96
100
97
101
### Verify Third-Party Actions
98
102
103
+
When including a GitHub Action within your workflow consider alternatives, is there an existing mechanism you can use? Would this be something that could be reused and you could create your own action within the organisation that other teams could benefit from? If you can only achieve your goal with a third-party action then:
104
+
99
105
- Only use trusted actions from the GitHub Marketplace
100
106
- Review the source code of third-party actions before using them
101
107
- Consider forking and maintaining your own copy of critical actions
@@ -120,7 +126,7 @@ When including a GitHub Action within your workflow you should perform due dilig
120
126
121
127
### Self-hosted Runner Security
122
128
123
-
If using self-hosted runners:
129
+
Self-hosted runners *must* only be [used with private repositories](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#self-hosted-runner-security). If using self-hosted runners:
124
130
125
131
- Run them in isolated environments (containers/VMs)
0 commit comments