]> source.dussan.org Git - jquery.git/commitdiff
Build: Limit permissions for GitHub workflows
authorAlex <aleksandrosansan@gmail.com>
Thu, 1 Dec 2022 13:23:17 +0000 (15:23 +0200)
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Thu, 1 Dec 2022 13:27:11 +0000 (14:27 +0100)
Add explicit permissions section[^1] to workflows. This is a security
best practice because by default workflows run with extended set
of permissions[^2] (except from `on: pull_request` from external forks[^3].
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[^4] or compromised third party tool or action) is
restricted. It is recommended to have most strict permissions on the top
level[^5] and grant write permissions on job level[^6] on a case by case
basis.

[^1]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
[^2]: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
[^3]: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
[^4]: https://securitylab.github.com/research/github-actions-untrusted-input/
[^5]: https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
[^6]: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

Closes gh-5119

(cherry picked from commit c909d6b1ff444e68618b6da13d9c21714f681925)

.github/workflows/node.js.yml

index 3619db3e6543d85de9e3d9ee716381b6ad3a73a2..b464caf5296a8f6364aa5483372dfc5a60b7c863 100644 (file)
@@ -2,6 +2,9 @@ name: CI
 
 on: [push, pull_request]
 
+permissions:
+  contents: read # to fetch code (actions/checkout)
+
 jobs:
   build:
     runs-on: ubuntu-latest