@@ -114,7 +114,29 @@ jobs:
114114 CHISEL_VERSION : ${{ steps.build.outputs.CHISEL_VERSION }}
115115 ARCHIVE_FILE : ${{ steps.archive.outputs.ARCHIVE_FILE }}
116116 ARCHIVE_FILE_SHA384 : ${{ steps.archive.outputs.ARCHIVE_FILE_SHA384 }}
117- # The following token needs "contents: write" permission to upload assets to release
117+ # If triggered by a "release" event, this additional and final step
118+ # of the job will upload the Chisel binaries (and checksums) to the corresponding
119+ # GitHub release. This operation NEEDS "contents: write" permissions.
120+ # Security concerns:
121+ # - Why a custom token instead of GITHUB_TOKEN?
122+ # - The GITHUB_TOKEN only has "readonly" permissions by default.
123+ # - Why not add "permissions: {contents:write}" to this workflow [1]?
124+ # - While this would elevate the GITHUB_TOKEN permissions to what we require, it
125+ # would do it for the entire job (ALL steps), which increases the attack surface unnecessarily.
126+ # - Why is it safer to use the ROCKSBOT_CHISEL_CONTENTS token?
127+ # 1. it is limited to this step of the workflow (unlike GITHUB_TOKEN, which is always available)
128+ # 2. this particular step only runs when the "event == release"
129+ # 3. the step's script doesn't rely on 3rd party actions
130+ # 4. the current workflow triggers are all maintainer-driven, except for "pull_request",
131+ # but the latter is designed not to use any secrets during execution from fork-based PRs
132+ # - NOTE: in fact, custom secrets are never passed to fork-based PR workflows, unlike GITHUB_TOKEN
133+ # which is available with "readonly" permissions [2]
134+ # - How could this token be compromised?
135+ # - By unintentionally merging a change that allows this step to run unvetted scripts
136+ # (either via a "pull_request_target", use of an insecure 3rd party action, or malicious changes to the
137+ # current script)
138+ # [1] https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#permissions
139+ # [2] https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflows-in-forked-repositories
118140 GITHUB_TOKEN : ${{ secrets.ROCKSBOT_CHISEL_CONTENTS }}
119141 if : ${{ github.event_name == 'release' }}
120142 run : |
0 commit comments