Skip to content

Commit e06558e

Browse files
am-steadheiskrsophiethekinglandongrindheim
authored
[Improvement]: Clarify security posture of different types of secrets github#13321 (#54412)
Co-authored-by: Kevin Heis <[email protected]> Co-authored-by: Sophie <[email protected]> Co-authored-by: Landon Grindheim <[email protected]>
1 parent b14dc62 commit e06558e

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed

content/code-security/getting-started/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ children:
1919
- /adding-a-security-policy-to-your-repository
2020
- /auditing-security-alerts
2121
- /best-practices-for-preventing-data-leaks-in-your-organization
22+
- /understanding-github-secret-types
2223
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
---
2+
title: Understanding GitHub secret types
3+
intro: 'Learn about the usage, scope, and access permissions for {% data variables.product.github %} secrets.'
4+
versions:
5+
fpt: '*'
6+
ghes: '*'
7+
ghec: '*'
8+
type: overview
9+
topics:
10+
- Repositories
11+
- Dependencies
12+
- Vulnerabilities
13+
- Advanced Security
14+
shortTitle: GitHub secret types
15+
---
16+
17+
## About {% data variables.product.github %}'s secret types
18+
19+
{% data variables.product.github %} secrets are used to securely store sensitive information like API keys, tokens, and passwords in repositories.
20+
21+
When you store the sensitive information as a {% data variables.product.github %} secret, you remove the need to hardcode the credential or key, and prevent exposure of it in your code or logs. The secret can then be used to authenticate services, manage credentials, and securely pass sensitive data in workflows.
22+
23+
There are {% ifversion fpt or ghec %}three {% else %}two {% endif %}types of secrets used by {% data variables.product.github %}:
24+
25+
* [{% data variables.product.prodname_dependabot %} secrets](#dependabot-secrets)
26+
* [Actions secrets](#actions-secrets){% ifversion fpt or ghec %}
27+
* [{% data variables.product.prodname_codespaces %} secrets](#codespaces-secrets){% endif %}
28+
29+
Depending on the {% data variables.product.github %} secret type, you can create and manage secrets under your repository, organization, or personal account security settings page.
30+
31+
{% ifversion fpt or ghec %}
32+
33+
### Understanding how {% data variables.product.github %} stores secrets
34+
35+
{% data variables.product.github %} uses [Libsodium sealed boxes](https://libsodium.gitbook.io/doc/public-key_cryptography/sealed_boxes) to encrypt secrets. A secret is encrypted before reaching {% data variables.product.github %} and remains encrypted until it's used by the relevant service ({% data variables.product.prodname_dependabot %}, {% data variables.product.prodname_actions %}, or {% data variables.product.prodname_codespaces %}).
36+
37+
{% endif %}
38+
39+
## {% data variables.product.prodname_dependabot %} secrets
40+
41+
{% data variables.product.prodname_dependabot %} secrets are used to store credentials and sensitive information for use within {% data variables.product.prodname_dependabot %}.
42+
43+
{% data variables.product.prodname_dependabot %} secrets are referenced in a repository's `dependabot.yml` file.
44+
45+
### Usage
46+
47+
{% data variables.product.prodname_dependabot %} secrets are typically used by {% data variables.product.prodname_dependabot %} to authenticate to private package registries. This allows {% data variables.product.prodname_dependabot %} to open pull requests to update vulnerable or outdated dependencies in private repositories. Used for authentication, these {% data variables.product.prodname_dependabot %} secrets are referenced in a repository's `dependabot.yml` file.
48+
49+
{% data variables.product.prodname_dependabot %} secrets can also include secrets required for workflows initiated by {% data variables.product.prodname_dependabot %}. For example, {% data variables.product.prodname_dependabot %} can trigger {% data variables.product.prodname_actions %} workflows when it creates pull requests to update dependencies, or comments on pull requests. In this case, {% data variables.product.prodname_dependabot %} secrets can be referenced from workflow files (`.github/workflows/*.yml`) as long as the workflow is triggered by a {% data variables.product.prodname_dependabot %} event.
50+
51+
### Scope
52+
53+
You can define {% data variables.product.prodname_dependabot %} secrets at:
54+
55+
* Repository level
56+
* Organization level
57+
58+
{% data variables.product.prodname_dependabot %} secrets can be shared across repositories when set at the organization-level. You must specify which repositories in the organization can access the secret.
59+
60+
### Access permissions
61+
62+
{% data variables.product.prodname_dependabot %} secrets are accessed by {% data variables.product.prodname_dependabot %} when authenticating to private registries to update dependencies.
63+
64+
{% data variables.product.prodname_dependabot %} secrets are accessed by {% data variables.product.prodname_actions %} workflows when the trigger event for the workflow is initiated by {% data variables.product.prodname_dependabot %}. This is because when a workflow is initiated by {% data variables.product.prodname_dependabot %}, only {% data variables.product.prodname_dependabot %} secrets are available - Actions secrets are not accessible. Therefore, any secrets required for these workflows must be stored as {% data variables.product.prodname_dependabot %} secrets, rather than Actions secrets. There are additional security restrictions for the `pull_request_target` event. See [Limitations and restrictions](#limitations-and-restrictions).
65+
66+
#### User access permissions
67+
68+
Repository-level secrets:
69+
* Users with **admin access** to the repository can create and manage {% data variables.product.prodname_dependabot %} secrets.
70+
* Users with **collaborator access** to the repository can use the secret for {% data variables.product.prodname_dependabot %}.
71+
72+
Organization-level secrets:
73+
* **Organization owners** can create and manage {% data variables.product.prodname_dependabot %} secrets.
74+
* Users with **collaborator access** to the repositories with access to each secret can use the secret for {% data variables.product.prodname_dependabot %}.
75+
76+
### Limitations and restrictions
77+
78+
For workflows initiated by {% data variables.product.prodname_dependabot %}, the `pull_request_target` event is treated differently to other events. For this event, if the base ref of the pull request was created by {% data variables.product.prodname_dependabot %} (`github.event.pull_request.user.login == 'dependabot[bot]'`):
79+
80+
* The workflow receives a read-only `GITHUB_TOKEN`.
81+
* Secrets are **not** available to the workflow.
82+
83+
This extra restriction helps prevent potential security risks that could arise from pull requests created by {% data variables.product.prodname_dependabot %}.
84+
85+
{% data variables.product.prodname_dependabot %} secrets are not passed to forks.
86+
87+
## Actions secrets
88+
89+
Actions secrets are used to store sensitive information such as API keys, authentication tokens, and other credentials in workflows.
90+
91+
### Usage
92+
93+
Actions secrets are referenced in workflow files (`.github/workflows/*.yml`).
94+
95+
### Scope
96+
97+
You can define Actions secrets at:
98+
99+
* Repository level
100+
* Environment level
101+
* Organization level
102+
103+
Environment-level secrets are specific to a particular environment, such as production or staging.
104+
Actions secrets can be shared across repositories if set at the organization-level. You can use access policies to control which repositories have access to the secret.
105+
106+
### Access permissions
107+
108+
Actions secrets are only available within {% data variables.product.prodname_actions %} workflows. Despite running on Actions, {% data variables.product.prodname_dependabot %} does not have access to Actions secrets.
109+
110+
For workflows initiated by {% data variables.product.prodname_dependabot %}, Actions secrets are not available. These workflow secrets must be stored as {% data variables.product.prodname_dependabot %} secrets in order to be accessible to the workflow.
111+
112+
The location where you store the Actions secret determines its accessibility:
113+
114+
* Repository secret: all workflows in the repository can access the secret.
115+
* Environment secret: secret is limited to jobs referencing that particular environment.
116+
* Organization secret: all workflows in the repositories that have been granted access by the organization can access the organization secrets.
117+
118+
#### User access permissions
119+
120+
Repository-level and environment secrets:
121+
* Users with **admin access** to the repository can create and manage Actions secrets.
122+
* Users with **collaborator access** to the repository can use the secret.
123+
124+
Organization-level secrets:
125+
* **Organization owners** can create and manage Actions secrets.
126+
* Users with **collaborator access** to the repositories with access to each secret can use the secret.
127+
128+
### Limitations and restrictions
129+
130+
* Actions secrets are not available to workflows initiated by {% data variables.product.prodname_dependabot %}.
131+
* Actions secrets are not passed to workflows that are triggered by a pull request from a fork.
132+
* {% data variables.product.prodname_actions %} automatically redacts the contents of all {% data variables.product.github %} secrets that are printed to workflow logs.
133+
* You can store up to 1,000 organization secrets, 100 repository secrets, and 100 environment secrets. Secrets are limited to 48 KB in size. For more information, see [Limits for secrets](/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#limits-for-secrets).
134+
135+
{% ifversion fpt or ghec %}
136+
137+
## {% data variables.product.prodname_codespaces %} secrets
138+
139+
{% data variables.product.prodname_codespaces %} secrets store credentials and sensitive information, such as API tokens and SSH keys, for use within {% data variables.product.prodname_github_codespaces %}, allowing you to configure secure development environments.
140+
141+
### Usage
142+
143+
{% data variables.product.prodname_codespaces %} secrets are referenced within the {% data variables.product.prodname_codespaces %} development container configuration (`devcontainer.json`).
144+
145+
### Scope
146+
147+
You can define {% data variables.product.prodname_codespaces %} secrets at:
148+
149+
* User account level
150+
* Repository level
151+
* Organization level
152+
153+
For user account level secrets, you can choose which repositories have access to the secret.
154+
{% data variables.product.prodname_codespaces %} secrets can be shared across repositories if set at the organization-level. You can use access policies to control which repositories have access to the secret.
155+
156+
### Access permissions
157+
158+
{% data variables.product.prodname_codespaces %} secrets are only accessible in {% data variables.product.prodname_codespaces %}.
159+
160+
{% data variables.product.prodname_actions %} cannot access {% data variables.product.prodname_codespaces %} secrets.
161+
162+
#### User access permissions
163+
164+
User account-level secrets:
165+
* {% data variables.product.prodname_codespaces %} secrets are available to any codespace you create using repositories with access to that secret.
166+
167+
Repository-level secrets:
168+
* Users with **admin access** to the repository can create and manage {% data variables.product.prodname_codespaces %} secrets.
169+
* Users with **collaborator access** to the repository can use the secret.
170+
171+
Organization-level secrets:
172+
* **Organization owners** can create and manage {% data variables.product.prodname_codespaces %} secrets.
173+
* Users with **collaborator access** to the repositories with access to each secret can use the secret.
174+
175+
### Limitations and restrictions
176+
177+
* You can store up to 100 secrets for {% data variables.product.prodname_github_codespaces %}.
178+
* Secrets are limited to 48 KB in size.
179+
* {% data variables.product.prodname_codespaces %} secrets are not passed to forks.
180+
181+
{% endif %}
182+
183+
## Further reading
184+
185+
* [AUTOTITLE](/code-security/dependabot/working-with-dependabot/configuring-access-to-private-registries-for-dependabot#storing-credentials-for-dependabot-to-use)
186+
* [AUTOTITLE](/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions){% ifversion fpt or ghec %}
187+
* [AUTOTITLE](/codespaces/managing-codespaces-for-your-organization/managing-development-environment-secrets-for-your-repository-or-organization)
188+
* [AUTOTITLE](/codespaces/managing-your-codespaces/managing-your-account-specific-secrets-for-github-codespaces){% endif %}

0 commit comments

Comments
 (0)