-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Tighten secret scope in release.yml
#14627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tighten secret scope in release.yml
#14627
Conversation
* Add `environment: release` to the "publish-to-hex" job so that only workflows explicitly targeting the release environment can read sensitive values. * Gate the job behind `if: ${{ vars.HEX_AWS_REGION }}` to avoid noisy failures in forks where the variable is not configured. * Replace `${{ secrets.HEX_AWS_REGION }}` / `${{ secrets.HEX_AWS_S3_BUCKET }}` references with `${{ vars.* }}`. These are not credentials, so environment-level *variables* are a better fit and keep them readable only by jobs that declare the environment. * Remove Fastly secrets from the job-wide `env:` block and inject them only into the Fastly purge step, following the principle of least privilege. Other steps no longer see these tokens. Restricting secret visibility to an environment and to the exact step that needs them reduces the blast radius of a compromised workflow run, blocks accidental exposure in logs of unrelated steps, and stops forks from obtaining privileged data.
I have added the environment variables and secrets. Is it ready to merge? |
@ericmj Yes, if the TODOs were done, this is ready. Please make sure to either backport the change to all still maintained versions or leave the old variables until they are no longer needed. |
* Add `environment: release` to the "publish-to-hex" job so that only workflows explicitly targeting the release environment can read sensitive values. * Gate the job behind `if: ${{ vars.HEX_AWS_REGION }}` to avoid noisy failures in forks where the variable is not configured. * Replace `${{ secrets.HEX_AWS_REGION }}` / `${{ secrets.HEX_AWS_S3_BUCKET }}` references with `${{ vars.* }}`. These are not credentials, so environment-level *variables* are a better fit and keep them readable only by jobs that declare the environment. * Remove Fastly secrets from the job-wide `env:` block and inject them only into the Fastly purge step, following the principle of least privilege. Other steps no longer see these tokens. Restricting secret visibility to an environment and to the exact step that needs them reduces the blast radius of a compromised workflow run, blocks accidental exposure in logs of unrelated steps, and stops forks from obtaining privileged data.
* Add `environment: release` to the "publish-to-hex" job so that only workflows explicitly targeting the release environment can read sensitive values. * Gate the job behind `if: ${{ vars.HEX_AWS_REGION }}` to avoid noisy failures in forks where the variable is not configured. * Replace `${{ secrets.HEX_AWS_REGION }}` / `${{ secrets.HEX_AWS_S3_BUCKET }}` references with `${{ vars.* }}`. These are not credentials, so environment-level *variables* are a better fit and keep them readable only by jobs that declare the environment. * Remove Fastly secrets from the job-wide `env:` block and inject them only into the Fastly purge step, following the principle of least privilege. Other steps no longer see these tokens. Restricting secret visibility to an environment and to the exact step that needs them reduces the blast radius of a compromised workflow run, blocks accidental exposure in logs of unrelated steps, and stops forks from obtaining privileged data.
I backported to v1.18 and v1.19. I also removed the repository secrets, if we need them back to ship new versions of <v1.18 hex maintainers can revert this commit: https://github.com/hexpm/hexpm-ops/commit/8188ddeeccd26b391070f7cf479fad50add115bb. |
@ericmj https://github.com/elixir-lang/elixir/actions/runs/17445029605/job/49537507599 fails. That is because #14604 is not backported to 1.18. |
Okay, backporting that PR to v1.18 also. |
@ericmj Hm, there's another issue. I'll open a PR with a fix for 1.18 |
Backported PRs: * elixir-lang#14604 * elixir-lang#14627 The commits are based on the SBoM PR (elixir-lang#14241) which changed the actions.
What changed
environment: release
to thepublish-to-hex
job so that only workflows explicitly targeting the release environment can read sensitive values.if: ${{ vars.HEX_AWS_REGION }}
– to skip the job in forks that don’t define release variables.${{ vars.HEX_AWS_REGION }}
${{ vars.HEX_AWS_S3_BUCKET }}
These are configuration values, not credentials, so variables are a better fit and remain visible only to jobs using the
release
environment.Why it matters
Placing secrets in an environment and scoping them to the minimum surface area:
TODO for Maintainers
HEX_AWS_REGION
,HEX_AWS_S3_BUCKET
HEX_AWS_ACCESS_KEY_ID
HEX_AWS_SECRET_ACCESS_KEY
HEX_FASTLY_REPO_SERVICE_ID
HEX_FASTLY_BUILDS_SERVICE_ID
HEX_FASTLY_KEY
Once the moves are complete, new release builds will run with the tighter permissions automatically.