Skip to content

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

Closed
@taylorjdawson

Description

@taylorjdawson

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

Effected packages:

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

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