Skip to content

Commit 8d6a3f6

Browse files
tmlemanlgirdwood
authored andcommitted
workflows: restrict GITHUB_TOKEN permissions to contents: read
Add explicit top-level permissions block to all GitHub Actions workflow files, limiting the GITHUB_TOKEN to the minimum required scope: read. Why this is recommended: GitHub Actions grants the GITHUB_TOKEN broad default permissions (read/write on most scopes) unless explicitly restricted. The GitHub security hardening guide and CodeQL (actions/missing-workflow-permissions rule) recommend always declaring an explicit permissions block to enforce the principle of least privilege. Threats prevented: - Compromised or malicious third-party actions (supply chain attacks) cannot use the implicit GITHUB_TOKEN to write to the repository, create releases, modify issues/PRs, upload packages, or affect deployments - even if such an action is injected into the workflow. - If a vulnerability in a workflow step allows code execution (e.g. via script injection through PR title/body), the attacker's ability to abuse the token is limited to read-only repository access. - Reduces blast radius of any accidental or intentional misuse of the token across all CI jobs. Affected workflows: build_all, codestyle, daily-tests, ipc_fuzzer, llext, pull-request, repro-build, rimage, sof-docs, sparse-zephyr, testbench, tools, unit-tests, zephyr. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent be861ab commit 8d6a3f6

14 files changed

Lines changed: 42 additions & 0 deletions

.github/workflows/build_all.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ name: Build test all components
88
# yamllint disable-line rule:truthy
99
on: [pull_request, workflow_dispatch, workflow_call]
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215

1316
stub-build:

.github/workflows/codestyle.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ name: codestyle
1414
# yamllint disable-line rule:truthy
1515
on: [pull_request, workflow_call, workflow_dispatch]
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
checkpatch:
1922
runs-on: ubuntu-24.04

.github/workflows/daily-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
# Allows you to run this workflow manually from the Actions tab
1414
workflow_dispatch:
1515

16+
permissions:
17+
contents: read
18+
1619
jobs:
1720

1821
# Keep in .yml alphabetical order

.github/workflows/ipc_fuzzer.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ on:
2222
pull_request:
2323
# TODO: can we provide a default inputs here too?
2424

25+
permissions:
26+
contents: read
27+
2528
jobs:
2629

2730
simple-IPC-fuzz_sh:

.github/workflows/llext.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ defaults:
1111
run:
1212
shell: bash
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
build:
1619
runs-on: ubuntu-24.04

.github/workflows/pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ on:
3131
# Allows to call this forkflow from other workflows
3232
workflow_call:
3333

34+
permissions:
35+
contents: read
36+
3437
jobs:
3538

3639
doxygen:

.github/workflows/repro-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ name: Reproducible builds
1414
# yamllint disable-line rule:truthy
1515
on: [pull_request, workflow_dispatch, workflow_call]
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
main:
1922
runs-on: ubuntu-24.04

.github/workflows/rimage.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ on:
2222
paths:
2323
- tools/rimage/**
2424

25+
permissions:
26+
contents: read
27+
2528
jobs:
2629

2730
# Basic build test

.github/workflows/sof-docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ on:
1717
# Allows to call this forkflow from other workflows
1818
workflow_call:
1919

20+
permissions:
21+
contents: read
22+
2023
jobs:
2124

2225
# This is unfortunately a mix of sof-docs/.github/ + pull-request.yml#doxygen

.github/workflows/sparse-zephyr.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ defaults:
1111
run:
1212
shell: bash
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
# As of sparse commit ce1a6720f69e / Sept 2022, the exit status of
1619
# sparse.c is an unusable mess and always zero in practice. Moreover

0 commit comments

Comments
 (0)