Skip to content

[BUG] npm audit (security/advisories/bulk) inaccuracy #8125

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

Closed
2 tasks done
benpbolton opened this issue Feb 20, 2025 · 1 comment
Closed
2 tasks done

[BUG] npm audit (security/advisories/bulk) inaccuracy #8125

benpbolton opened this issue Feb 20, 2025 · 1 comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@benpbolton
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

For complex (multiple major versioned) CVE ranges, https://registry.npmjs.org/-/npm/v1/security/advisories/bulk incorrectly 'simplifies' affected versions.

e.g. GHSA-rmvr-2pp2-xj38 via related: octokit/graphql.js#638

Expected Behavior

echo '{"@octokit/request":["8.4.1"]}' | gzip -c | curl -X POST \
           https://registry.npmjs.org/-/npm/v1/security/advisories/bulk \
           -H "Content-Type: application/json" \
           -H "Content-Encoding: gzip" \
           -H "Accept: application/json" \
           --data-binary @-

Should return an empty object {} (no vulnerabilities found))

Instead, it returns:

{
  "@octokit/request": [
    {
      "id": 1102260,
      "url": "https://github.com/advisories/GHSA-rmvr-2pp2-xj38",
      "title": "@octokit/request has a Regular Expression in fetchWrapper that Leads to ReDoS Vulnerability Due to Catastrophic Backtracking",
      "severity": "moderate",
      "vulnerable_versions": ">=1.0.0 <9.2.1",
      "cwe": [
        "CWE-1333"
      ],
      "cvss": {
        "score": 5.3,
        "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
      }
    }
  ]
}

Expanding the vulnerable version range without constraints around the vulnerable versions reported by GitHub:

curl -L \
           -H "Accept: application/vnd.github+json" \
           -H "X-GitHub-Api-Version: 2022-11-28" \
           https://api.github.com/advisories/GHSA-rmvr-2pp2-xj38 | jq '.vulnerabilities'

of

[
  {
    "package": {
      "ecosystem": "npm",
      "name": "@octokit/request"
    },
    "vulnerable_version_range": ">= 9.0.0-beta.1, < 9.2.1",
    "first_patched_version": "9.2.1",
    "vulnerable_functions": []
  },
  {
    "package": {
      "ecosystem": "npm",
      "name": "@octokit/request"
    },
    "vulnerable_version_range": ">= 1.0.0, < 8.4.1",
    "first_patched_version": "8.4.1",
    "vulnerable_functions": []
  }
]

Steps To Reproduce

e.g. for this specific CVE:

git clone [email protected]:octokit/graphql.js.git -b 7.x
cd graphql.js
npm audit --loglevel=silly

npm audit incorrectly reports 8.4.1 as a vulnerable version

Environment

  • npm: 11.1.0
  • Node.js: 22.14.0
  • OS Name: 15.3 (24D60)
  • System Model Name: Macbook Pro
@benpbolton benpbolton added Bug thing that needs fixing Needs Triage needs review for next steps labels Feb 20, 2025
wolfy1339 added a commit to octokit/rest.js that referenced this issue Feb 26, 2025
…, bump `devDependencies` (#487)

This aims to resolve #486 `npm vulnerabilities with the 20.x branch

Should resolve:

GHSA-2p57-rm9w-gvfp
GHSA-3xgq-45jj-v275
GHSA-67mh-4wv8-2f99
GHSA-78xj-cgh5-2h22
GHSA-952p-6rrq-rcjv
GHSA-9qxr-qj54-h672
GHSA-9wv6-86v2-598j
GHSA-c2qf-rxjj-qqgw
GHSA-c76h-2ccp-4975
GHSA-c7qv-q95q-8v27
GHSA-f5x3-32g6-xq36
GHSA-grv7-fg5c-xmjg
GHSA-h5c3-5r3r-rr8q
GHSA-m4v8-wqvr-p9f7
GHSA-m6fv-jmcg-4jfg
GHSA-pxg6-pf52-xh8x
GHSA-qwcr-r2fm-qrc7
GHSA-rhx6-c78j-4q9w
GHSA-rmvr-2pp2-xj38
GHSA-xx4v-prfh-6cgc


----

### Before the change?
<!-- Please describe the current behavior that you are modifying. -->

> 31 vulnerabilities (3 low, 18 moderate, 10 high)

![CleanShot 2025-02-21 at 12 06
39](https://github.com/user-attachments/assets/02abda17-8aee-46e3-b808-764672a18475)


### After the change?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

> 9 moderate severity vulnerabilities

![CleanShot 2025-02-21 at 12 12
49](https://github.com/user-attachments/assets/10d593d8-9de5-478e-8cde-b5fb81762706)

**Important note**: the remaining reported 'moderate' vulnerabilities
for `@octokit/request` and `@octokit/plugin-paginate-rest` for
GHSA-h5c3-5r3r-rr8q and
GHSA-rmvr-2pp2-xj38 are actually mitigated
already; npm audit isn't taking the minor versions properly into account
as:

- @octokit/plugin-paginate-rest is patched in `9.2.2` (applied)
- @octokit/request is patched in `8.4.1` (applied)

This is a reporting issue: npm/cli#8125


### Pull request checklist

**Important note**: this PR reduces updates (reduces :() test coverage
due to the same challenges discovered in
#413 (comment)

- [x] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been reviewed and added / updated if needed (for bug
fixes / features)

### Does this introduce a breaking change?
<!-- If this introduces a breaking change make sure to note it here any
what the impact might be -->

Please see our docs on [breaking
changes](https://github.com/octokit/.github/blob/master/community/breaking_changes.md)
to help!

- [ ] Yes
- [x] No

----

---------

Co-authored-by: wolfy1339 <[email protected]>
wolfy1339 added a commit to octokit/rest.js that referenced this issue Feb 26, 2025
…, bump `devDependencies` (#487)

This aims to resolve #486 `npm vulnerabilities with the 20.x branch

Should resolve:

GHSA-2p57-rm9w-gvfp
GHSA-3xgq-45jj-v275
GHSA-67mh-4wv8-2f99
GHSA-78xj-cgh5-2h22
GHSA-952p-6rrq-rcjv
GHSA-9qxr-qj54-h672
GHSA-9wv6-86v2-598j
GHSA-c2qf-rxjj-qqgw
GHSA-c76h-2ccp-4975
GHSA-c7qv-q95q-8v27
GHSA-f5x3-32g6-xq36
GHSA-grv7-fg5c-xmjg
GHSA-h5c3-5r3r-rr8q
GHSA-m4v8-wqvr-p9f7
GHSA-m6fv-jmcg-4jfg
GHSA-pxg6-pf52-xh8x
GHSA-qwcr-r2fm-qrc7
GHSA-rhx6-c78j-4q9w
GHSA-rmvr-2pp2-xj38
GHSA-xx4v-prfh-6cgc

----

<!-- Please describe the current behavior that you are modifying. -->

> 31 vulnerabilities (3 low, 18 moderate, 10 high)

![CleanShot 2025-02-21 at 12 06
39](https://github.com/user-attachments/assets/02abda17-8aee-46e3-b808-764672a18475)

<!-- Please describe the behavior or changes that are being added by
this PR. -->

> 9 moderate severity vulnerabilities

![CleanShot 2025-02-21 at 12 12
49](https://github.com/user-attachments/assets/10d593d8-9de5-478e-8cde-b5fb81762706)

**Important note**: the remaining reported 'moderate' vulnerabilities
for `@octokit/request` and `@octokit/plugin-paginate-rest` for
GHSA-h5c3-5r3r-rr8q and
GHSA-rmvr-2pp2-xj38 are actually mitigated
already; npm audit isn't taking the minor versions properly into account
as:

- @octokit/plugin-paginate-rest is patched in `9.2.2` (applied)
- @octokit/request is patched in `8.4.1` (applied)

This is a reporting issue: npm/cli#8125

**Important note**: this PR reduces updates (reduces :() test coverage
due to the same challenges discovered in
#413 (comment)

- [x] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been reviewed and added / updated if needed (for bug
fixes / features)

<!-- If this introduces a breaking change make sure to note it here any
what the impact might be -->

Please see our docs on [breaking
changes](https://github.com/octokit/.github/blob/master/community/breaking_changes.md)
to help!

- [ ] Yes
- [x] No

----

---------

Co-authored-by: wolfy1339 <[email protected]>
mislav added a commit to mislav/toolkit that referenced this issue Mar 4, 2025
GHSA-h5c3-5r3r-rr8q

Note that `npm audit` will still show the updated version as vulnerable, even
though it is patched. npm/cli#8125
mislav added a commit to mislav/toolkit that referenced this issue Mar 7, 2025
GHSA-h5c3-5r3r-rr8q

Note that `npm audit` will still show the updated version as vulnerable, even
though it is patched. npm/cli#8125
mislav added a commit to mislav/toolkit that referenced this issue Mar 7, 2025
GHSA-h5c3-5r3r-rr8q

Note that `npm audit` will still show the updated version as vulnerable, even
though it is patched. npm/cli#8125
@wraithgar
Copy link
Member

It appears that the npm registry advisory is (or was) out of date. This isn't anything the npm cli itself is doing.

The advisory was updated but it looks like the npm registry copy wasn't.

The npm advisory database appears to have since been updated, so we're closing this

$ curl -s -X POST -H 'Content-Type: application/json, application/octet-stream' https://registry.npmjs.org/-/npm/v1/security/advisories/bulk --data-binary '{"@octokit/request":["8.4.1"]}'|json
{}

In the future, npm registry issues should go through https://www.npmjs.com/support, this repo is for the npm cli itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

2 participants