When I opened npm's tutorial on auditing dependencies, I was curious about the other end of the process. If someone tells me a package I maintain has a vulnerability, how do I reach the people still using older versions? For an npm package hosted in a public GitHub repository, maintainers can publish a security advisory specifying which versions of which package are affected. When a user runs npm audit, npm can use indexed advisories to check the project's dependencies.12
Where does the maintainer publish the advisory?
- Create a private draft. A maintainer with admin access can open the repository's Advisories page on GitHub and choose New draft security advisory. Use the draft to confirm the affected versions with the reporter, discuss the fix, and decide when to go public.3
- Specify the package name and version range. Under Affected products, select
npmand enter the full published package name, including its@organization/scope if it has one. Fill in the affected version range and the released version containing the fix. In the description, explain under what conditions users are affected and whether they have a workaround until they upgrade.3 - Publish the advisory. After checking the details, select Publish advisory. If a fix hasn't shipped, you can disclose the known impact first and add the patched version number once it's available. Maintainers may optionally request a Common Vulnerabilities and Exposures (CVE) identifier.45
How does the advisory end up in npm audit?
GitHub reviews published repository advisories and includes them in the GitHub Advisory Database. The official npm registry has used that database to answer audit requests since 2021. When someone runs npm audit in a project, npm sends the package names and versions from the dependency tree to the configured registry to check which versions fall within the scope of a known vulnerability.526
For example, a public advisory from 2024 lists the affected versions of the npm package braces as < 3.0.3 and the patched version as 3.0.3. Suppose I didn't install braces directly, but another dependency brought in braces@3.0.2. Running npm audit would still show the advisory. Once that copy in my dependency tree is upgraded to 3.0.3, it falls outside the advisory's affected range.76
Footnotes
-
npm. (n.d.). Auditing package dependencies for security vulnerabilities. npm Docs. Running a security audit with npm audit. ↩
-
Thomson, E. (2021, October 7). GitHub Advisory Database now powers npm audit. The GitHub Blog. GitHub Advisory Database + npm. ↩ ↩2
-
GitHub. (n.d.). Creating a repository security advisory. GitHub Docs. Creating a security advisory. ↩ ↩2
-
GitHub. (n.d.). Publishing a repository security advisory. GitHub Docs. Publishing a security advisory. ↩
-
GitHub. (n.d.). Repository security advisories. GitHub Docs. Publication of security advisories. ↩ ↩2
-
npm. (n.d.). npm-audit (CLI v10). npm Docs. Bulk Advisory Endpoint. ↩ ↩2
-
GitHub Advisory Database. (2024, May 14). Uncontrolled resource consumption in braces (GHSA-grv7-fg5c-xmjg). GitHub. Affected versions and patched versions. ↩