-
Notifications
You must be signed in to change notification settings - Fork 21
Recommend environment secrets #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,58 @@ Resources: | |||||
| - [Immutable releases](https://docs.github.com/en/code-security/concepts/supply-chain-security/immutable-releases) | ||||||
| - [Verifying the integrity of a release](https://docs.github.com/en/code-security/how-tos/secure-your-supply-chain/secure-your-dependencies/verifying-the-integrity-of-a-release) | ||||||
|
|
||||||
| ## GitHub environment secrets | ||||||
|
|
||||||
| GitHub [environment secrets](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-an-environment) | ||||||
| provide an additional layer of protection for sensitive secrets used in | ||||||
| publishing, signing, and other privileged workflows. | ||||||
|
|
||||||
| With **repository secrets**, any workflow running in the repository can access | ||||||
| them, including workflows triggered on non-protected branches. This means | ||||||
| anyone with write access could push a non-protected branch containing secret | ||||||
| exfiltration code and trigger a workflow without going through a PR review. | ||||||
|
|
||||||
| With **environment secrets**, access is restricted to workflows running in the | ||||||
| context of a named environment, and that environment can be configured to only | ||||||
| allow deployments from specific branches. This means even a contributor with | ||||||
| write access cannot access the secrets without their code successfully passing | ||||||
| all branch protection criteria (i.e. an approved and merged PR). | ||||||
|
|
||||||
| Recommendation: migrate publishing, signing, and other privileged secrets from | ||||||
| repository secrets to an environment with a deployment branch policy restricting | ||||||
| access to `main` and `release/**` branches. | ||||||
|
|
||||||
| Steps: | ||||||
|
|
||||||
| 1. Create an environment (e.g., `protected`) in the repository settings. | ||||||
| 2. Configure a deployment branch policy on the environment, allowing only | ||||||
| `main` and `release/**` (adjust to match your branching strategy). | ||||||
| 3. Add your publishing and signing secrets to the environment. | ||||||
| 4. Remove the corresponding repository-level secrets. If both exist, the | ||||||
| repository-level secret remains accessible from any branch, defeating the | ||||||
| purpose. | ||||||
|
Comment on lines
+74
to
+76
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe swap ordering of 4 and 5, and mention something about may need to backport the release workflow update if making an older patch release |
||||||
| 5. Update release workflows to run in the context of the environment: | ||||||
|
|
||||||
| ```yaml | ||||||
| jobs: | ||||||
| release: | ||||||
| environment: protected | ||||||
| steps: | ||||||
| ... | ||||||
| ``` | ||||||
|
|
||||||
| Caveats: | ||||||
|
|
||||||
| - Repository admin permission is required to create environments and manage | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
not if done via Terraform (https://github.com/open-telemetry/sig-security/pull/274/changes#r3318814752)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @arminru's suggestion here is just to remove the "create environments" portion, since better to do that part via terraform.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jack-berg please let me know when this is addressed and the PR is ready to be merged. |
||||||
| environment secrets. See [Request Repository Admin Permissions](https://github.com/open-telemetry/community/blob/main/guides/maintainer/github-admin-processes.md#request-repository-admin-permissions) | ||||||
| if you need to request access. | ||||||
|
|
||||||
| Resources: | ||||||
|
|
||||||
| - [Using environments for deployment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment) | ||||||
| - [Creating secrets for an environment](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-an-environment) | ||||||
| - [Example migration in opentelemetry-java](https://github.com/open-telemetry/opentelemetry-java/pull/8432/changes#diff-bae0feaab53d9bdd636360014c03f3456cd796c65e3984b5373443e92fdb5efeR17) | ||||||
|
|
||||||
| ## Binding to Network Interfaces | ||||||
|
|
||||||
| Always bind to localhost rather than to 0.0.0.0 or any interface, unless there | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should recommend setting it up properly via Terraform in https://github.com/open-telemetry/admin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wow I totally forgot I did this: https://github.com/open-telemetry/admin/pull/595
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/open-telemetry/admin/pull/684
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But even with the environment setup in terraform, maintainers still need admin to be able to go and manage secrets for that environment yeah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, looks like it