CVE-2021-28918

9.1 CRITICAL

📋 TL;DR

A vulnerability in the netmask npm package allows attackers to bypass IP address filtering by submitting specially crafted octal strings. This enables Server-Side Request Forgery (SSRF), Remote File Inclusion (RFI), and Local File Inclusion (LFI) attacks against systems using vulnerable versions. Over 280,000 projects depending on netmask are potentially affected.

💻 Affected Systems

Products:
  • netmask npm package
  • Any application/package depending on netmask v1.0.6 or earlier
Versions: netmask v1.0.6 and all earlier versions
Operating Systems: All platforms running Node.js
Default Config Vulnerable: ⚠️ Yes
Notes: The vulnerability is in the core netmask library itself, so all configurations using vulnerable versions are affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers bypass network segmentation to access internal VPN/LAN resources, execute arbitrary code on backend systems, or read sensitive files from the server.

🟠

Likely Case

SSRF attacks allowing access to internal services, cloud metadata endpoints, or file disclosure from vulnerable applications.

🟢

If Mitigated

Limited to applications with additional input validation layers or those not using netmask for security-critical filtering.

🌐 Internet-Facing: HIGH - Directly exploitable via web applications using netmask for IP validation without authentication.
🏢 Internal Only: MEDIUM - Internal applications using netmask could be exploited by authenticated users or via other attack vectors.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Proof-of-concept code is publicly available, and exploitation requires minimal technical skill due to simple input manipulation.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: netmask v2.0.1

Vendor Advisory: https://github.com/advisories/GHSA-pch5-whg9-qr2r

Restart Required: No

Instructions:

1. Update package.json to require netmask ^2.0.1. 2. Run 'npm update netmask'. 3. Test application functionality with updated version.

🔧 Temporary Workarounds

Input validation wrapper

all

Implement additional input validation before passing IP addresses to netmask functions

// JavaScript example: Validate IP format before netmask processing
function validateIP(input) {
  // Add regex validation for proper IP format
  const ipRegex = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/;
  return ipRegex.test(input);
}

🧯 If You Can't Patch

  • Implement network-level controls to restrict outbound connections from vulnerable systems
  • Deploy WAF rules to block requests containing octal notation in IP parameters

🔍 How to Verify

Check if Vulnerable:

Check package.json or package-lock.json for netmask version <=1.0.6, or run 'npm list netmask'

Check Version:

npm list netmask | grep netmask

Verify Fix Applied:

Confirm netmask version is 2.0.1 or higher via 'npm list netmask'

📡 Detection & Monitoring

Log Indicators:

  • Unusual outbound connections from application servers
  • Requests containing IP addresses with leading zeros (octal notation)

Network Indicators:

  • Traffic from web servers to internal IP ranges not normally accessed
  • Unexpected connections to cloud metadata services

SIEM Query:

source="web_logs" AND (uri="*ip=0*" OR uri="*ip=0[0-7]*")

🔗 References

📤 Share & Export