Skip to content

Commit e6c2598

Browse files
sashashurafacebook-github-bot
authored andcommitted
GitHub Workflows security hardening (#529)
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: #529 Reviewed By: ParalaxRus Differential Revision: D39866397 Pulled By: ParalaxRus fbshipit-source-id: 3c921df4845618c2091be45e3702d4e639c7da46
1 parent 3a21285 commit e6c2598

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

.github/workflows/getdeps_linux.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
branches:
1111
- main
1212

13+
permissions:
14+
contents: read # to fetch code (actions/checkout)
15+
1316
jobs:
1417
build:
1518
runs-on: ubuntu-20.04

.github/workflows/getdeps_mac.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
branches:
1111
- main
1212

13+
permissions:
14+
contents: read # to fetch code (actions/checkout)
15+
1316
jobs:
1417
build:
1518
runs-on: macOS-latest

.github/workflows/getdeps_windows.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
branches:
1111
- main
1212

13+
permissions:
14+
contents: read # to fetch code (actions/checkout)
15+
1316
jobs:
1417
build:
1518
runs-on: windows-2019

0 commit comments

Comments
 (0)