Skip to content

Commit

Permalink
GitHub Workflows security hardening (#4577)
Browse files Browse the repository at this point in the history
This PR adds explicit [permissions section](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions) to workflows. This is a security best practice because by default workflows run with [extended set of permissions](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token) (except from `on: pull_request` [from external forks](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)). By specifying any permission explicitly all others are set to none. By using the principle of least privilege the damage a compromised workflow can do (because of an [injection](https://securitylab.github.com/research/github-actions-untrusted-input/) or compromised third party tool or action) is restricted.
It is recommended to have [most strict permissions on the top level](https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions) and grant write permissions on [job level](https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs) case by case.
  • Loading branch information
kodiakhq[bot] authored Sep 27, 2022
2 parents 90b5ed9 + 903da4e commit d2a984a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
schedule:
- cron: '0 7 * * *'

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
deploy_docs:
runs-on: ubuntu-20.04
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/push_pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
schedule:
- cron: '0 3 * * *'

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
regular_check:
runs-on: macos-latest
Expand All @@ -24,6 +27,10 @@ jobs:
ubsan: false

sanitizer_check:
permissions:
contents: read # to fetch code (actions/checkout)
issues: write # to create an issue

runs-on: macos-latest
if: (github.event_name == 'schedule' && github.repository == 'espressomd/espresso')
steps:
Expand Down

0 comments on commit d2a984a

Please sign in to comment.