-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Extend Security Best Practices for your Project #3465
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
Open
UlisesGascon
wants to merge
8
commits into
github:main
Choose a base branch
from
UlisesGascon:update-seccurity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+73
−3
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
becfcd3
docs: mention license risks
UlisesGascon dc4df46
docs: mention team effort
UlisesGascon c5ea56b
docs: mention threat models
UlisesGascon 272fa26
docs: mention IRP
UlisesGascon 6b4e258
docs: minor changes
UlisesGascon 9e75f8c
chore: linting
UlisesGascon 969353d
Merge branch 'main' into update-seccurity
UlisesGascon e886ee9
Merge branch 'main' into update-seccurity
jmeridth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,13 +50,27 @@ Picture this: a project built on the sturdy foundation of a widely-used library. | |
|
||
To prevent such scenarios, Software Composition Analysis (SCA) tools such as Dependabot and Renovate automatically check your dependencies for known vulnerabilities published in public databases such as the NVD or the GitHub Advisory Database, and then creates pull requests to update them to safe versions. Staying up-to-date with the latest safe dependency versions safeguards your project from potential risks. | ||
|
||
## Understand and manage open source license risks | ||
|
||
### Open source licenses come with terms and ignoring them can lead to legal and reputational risks. | ||
|
||
Using open source dependencies can speed up development, but each package includes a license that defines how it can be used, modified, or distributed. Some licenses are permissive, while others (like AGPL or SSPL) impose restrictions that may not be compatible with your project's goals or your users' needs. | ||
|
||
Imagine this: You add a powerful library to your project, unaware that it uses a restrictive license. Later, a company wants to adopt your project but raises concerns about license compliance. The result? You lose adoption, need to refactor code, and your project’s reputation takes a hit. | ||
|
||
To avoid these pitfalls, consider including automated license checks as part of your development workflow. These checks can help identify incompatible licenses early in the process, preventing problematic dependencies from being introduced into your project. | ||
|
||
Another powerful approach is generating a Software Bill of Materials (SBOM). An SBOM lists all components and their metadata (including licenses) in a standardized format. It offers clear visibility into your software supply chain and helps surface licensing risks proactively. | ||
|
||
Just like security vulnerabilities, license issues are easier to fix when discovered early. Automating this process keeps your project healthy and safe. | ||
|
||
## Avoid unwanted changes with protected branches | ||
|
||
### Unrestricted access to your main branches can lead to accidental or malicious changes that may introduce vulnerabilities or disrupt the stability of your project. | ||
|
||
A new contributor gets write access to the main branch and accidentally pushes changes that have not been tested. A dire security flaw is then uncovered, courtesy of the latest changes. To prevent such issues, branch protection rules ensure that changes cannot be pushed or merged into important branches without first undergoing reviews and passing specified status checks. You're safer and better off with this extra measure in place, guaranteeing top-notch quality every time. | ||
|
||
## Set up an intake mechanism for vulnerability reporting | ||
## Make it easy (and safe) to report security issues | ||
|
||
### It's a good practice to make it easy for your users to report bugs, but the big question is: when this bug has a security impact, how can they safely report them to you without putting a target on you for malicious hackers? | ||
|
||
|
@@ -70,15 +84,71 @@ To avoid this, publish a security policy. A security policy, defined in a `SECUR | |
|
||
On some platforms, you can streamline and strengthen your vulnerability management process, from intake to broadcast, with private issues. On GitLab, this can be done with private issues. On GitHub, this is called private vulnerability reporting (PVR). PVR enables maintainers to receive and address vulnerability reports, all within the GitHub platform. GitHub will automatically create a private fork to write the fixes, and a draft security advisory. All of this remains confidential until you decide to disclose the issues and release the fixes. To close the loop, security advisories will be published, and will inform and protect all your users through their SCA tool. | ||
|
||
### Define your threat model to help users and researchers understand scope | ||
|
||
Before security researchers can report issues effectively, they need to understand what risks are in scope. A lightweight threat model can help define your project’s boundaries, expected behavior, and assumptions. | ||
|
||
A threat model doesn’t need to be complex. Even a simple document outlining what your project does, what it trusts, and how it could be misused goes a long way. It also helps you, as a maintainer, think through potential pitfalls and inherited risks from upstream dependencies. | ||
|
||
A great example is the [Node.js threat model](https://github.com/nodejs/node/security/policy#the-nodejs-threat-model), which clearly defines what is and isn’t considered a vulnerability in the project’s context. | ||
|
||
If you’re new to this, the [OWASP Threat Modeling Process](https://owasp.org/www-community/Threat_Modeling_Process) offers a helpful introduction to build your own. | ||
|
||
Publishing a basic threat model alongside your security policy improves clarity for everyone. | ||
|
||
### Prepare a lightweight incident response process | ||
|
||
<aside markdown="1" class="pquote"> | ||
<img src="https://avatars.githubusercontent.com/ulisesgascon?s=180" class="pquote-avatar" alt="avatar"> | ||
A vulnerability is basically a flaw, a security misconfiguration or a weak point in our system that can be exploited by third parties to behave in unintended ways. | ||
<p markdown="1" class="pquote-credit"> | ||
— [@UlisesGascon](https://github.com/ulisesgascon), ["What is a Vulnerability and What’s Not? Making Sense of Node.js and Express Threat Models"](https://gitnation.com/contents/what-is-a-vulnerability-and-whats-not-making-sense-of-nodejs-and-express-threat-models) | ||
</p> | ||
</aside> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed some of the other pages include quotes for emphasis, so I added a short one from myself in this version for consistency. Totally happy to remove it if it doesn’t fit the tone or style 🫠 |
||
|
||
Once you receive a vulnerability report, what happens next? | ||
|
||
Having a basic incident response plan, even a simple checklist, helps you stay calm and act efficiently when time matters. It also shows users and researchers that you take reports seriously. | ||
|
||
Your process doesn't have to be complex. At minimum, define: | ||
- Who reviews and triages security reports | ||
- How you evaluate severity and decide on mitigation | ||
- What steps you take to prepare a fix and publish a disclosure | ||
- How you notify affected users or contributors, if needed | ||
|
||
Coordinated disclosure works best when there's a clear plan. Publishing this (or linking to it) in your `SECURITY.md` file can help set expectations and build trust. | ||
|
||
For inspiration, the [Express.js Security WG](https://github.com/expressjs/security-wg/blob/main/docs/incident_response_plan.md) provides a simple but effective example of an open source incident response plan. | ||
|
||
This plan can evolve as your project grows, but having a basic framework in place now can save time and reduce mistakes later. | ||
|
||
|
||
## Treat security as a team effort | ||
|
||
### Security isn't a solo responsibility. It works best when shared across your project's community. | ||
|
||
While tools and policies are essential, a strong security posture comes from how your team and contributors work together. Building a culture of shared responsibility helps your project identify, triage, and respond to vulnerabilities faster and more effectively. | ||
|
||
Here are a few ways to make security a team sport: | ||
|
||
- **Assign clear roles**: Know who handles vulnerability reports, who reviews dependency updates, and who approves security patches. | ||
- **Limit access using the principle of least privilege**: Only give write or admin access to those who truly need it and review permissions regularly. | ||
- **Invest in education**: Encourage contributors to learn about secure coding practices, common vulnerability types, and how to use your tools (like SAST or secret scanning). | ||
- **Foster diversity and collaboration**: A heterogeneous team brings a wider set of experiences, threat awareness, and creative problem-solving skills. It also helps uncover risks others might overlook. | ||
- **Engage upstream and downstream**: Your dependencies can affect your security and your project affects others. Participate in coordinated disclosure with upstream maintainers, and keep downstream users informed when vulnerabilities are fixed. | ||
|
||
Security is an ongoing process, not a one-time setup. By involving your community, encouraging secure practices, and supporting each other, you build a stronger, more resilient project and a safer ecosystem for everyone. | ||
|
||
## Conclusion: A few steps for you, a huge improvement for your users | ||
|
||
These few steps might seem easy or basic to you, but they go a long way to make your project more secure for its users, because they will provide protection against the most common issues. | ||
|
||
Security isn’t static. Revisit your processes from time to time as your project grows, so do your responsibilities and your attack surface. | ||
|
||
## Contributors | ||
|
||
### Many thanks to all the maintainers who shared their experiences and tips with us for this guide! | ||
|
||
This guide was written by [@nanzggits](https://github.com/nanzggits) & [@xcorail](https://github.com/xcorail) with contributions from: | ||
|
||
[@JLLeitschuh](https://github.com/JLLeitschuh) | ||
[@intrigus-lgtm](https://github.com/intrigus-lgtm) + many others! | ||
[@JLLeitschuh](https://github.com/JLLeitschuh), [@intrigus-lgtm](https://github.com/intrigus-lgtm), [@UlisesGascon](https://github.com/ulisesgascon) + many others! |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@Jeffrey-Luszcz feel free to suggest a better example for the mixed-license scenario in the license section. You probably have a much stronger one than mine 🙏