-
Notifications
You must be signed in to change notification settings - Fork 11
Prevent code injection in workflow #79
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
Conversation
Courtesy of Code Scanning. Signed-off-by: Mark Matyas <mmatyas@qti.qualcomm.com>
Test jobs for commit a701f38 |
@mynameistechno Was there some context from GitHub Code Scanning on why this is problematic? I don't immediately see why the modified approach is safer and I'm curious to read their guidance! Is there a way for me to receive these notifications about discovered issues directly? |
Same here. This patch should work when it comes to the purpose of the workflow, however I don't see any difference wrt code injection. |
Can you access this? https://github.com/qualcomm-linux/qcom-deb-images/security/code-scanning/2 I was just clicking around the Security tab to better understand it when I came across this reported vulnerability. I need to better understand permissions and alerts around the security features and how to provide access to maintainers. Going forward, we will be using Semgrep on PRs for this class of scanning anyway. We plan to use GitHub's dependency scanning/dependabot, GitHub's secret scanning, and Semgrep (instead of CodeQL) for code scanning/static analysis. @njjetha we should submit a PR to this repo that replaces the repolinter workflow with the qcom-preflights-check once we've verified it is working correctly. This is the workflow we plan to ask all repos to run https://github.com/qualcomm/qcom-actions/blob/main/.github/workflows/qcom-preflight-checks.yml . More info at https://github.com/qualcomm/qcom-actions
The solution was suggested by CodeQL. Essentially from what I can gather, when you assign the input to an intermediary variable, it is stored in memory and does not influence the actual script generation: https://securitylab.github.com/resources/github-actions-untrusted-input/ "The expressions inside of ${{ }} are evaluated and substituted with the resulting values before the shell script is run which may make it vulnerable to shell command injection." |
I can! Thanks
Ok, so indeed, I can see that if one assumes bad input into that input, it could be used to attach the action shell script; I guess we are not worried about untrusted people having the ability to call the workflow with random inputs, but it's a valid thing to defend against, so we can and should be extra careful. Thanks, interesting situation! |
FYI this wasn't defined properly; I submitted a fix here: |
Courtesy of GitHub Code Scanning.
I haven't tested this solution, mostly just wanted to share this general recommendation as there are a few of these across the organization. We can delete my branch after this is merged/closed.