-
Notifications
You must be signed in to change notification settings - Fork 282
Add security considerations for Attribute Conditions #393
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
Merged
Merged
Changes from all commits
Commits
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
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Security Considerations | ||
|
|
||
| There are important risks to consider when mapping GitHub Actions OIDC token | ||
| claims. | ||
|
|
||
|
|
||
| ## Use Unique Mapping Values | ||
|
|
||
| Many of the claims embedded in the GitHub Actions OIDC token are not guaranteed | ||
| to be unique, and tokens issued by other GitHub organizations or repositories | ||
| may contain the same values, allowing them to establish an identity. To protect | ||
| against this situation, always use an Attribute Condition to restrict access to | ||
| tokens issued by your GitHub organization. | ||
|
|
||
| ```cel | ||
| assertion.repository_owner == 'my-github-org' | ||
| ``` | ||
|
|
||
| Never use a "*" in an IAM Binding unless you absolutely know what you are doing! | ||
|
|
||
|
|
||
| ## Use GitHub's Numeric, Immutable Values | ||
|
|
||
| Using "name" fields in Attribute Conditions or IAM Bindings like `repository` and `repository_owner` increase the chances of [cybersquatting][] and [typosquatting][] attacks. If you delete your GitHub repository or GitHub organization, someone could claim that same name and establish an identity. To protect against this situation, use the numeric `*_id` fields instead, which GitHub guarantees to be unique and never re-used. | ||
|
|
||
| To get your numeric organization ID: | ||
|
|
||
| ```sh | ||
| ORG="my-org" # TODO: replace with your org | ||
| curl -sfL -H "Accept: application/json" "https://api.github.com/orgs/${ORG}" | jq .id | ||
| ``` | ||
|
|
||
| To get your numeric repository ID: | ||
|
|
||
| ```sh | ||
| REPO="my-org/my-repo" # TODO: replace with your full repo including the org | ||
| curl -sfL -H "Accept: application/json" "https://api.github.com/repos/${REPO}" | jq .id | ||
| ``` | ||
|
|
||
| These can be used in an Attribute Condition: | ||
|
|
||
| ```cel | ||
| assertion.repository_owner_id == 1342004 && assertion.repository_id == 260064828 | ||
| ``` | ||
|
|
||
| [cybersquatting]: https://en.wikipedia.org/wiki/Cybersquatting | ||
| [typosquatting]: https://en.wikipedia.org/wiki/Typosquatting |
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.
Uh oh!
There was an error while loading. Please reload this page.