Skip to content

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

Description

@taylorjdawson

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
  }
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions