-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
MAINT: Apply security best practices #23131
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
MAINT: Apply security best practices #23131
Conversation
Let's see what StepSecurity does. Signed-off-by: StepSecurity Bot <[email protected]>
We probably want to remove dependabot from this, and maybe CodeQL as well. Not sure what |
I generated this security PR to see what it did, motivated by the alerts in the security tab. |
Hi @charris, thanks for using https://github.com/step-security/secure-workflows to create the PR. I am the maintainer for that project. I am curious why you don't want to add CodeQL and Dependabot. Those changes increase the OpenSSF Scorecard score. Moreover, if dependabot.yml or some other updating mechanism is not used, the pinned hashes for Actions will not get updated (using a dependabot PR) when there is a new version. w.r.t harden-runner, you can get more details here: https://github.com/step-security/harden-runner To not add any of the best practices, you can uncheck the issue type before creating the PR at http://app.stepsecurity.io/securerepo. There is also a feature to preview the PR. Thanks! Also adding @pnacht since I saw they initiated a discussion about Scorecard. |
We dropped dependabot because is was spamming all the numpy forks. It was a known problem, but it never got fixed AFAICT. Not sure about CodeQL, it could be useful. If we dismiss an alert, does it stay dismissed? |
I see dependabot was removed in #20268, which was in November 2021. However, dependabot has recently become default-off for forks (November 2022). |
w.r.t CodeQL, yes, my experience has been that once an alert is dismissed in the Code Scanning UI, it stays dismissed. |
I'm not sure I understand. Where did step-security-bot come from, who is behind it? Can we make each addition a separate PR? I would like to think about each tool separately. Here are a few thoughts but again I think they should be dealt with one-at-a-time:
At the end of the day, the OpenSSF Scorecard is just another measure by a third-party service who may value certain measures of security without considering the maintainer burden they add. Does OpenSSF do any kind of cost-benefit analysis on their reccomendations? (I asked this question in ossf/scorecard#2627 Each new tool comes with more maintainer burden, more discussions about the validity of its recommendations. As more of these automated tools become available via bots, and more organizations develop measures that recommend their use, the maintainer workload keeps growing. |
Hi @mattip, this semi-automated PR was created using https://github.com/step-security/secure-workflows. I am the maintainer of that project. The project helps to apply security best practices using automation. Even though
GitHub does recommend pinning 3rd party Actions. Dependabot can then update the hash when a new version is released. The tag of the new version is stored as a comment and that also gets updated by Dependabot.
CodeQL is from GitHub https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning-with-codeql.
@pnacht feel free to add to what I wrote. |
This concept is problematic. Security best practices cannot be applied without context. What in one area may be considered best practices may be overkill in other areas. Here is an example. A CVE was filed against setuptools claiming it could suffer from a DOS in a crafted package or custom PackageIndex page. But for the vast majority of the uses of setuptools (including the one in this repo NumPy), that CVE is not relevant since they do not use a custom PackageIndex. That CVE puts users of NumPy in an impossible situation: if they use automated tools to detect vulnerabilities, those tools will flag NumPy as unsafe and prevent its use. There currently is no released version of NumPy that can be used under that CVE. Well, except that:
Ahh, but wait, what if someone sets an environment variable to target a private PackageIndex. Then is NumPy susceptible to the CVE or not? Well, then is the problem only going to affect NumPy or is it going to apply to the entire python environment they are using? In short, in my opinion, adoption of automated tools to blindly apply security vulnerability data bases or automated tools for static code analysis to python code could have unintended consequences. For one such doomsday outcome, take a look at this discussion thread to ban python use in a corporate environment. |
@mattip I agree with you. I want to clarify that best practices are only being applied with the intent of a contributor. As you can see from @charris's comment,
Using https://github.com/step-security/secure-workflows, a contributor can choose what best practices they want to apply using a PR; each best practice can be de-selected using a checkbox. The contributor must then click on a button to generate a PR and can even create a preview of the PR to see the changes. I hope that clarifies that the bot is not creating the PR independently with a fixed set of best practices. A contributor can choose what they think will help based on the context of the project and apply them. I'm sorry if this caused confusion, and if you believe the PR text can be improved to clarify this, I can take that action item. Please let me know. Thanks! |
That's great - finally, took them 3+ years - but please don't bother adding Dependabot back. They've been godawful, and until there is much more evidence that they have changed, I am a very hard -1 on re-enabling it. |
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 for the PR. I'll have a closer look at this soon. The change to hashes for GitHub Actions seems good in principle (like, actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
). It's not entirely clear that this is useful for actions made by GitHub itself (the actions
repo) - there is some discussion about this in the Tidelift security scorecard channel that I'll revisit. But in general, where we use actions from individuals that we don't really know, it seems like a clear improvement.
I'll note that I de-selected some of the checks, saving them for later. |
Dependabot does run, you can see the results in the security tab, so it isn't like it is completely disabled. I used the results for #23130. EDIT: Maybe we can set it up to only notify for security alerts. But we pretty much already have that with the security tab. |
It's like one of those prickly weeds in your garden - no matter how hard you work to get rid of it, you never fully succeed ... |
I thought the security upgrades/pins were useful, it didn't bother alerting releases otherwise, which was nice. However, it did keep adding the same alerts to the list, so it has grown rather lengthy ... |
If the code quality comments mainly/only show up as annotations on changed lines, I am happy with them, should be rare enough to ignore them (i.e. none of the ones currently there seem really important, a more efficient regex may be nice, but really isn't a priority). No opinion on dependabot, pinning hashes seems fine in general (seems a bit like it makes more sense with rare auto-updates). Would it be possible to schedule dependabot on a very slow schedule to keep the hashes up-to date but otherwise hear nothing from it for months at a time? |
I'm happy to leave it under the security tab, but we do need to take a look now and then.
You can dismiss them and they should stay dismissed. That said, I think we could make issues of the current ones, they could be improved for clarity if nothing else.
|
@charris I am also the maintainer for harden-runner, so let me know if you have any questions about it. |
Will regenerate to resolve conflicts. |
Summary
This pull request is created by Secure Workflows at the request of @charris. Please merge the Pull Request to incorporate the requested changes. Please tag @charris on your message if you have any questions related to the PR. You can also engage with the StepSecurity team by tagging @step-security-bot.
Security Fixes
Pinned Dependencies
A pinned dependency is a dependency that is explicitly set to a specific hashed version instead of a mutable version. Pinned dependencis ensure that development and deployment are done with the same software versions which reduces deployment risks, and enables reproducibility. It can help mitigate compromised dependencies from undermining the security of the project in certain scenarios. The dependencies were pinned using Secure WorkFlows
Harden Runner
Harden-Runner is an open-source security agent for the GitHub-hosted runner to prevent software supply chain attacks. It prevents exfiltration of credentials, detects tampering of source code during build, and enables running jobs without
sudo
access.Harden runner usage
You can find link to view insights and policy recommendation in the build log
Please refer to documentation to find more details.
Keeping your actions up to date with Dependabot
The package ecosystem to update github-actions is added using Secure WorkFlows. This is recommended by GitHub as well as The Open Source Security Foundation (OpenSSF).
Detect Vulnerabilities with SAST Workflow
Static Code Analysis (also known as Source Code Analysis) is usually performed as part of a Code Review (also known as clear-box testing) and is carried out at the Implementation phase of a Security Development Lifecycle (SDL). Static Code Analysis commonly refers to the running of Static Code Analysis tools that attempt to highlight possible vulnerabilities within ‘static’ (non-running) source code by using techniques such as Taint Analysis and Data Flow Analysis.
Feedback
For bug reports, feature requests, and general feedback; please create an issue in step-security/secure-workflows. To create such PRs, please visit https://app.stepsecurity.io/securerepo.
Signed-off-by: StepSecurity Bot [email protected]