Mitigate security risks found using Zizmor - #924
Conversation
6d7b7e8 to
ae83704
Compare
7277e3f to
22c087f
Compare
|
Looks like a great step in the right direction! Once this PR has been merged I wouldn't mind collaborating on some additional workflow security improvements. |
|
Hi @andreaso, thanks a lot! 😃 I'll prioritize this PR to get it merged sooner. Looking forward to more workflow security improvements! |
|
@fatima2003: Since you keep adding to this PR, I hope you won't mind me jumping in with a general piece of advice... Right now it looks like you simply are trying to resolve as many individual zizmor warning as possible by adding more and more input validation steps? And while input validation no doubt is a good thing, maybe also consider taking a step back, and consider some more strategic approaches? For example, rather than always creating global environment variables by writing to Or rather than updating PATH by writing to None of these example fully does away with the dangers of untrusted inputs, but it puts everything in a smaller and more manageable scope. Finally, how much time are you spending on evaluating to what extent each zizmor warning actually apply to the specific circumstances in these specific workflows? After all, false positives are a thing.... |
Signed-off-by: fp17 <fp17@hw.ac.uk>
|
Hi @andreaso, thank you for your input! I'm still getting familiar with workflows, so I was referencing other articles and PR's: like packaging.python.org #1748, Exploring Github Vulnerabilities and Preventing script injection by using env var. This is prolly why my approach has been heavily focused on using environment variables 😅 I appreciate your advice and will try setting output parameters and $GITHUB_PATH where it feels appropriate. The warnings I was focusing on addressing were Regarding the last point on evaluating whether each Zizmor warning is applicable, I don’t have a specific test for that. My approach was primarily focused on replacing template substitutions in Bash scripts, since I assume the risk of template injection is most significant there, as advised in GitHub's security hardening guide. Really appreciate the advice and look forward to more feedback as I work on this :D |
|
Yeah, setting I should probably clarify that my dislike for setting environment variables is strictly a dislike for setting environment variables that persist through the entire job, like when writing to To me setting environment variables that persist through the entire job vs. using outputs for defining environment variables on a step level is similar to the distinction between working with global variables vs with local variables. Yes, having access to global variables can be very convenient, but once your code base passes a certain size it can easily become really hairy to keep track of them all. Of course, working with environment variables that persist through the entire job has the potential to become even hairier, since there's a whole bunch of them that will affect runtime behavior even if they aren't explicitly referenced. If we now look at this from a security perspective the term blast radius ought to apply. Yes, it's very common that documentation examples as well as third party Actions will set environment variables that persist through out a job, and I understand why. Persistent environment variables are familiar, easy to use and they do work fine as long as your workflows are sufficiency simple. UPDATE: Added a few more words to also cover how outputs fits into the big picture. |
- persisted credentials to false. - used GITHUB_OUTPUTS to prevent template injection and keep variable declarations within scope of steps that require them. Signed-off-by: fp17 <fp17@hw.ac.uk>
Signed-off-by: fp17 <fp17@hw.ac.uk>
Signed-off-by: fp17 <fp17@hw.ac.uk>
Signed-off-by: fp17 <fp17@hw.ac.uk>
Signed-off-by: fp17 <fp17@hw.ac.uk>
Signed-off-by: FattiesPatties <63286473+fatima2003@users.noreply.github.com>
cipherboy
left a comment
There was a problem hiding this comment.
Few minor nits about shell quoting and then I'll merge!
Co-authored-by: Alexander Scheel <alexander.m.scheel@gmail.com> Signed-off-by: FattiesPatties <63286473+fatima2003@users.noreply.github.com>
|
@cipherboy test-go (7) failure seems unrelated and also shows up in 64ce299. Edit: hmmm it fails for the same reason as the race detection test for 7 mentioned in #1031: |
cipherboy
left a comment
There was a problem hiding this comment.
Thank you @fatima2003 and appreciate the assist @andreaso!
|
Thank you for the review @cipherboy and @andreaso! |
Found a few vulnerabilities in the workflow using zizmor.
Fixed 33 warnings by:
Zizmor still returns some warnings:
References: