Skip to content

Commit 80306da

Browse files
authored
Enhance security of GitHub workflows using least privilege principle (#69)
### Motivation: GitHub Actions workflows by default may have broader permissions than necessary, increasing the attack surface for supply chain attacks and credential theft. Explicitly scoping permissions prevents potential exploitation if workflows are compromised. ### Modifications: Add explicit `permissions: contents: read` declaration to all workflow files: - .github/workflows/main.yml - .github/workflows/pull_request.yml - .github/workflows/pull_request_label.yml - .github/workflows/unit_tests.yml ### Result: Workflows are restricted to read-only repository access, preventing malicious code execution from modifying repository contents, pushing commits, or escalating privileges even if the workflow is compromised.
1 parent 7b98490 commit 80306da

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
schedule:
77
- cron: "0 8,20 * * *"
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
unit-tests:
1114
name: Unit tests

.github/workflows/pull_request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
types: [opened, reopened, synchronize]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
soundness:
912
name: Soundness

.github/workflows/pull_request_label.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
types: [labeled, unlabeled, opened, reopened, synchronize]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
semver-label-check:
912
name: Semantic version label check

.github/workflows/unit_tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ on:
5252
description: "The arguments passed to swift test in the Linux nightly main Swift version matrix job."
5353
default: ""
5454

55+
permissions:
56+
contents: read
57+
5558
jobs:
5659
unit-tests:
5760
name: Unit tests (${{ matrix.swift.swift_version }})

0 commit comments

Comments
 (0)