Pre-submission checks
What's the problem this feature will solve?
In GitHub Actions, environment variables can now be declared at the workflow level, at the individual job level, and at the step level.
If variables are declared for all steps, values in env that depend on secrets.* become accessible to a wider range of steps than might be necessary :(
jobs:
example:
runs-on: ubuntu-latest
env:
JOB_SECRET: ${{ secrets.JOB_SECRET }} # bad: available to all `steps`
steps:
- name: vulnerable step
shell: bash
run: |
# could steal secrets
./vulnerable_script.sh
- name: working step
shell: bash
run: |
./working_script.sh
- name: vulnerable step
shell: bash
run: |
# could steal secrets
./vulnerable_script.sh
Describe the solution you'd like
- warn if
workflow.env uses a value from secrets.*
- warn if
jobs.<job_id>.env uses a value from secrets.*
- do not warn if
jobs.<job_id>.steps[*].env uses a value from secrets.*
Additional context
name: CI
on:
push:
workflow_dispatch:
env:
WORKFLOW_SECRET: ${{ secrets.WORKFLOW_SECRET }} # bad: available to all `jobs` and `steps`
jobs:
test:
runs-on: ubuntu-latest
env:
JOB_SECRET: ${{ secrets.JOB_SECRET }} # bad: available to all `steps`
steps:
- name: step 1
shell: bash
run: |
echo $WORKFLOW_SECRET | base64 | base64
echo $JOB_SECRET | base64 | base64
echo $STEP_SECRET | base64 | base64
- name: step 2
env:
STEP_SECRET: ${{ secrets.STEP_SECRET }} # good: available to this `step`
shell: bash
run: |
echo $WORKFLOW_SECRET | base64 | base64
echo $JOB_SECRET | base64 | base64
echo $STEP_SECRET | base64 | base64
- name: step 3
shell: bash
run: |
echo $WORKFLOW_SECRET | base64 | base64
echo $JOB_SECRET | base64 | base64
echo $STEP_SECRET | base64 | base64
Pre-submission checks
What's the problem this feature will solve?
In GitHub Actions, environment variables can now be declared at the workflow level, at the individual job level, and at the step level.
If variables are declared for all steps, values in
envthat depend onsecrets.*become accessible to a wider range of steps than might be necessary :(Describe the solution you'd like
workflow.envuses a value fromsecrets.*jobs.<job_id>.envuses a value fromsecrets.*jobs.<job_id>.steps[*].envuses a value fromsecrets.*Additional context