-
Notifications
You must be signed in to change notification settings - Fork 32
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
Mitigate injection #115
Mitigate injection #115
Conversation
Replace interpolated context variables with default variables used more defensively. This mitigates an attacker naming a branch a command that could run in our runner's context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -10,7 +10,7 @@ jobs: | |||
runs-on: ubuntu-latest | |||
steps: | |||
- name: Print build information | |||
run: "echo head_ref: ${{ github.head_ref }}, ref: ${{ github.ref }}" | |||
run: 'echo head_ref: "$GITHUB_HEAD_REF", ref: "$GITHUB_REF"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may have to set these as environment variables first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are actually set by Github by default and are available to every step in a workflow. You can verify that it's working here: https://github.com/temporalio/api-go/actions/runs/5754549570/job/15600068301?pr=115
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kind of can't believe that gha has such a security-footgun with no warnings or easy alternatives. I've fixed this in multiple other places. there isn't even a "shell-escape" filter available on substitutions :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry! I confused the exec line for the output. Thanks, will merge.
What changed?
Replace interpolated github context variables with default variables used more defensively.
Why?
This mitigates an attacker naming a branch a command that could run in our runner's context.
How did you test it?
Ran in my own fork and it was fine in my workflow.
Potential risks
Somehow not printing the build info in the workflow output.