-
Couldn't load subscription status.
- Fork 2
Add github hardening page #13
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
Open
xoloki-stacks
wants to merge
3
commits into
stx-labs:main
Choose a base branch
from
xoloki-stacks:github
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,31 @@ | ||
| # GitHub hardening | ||
|
|
||
| Since the Stacks ecosystem does the bulk of its development work in public repositories, it is crucial that those repositories be hardened against attack. Any weakness in their configuration exposes our developers and users to attack vectors, as we have seen in previous attacks against the ecosystem from nation-state sponsored attackers. The following policies MUST ALWAYS be implemented on EVERY repository. If your organization has an Enterprise GitHub account, you can set this up at the org level and have it apply by default to all repositories. | ||
|
|
||
| ## Commit signing | ||
|
|
||
| `git` does not, by default, do anything to verify that a commit comes from the user whose email address is tied to it. This address is simply metadata, and a compromised developer machine can alter this data at any point in the commit/push process; we saw exactly this in previous attacks. | ||
|
|
||
| To combat this, you MUST require [signed commits](./ssh_keys.md) on your repositories. You SHOULD require all users to enable [vigilant mode](https://docs.github.com/en/authentication/managing-commit-signature-verification/displaying-verification-statuses-for-all-of-your-commits), which adds an extra layer of obviousness when commits are unsigned. This will prevent one infected developer from impersonating others. | ||
|
|
||
| ## Branch protection | ||
|
|
||
| The `main` branch of a repository is the source of truth for external users, and where releases are normally taken. So you MUST protect that branch against common problems, regardless of whether those problems arise from malice or simply negligence. | ||
|
|
||
| First, you MUST disable force pushes against your main branch. This prevents an infected developer from altering the history of a branch, in order to hide a malicious commit by making it appear to have happened in the past. | ||
|
|
||
| Next, you MUST require all changes to your main branch to go through the pull request process. You SHOULD require two or more approvals for each PR. You MUST require dismissing stale reviews, i.e. when new code is pushed. | ||
|
|
||
| Finally, you MUST protect the main branch from deletion. | ||
|
|
||
| ## CI | ||
|
|
||
| Continuous integration is a powerful tool for preventing regressions in code, and allows us to make changes without unexpected side effects. However, CI MUST be hardened in specific ways to avoid causing other problems. | ||
|
|
||
| 1. You MUST NEVER include secrets in CI! Instead use the github `secrets` APIs, which allow fine grained access control. This can for example limit access to specific jobs run by specific people. | ||
| 1. You MUST use OIDC for backend to backend authentication. This allows the use of limited and expiring tokens in the place of passwords. | ||
| 1. You MUST require reviews for deployments, and use [environments](https://docs.github.com/en/actions/concepts/workflows-and-actions/deployment-environments). This limits the blast radius of any compromise, preventing infected code from reaching users. | ||
| 1. You MUST pin actions to specific versions using the SHA. | ||
| 1. You MUST specify permissions used by all workflows, limited to the minimum needed to run. | ||
| 1. You SHOULD use [zizimor](https://github.com/zizmorcore/zizmor) to vet CI workflows. | ||
| 1. You SHOULD NEVER use `pull_request_target`, since in a public repo anyone can submit a pull request from a fork. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'd also add to use
zizmorfor vetting CI workflows and also NEVER usingpull_request_target.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.
Done. To be clear though, we do use
pull_request_targeton this repo currently.