Skip to content

Commit f6f8a29

Browse files
GitHub Workflows security hardening (#16075)
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.
2 parents c3097af + 69d44f7 commit f6f8a29

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.github/workflows/ci.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ env:
2626
# `java` (we could use the `_JAVA_OPTIONS` environment variable, but this prints
2727
# text on stderr and so can break tests which check the output of a program).
2828

29+
permissions:
30+
contents: read # to fetch code (actions/checkout)
31+
2932
jobs:
3033
test_non_bootstrapped:
3134
runs-on: [self-hosted, Linux]
@@ -527,6 +530,9 @@ jobs:
527530
./project/scripts/sbtPublish ";project scala3-bootstrapped ;publishSigned ;sonatypeBundleRelease"
528531
529532
nightly_documentation:
533+
permissions:
534+
contents: write # to push pages branch (peaceiris/actions-gh-pages)
535+
530536
runs-on: [self-hosted, Linux]
531537
container:
532538
image: lampepfl/dotty:2021-03-22
@@ -705,6 +711,10 @@ jobs:
705711

706712

707713
open_issue_on_failure:
714+
permissions:
715+
contents: read # to fetch code (actions/checkout)
716+
issues: write # to create new issues (jasonetco/create-an-issue)
717+
708718
runs-on: [self-hosted, Linux]
709719
container:
710720
image: lampepfl/dotty:2021-03-22

.github/workflows/dependency-graph.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on:
33
push:
44
branches:
55
- main # default branch of the project
6+
permissions:
7+
contents: read # to fetch code (actions/checkout)
68
jobs:
79
dependency-graph:
810
name: Update Dependency Graph

0 commit comments

Comments
 (0)