chore: harden workflow permissions and standardize GITHUB_TOKEN usage #5141
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've noticed several workflows are running with default permissions and relying on a custom
WORKFLOW_TOKEN. This PR refactors some to follow the principle of least privilege.Changes:
Permissions Hardening: Added
permissions: contents: readto all workflow headers.Token Standardization: Migrated
build-prs.ymlandflatpak-build.ymlfromsecrets.WORKFLOW_TOKENto the built-insecrets.GITHUB_TOKEN.Technical Considerations:
contents: readmitigates potential write-access exploits from compromised dependencies in the build chain.WORKFLOW_TOKENin these files? If the built-inGITHUB_TOKENprovides the necessary scope for PR builds and artifact generation, it seems more logical to use the automatically rotated, short-lived secret.A question on the build logic: I have applied
contents: readbased on the assumption that these workflows are used for validation and artifact storage. Ifpnpm distor the Flatpak builder requires pushing tags or updating releases via the API, these will fail with a 403.Does our current CI flow require write access for these automated checks, or is the restrictive "read-only" state the intended baseline?
Infrastructure / CI Changes
Note: This PR does not modify Backend or Frontend logic, so standard app testing (Login/Install/Play) was not performed. The primary risk is CI permission scoping.