Skip to content
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

🚨 Security Vulnerability: ip npm package is unsafe for use as of v1.1.8 #2294

Closed
taylorjdawson opened this issue Feb 9, 2024 · 21 comments · Fixed by #2299
Closed

🚨 Security Vulnerability: ip npm package is unsafe for use as of v1.1.8 #2294

taylorjdawson opened this issue Feb 9, 2024 · 21 comments · Fixed by #2299

Comments

@taylorjdawson
Copy link

taylorjdawson commented Feb 9, 2024

NPM ip package is vulnerable to Server-Side Request Forgery (SSRF) attacks, see GitHub advisory for more information.

Effected packages:

  • @react-native-community/cli-doctor@12.3.2 includes ip in the package.json file but doesn't appear to be used in the code itself.

  • @react-native-community/cli-hermes@12.3.2:
    It looks like the ip.isPublic isn't explictly used within the @react-native-community/cli-hermes@12.3.2 pkg:

    const IP_ADDRESS = ip.address();

    However, ip.address does call ip.isPublic under the hood:

    //...
          return name === 'public' ? ip.isPrivate(details.address)
        : ip.isPublic(details.address);
    });
    

Could potentially introduce a function to check that the IP address isn't private or reserved using the ipaddr.js lib

// Function to check if the IP address is safe to use (not private or reserved)
function isSafeIPAddress(ipAddress) {
  try {
    const addr = ipaddr.parse(ipAddress);

    // Check if the IP address is in a private or reserved range
    const range = addr.range();
    return range !== 'private' && range !== 'loopback' && range !== 'linkLocal' && range !== 'uniqueLocal';
  } catch (e) {
    console.error("Error parsing IP address:", e);
    return false; // Consider the IP address unsafe if it cannot be parsed
  }
}
@IzumiKomatsu

This comment was marked as duplicate.

@szymonrybczak

This comment was marked as outdated.

@taylorjdawson

This comment was marked as outdated.

@szymonrybczak

This comment was marked as outdated.

@DiNMEA

This comment was marked as duplicate.

@glitch-txs
Copy link

seems like this upstreams to the latest version of react-native

@salmaazakii

This comment was marked as duplicate.

@darakeon
Copy link

The ip package last update was 2 years ago.
https://www.npmjs.com/package/ip

My problem is with puppeteer instead of react, but same issue: will really ip package be updated? I think it is not maintained anymore...

@jxia-innablr

This comment was marked as off-topic.

@glitch-txs
Copy link

glitch-txs commented Feb 12, 2024

anyone find any workaround pls share here, thanks!

there's no workaround, the library needs to be either patched or replaced

@thymikee
Copy link
Member

FYI, the only affected command is profile-hermes when producing source maps. If you're not using it on a server (e.g. your CI), you're safe to ignore this and wait for us to patch it once we have a proper solution. If you are using it however, please disable it temporarily.

dlpzx added a commit to data-dot-all/dataall that referenced this issue Feb 13, 2024
### Feature or Bugfix
- Bugfix

### Detail
- Add `.nsprc` file for ignored vulnerabilities in `better-npm-audit`. 
- Added `ip` package to ignored vulnerabilities with expiration
2024/02/28: https://www.cve.org/CVERecord?id=CVE-2023-42282

The vulnerability found in `ip` affects us because we use the
`react-native-community/cli` package. In this package repository an
[issue reporting the
vulnerabilty](react-native-community/cli#2294)
was already raised.

Update: `ip` team is working on a fix:
indutny/node-ip#138
### Relates
- https://www.cve.org/CVERecord?id=CVE-2023-42282

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
mvaivre added a commit to alephium/alephium-frontend that referenced this issue Feb 13, 2024
Problem: no fix yet for IP package: react-native-community/cli#2294
@henriquelomarques
Copy link

same error here

@antoinecaputo
Copy link

The PR is opened here and should probably be merged soon.

@mnikolaus
Copy link

The PR is opened here and should probably be merged soon.

I wouldn't count on it to be merged soon... I've seen a lot of depended libraries moving away from ip lib. I think @taylorjdawson proposal is very sound

@whayu901
Copy link

anyone find any workaround pls share here, thanks!

there's no workaround, the library needs to be either patched or replaced

i have tried patched the ip library. But still not work for me

nop33 pushed a commit to alephium/alephium-frontend that referenced this issue Feb 20, 2024
Problem: no fix yet for IP package: react-native-community/cli#2294
@lsmith77
Copy link

FYI there is now a 1.1.9 and 2.0.1.

However the CVE needs to be updated to allow the 1.1.9 release to be seen as a valid fix:
github/advisory-database#3553

@thymikee
Copy link
Member

1.1.9 is within the semver range so refreshing the lock file should be enough. Additionally we merged #2299 (which drops the dependency on ip offering an alternative) which we intend to backport to RN 0.72 and 0.71 – although with the fix being within the semver range, I'm not sure if that's gonna be necessary and will leave that to the RN release crew to decide.

@lsmith77
Copy link

yeah .. I just wanted to point out that this release now exists and that people might still see dependabot etc complain until the CVE is updated.

@thymikee
Copy link
Member

Thanks for doing that @lsmith77

@azmainamin
Copy link

If using React Native version 0.68.2. How can we get the patch/fix?

@thymikee
Copy link
Member

@azmainamin it should be enough to regenerate the lockfile entry for this package in your project, now that github/advisory-database#3553 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet