Skip to content

Harden the GitHub Actions workflows - #121

Open
Aerhhh wants to merge 1 commit into
masterfrom
security/ci-hardening
Open

Aerhhh wants to merge 1 commit into
masterfrom
security/ci-hardening

Conversation

@Aerhhh

@Aerhhh Aerhhh commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Why

Follow-up to the security review (see #116), covering the workflow files.

What changed

  • Actions pinned by commit SHA. actions/checkout, actions/setup-java, actions/upload-artifact and stefanzweifel/git-auto-commit-action were referenced by tag, which the action's owner can move. Each now names a full commit SHA, with the tag kept as a trailing comment so Dependabot's existing github-actions updates still work.
  • Narrower tokens. build-test.yml now declares contents: read; it had no permissions block, so it inherited the repository default. auto-format.yml drops pull-requests: write, which it never used.
  • No input interpolation into shell. generate-spritesheet.yml pasted ${{ inputs.minecraft_version }}, ${{ inputs.render_size }}, ${{ inputs.pipeline }} and ${{ github.ref_name }} straight into run: scripts. They now arrive as environment variables, and a new first step rejects a version or render size that is not a plain version string or a number. Only people with write access can dispatch this workflow, so this was low risk, but it is the standard fix.
  • The "Set up JDK 21" step in the formatter is renamed to match the JDK 25 it installs.

Not changed

  • git push -f to automated/spritesheet-update stays: that branch is owned by the workflow.

Testing

Workflow changes cannot be run locally. auto-format runs on this PR. build-test only triggers on .java and pom.xml changes, so it will not run here; generate-spritesheet is manual. Worth dispatching generate-spritesheet once from this branch with spritesheet-only before merging to confirm the pinned actions and input handling.

- Pin every action to a full commit SHA (the tag is kept as a comment so
  Dependabot can still propose updates).
- Give the build workflow a read-only token and drop the unused
  pull-requests permission from the formatter.
- Pass workflow_dispatch inputs to scripts through environment variables
  and validate them first, instead of interpolating them into shell.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant