Skip to content

Commit

Permalink
GitHub Workflows security hardening (#870)
Browse files Browse the repository at this point in the history
Summary:
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.

Pull Request resolved: #870

Reviewed By: jacdebug

Differential Revision: D42406481

Pulled By: robhogan

fbshipit-source-id: c1118141c8b95d85c850ebe91b6b72c3b5170869
  • Loading branch information
sashashura authored and facebook-github-bot committed Jan 9, 2023
1 parent 735aa9f commit b27ceef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/deploy-website.yml
Expand Up @@ -9,8 +9,13 @@ on:
- "website/**"
- ".github/workflows/deploy-website.yml"

permissions:
contents: read

jobs:
deploy:
permissions:
contents: write # to deploy
runs-on: ubuntu-latest

if: github.repository == 'facebook/metro'
Expand Down

0 comments on commit b27ceef

Please sign in to comment.