惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
量子位
S
SegmentFault 最新的问题
V
Visual Studio Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
Stack Overflow Blog
Stack Overflow Blog
Vercel News
Vercel News
D
Docker
J
Java Code Geeks
博客园 - 三生石上(FineUI控件)
博客园 - Franky
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
V
V2EX

NodeJS Security & NodeJS Secure Coding's Blog

Hardening Your npm and pnpm Configs in the Age of Shai-Hulud Argument Injection vulnerability in git-blame@1.4.0 Argument Injection vulnerability in `gits@0.1.8` Command Injection vulnerability in `@fab1o/git@1.4.0` Command Injection vulnerability in `git-contributors` via unsanitized CLI arguments Command Injection vulnerability in `git-q@0.0.3` Command injection vulnerability via unsanitized CLI arguments in touxing/fast-git-clone Command Injection vulnerability in `willitmerge@0.2.1` A Directory Traversal Vulnerability I found in Mastra AI Frameworks MCP Server Mastering NPX: A Cheatsheet for npm and Node.js Power Users Mitigate Supply Chain Security with DevContainers and 1Password for Node.js Local Development The Tale of the Vulnerable MCP Database Server Bad Security Defaults in Mastra AI Frameworks Templates SQL Injection and Bypassing "Read-Only" Mode in Xata's MCP Server Security Advisory for qix npm supply-chain compromise affecting debug and billions of weekly download users How to Mitigate SQL Bypass in MCP Servers Enhancing MCP Server Security: A Guide to Using execFile Argument Injection Vulnerability in ggit How to Bypass Access Control in PostgreSQL in Simple PSQL MCP Server for SQL Injection Command Injection Flaws in ggit: Unveiling a Vulnerability Command Injection Vulnerability in Create MCP Server STDIO Tool Exposes System Monitoring Functions GitHub Kanban MCP Server Command Injection Vulnerability Threatens Developer Workflows Critical Command Injection Flaw in iOS Simulator MCP Server Exposes Development Environments Command Injection Vulnerability Discovered in Codehooks MCP Server: A Critical Security Analysis SSRF Shenanigans in safe-axios: Redirects Open the Backdoor SSRF Vulnerability in safe-axios: Unintended Public Address Classification Bypassing SSRF Safeguards in ssrfcheck: A Case of Incomplete Denylists Node.js Authentication from Lucia to Better Auth Bypassing SSRF Protection in nossrf: When Your Safeguards Become Loopholes Vue CLI Security Fix to Mitigate NPM Binary Planting
Don't Be Fooled by Multicast, SSRF Bypass in private-ip
2025-05-01 · via NodeJS Security & NodeJS Secure Coding's Blog

Greetings, developers and fellow appsec practitioners! Another SSRF (Server-Side Request Forgery) vulnerability report for us to learn from. In this one, an SSRF bypass vulnerability I discovered in a popular npm package called private-ip. This package helps developers determine if an IP address falls within a private range. However, a clever attacker can exploit a blind spot in its logic to bypass these safeguards. Let’s dissect the issue and explore its practical implications.

Understanding private-ip: Your Ally in SSRF Prevention (Almost)

SSRF vulnerabilities arise when an application makes unintended requests to external servers based on user-controlled input. Attackers can leverage this to trick the application into fetching internal resources, performing unauthorized actions, or even launching denial-of-service attacks.

The private-ip package aims to mitigate this risk by identifying private IP addresses. Developers can integrate it into their applications to validate user-provided URLs or IP addresses. If the input resolves to a private IP, it’s likely an internal resource, and the application can handle it accordingly.

However, a critical vulnerability renders this validation incomplete.

The Vulnerability: A Gap in the Private IP Net

The crux of the issue lies in how private-ip defines private IP ranges. The package relies on a hardcoded list of IP ranges considered “private.” Unfortunately, this list omits an important category: multicast IP addresses.

Here’s the relevant code snippet from private-ip (for the technically curious):

const PRIVATE_IP_RANGES = [

// ... List of private IP ranges

'224.0.0.0/4' // This range (multicast) is missing!

];

Multicast addresses (ranging from 224.0.0.0 to 239.255.255.255) are a special class of IP addresses used for one-to-many communication. While not technically “private” in the traditional sense, an attacker could potentially craft a request leveraging a multicast address to exploit an SSRF vulnerability in the application.

Consider the following real-world example - imagine an application utilizes private-ip to validate incoming requests. An attacker could send a request with a hostname resolving to a multicast IP address. Since private-ip wouldn’t flag this as suspicious, the application might unknowingly process the request, potentially leading to unauthorized access or internal resource leakage.

A Reference Case: CVE-2020-28360

This vulnerability in the ip npm package (a similar package for IP address utilities) serves as a cautionary tale. An attacker could exploit an insufficient regular expression to bypass its private IP validation and potentially launch SSRF attacks. This incident highlights the importance of thorough validation logic when dealing with IP addresses.

SSRF Practical Example and Proof of Concept (PoC)

Let’s solidify our understanding with some code examples:

// Using private-ip

const isPrivateIP = require('private-ip');

console.log(isPrivateIP('127.0.0.1')); // True (correctly identified)

console.log(isPrivateIP('10.0.0.1')); // True (correctly identified)

console.log(isPrivateIP('239.255.255.250')); // **False Negative!** (incorrectly identified)

As you can see, private-ip incorrectly classifies the multicast address 239.255.255.250 as a non-private IP. This oversight could lead to potential SSRF vulnerabilities in applications relying on this package for input validation.

For educational purposes only, here’s a PoC demonstrating the bypass:

  1. Install the private-ip package:
  1. Define an app.js file with the programmatic API of private-ip as follows:

import is_ip_private from 'private-ip'

import ipaddr from 'ipaddr.js'

// -- private-ip

console.log(is_ip_private('127.0.0.1'))

console.log(is_ip_private('10.0.0.0'))

console.log(is_ip_private('169.254.0.1'))

console.log(is_ip_private('239.255.255.250'))

// -- ipaddr.js

console.log(ipaddr.parse('127.0.0.1').range())

console.log(ipaddr.parse('10.0.0.0').range())

console.log(ipaddr.parse('169.254.0.1').range())

console.log(ipaddr.parse('239.255.255.250').range())

  1. Run the app.js file:
  1. Observe that the private-ip package does not detect the multicast IP address 239.255.255.250 as a private IP address and returns true for all 4 checks.

As a case of comparison, the ipaddr.js package correctly identifies the multicast IP address as a non-private IP address.

import ipaddr from 'ipaddr.js'

// -- ipaddr.js

console.log(ipaddr.parse('127.0.0.1').range())

console.log(ipaddr.parse('10.0.0.0').range())

console.log(ipaddr.parse('169.254.0.1').range())

console.log(ipaddr.parse('239.255.255.250').range())

It would result in the following stdout:

loopback

private

linkLocal

multicast