Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
The 'forwarded' npm package is designed to parse the 'X-Forwarded-For' header from an HTTP request, which is a standard header for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer. This package extracts the IP addresses listed in the header and provides them in an array format, making it easier to handle cases where there are multiple proxies in use.
Parse X-Forwarded-For header
This feature allows you to parse the 'X-Forwarded-For' header from an HTTP request object and returns an array of IP addresses that were added by each proxy.
const forwarded = require('forwarded');
const req = { headers: { 'x-forwarded-for': '192.0.2.60, 198.51.100.17' } };
const ips = forwarded(req);
console.log(ips); // ['192.0.2.60', '198.51.100.17']
Similar to 'forwarded', 'proxy-addr' is used to determine the address of the client that connected to the proxy server. It provides more functionality, such as trusting custom IP address ranges and determining the client's IP address from a list of trusted proxies.
While 'ipware' is not limited to Node.js and is also available for Python, it offers similar functionality for getting the client's IP address from the 'X-Forwarded-For' header or other headers like 'X-Real-IP'. It also provides features to customize trusted proxies and private IP ranges.
The 'request-ip' package is another alternative that retrieves the client's IP address from an HTTP request. It supports both IPv4 and IPv6 addresses and works with various headers, including 'X-Forwarded-For'. It is a simple and straightforward package for getting the client's IP address without additional configuration options.
Parse HTTP X-Forwarded-For header
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install forwarded
var forwarded = require('forwarded')
var addresses = forwarded(req)
Parse the X-Forwarded-For
header from the request. Returns an array
of the addresses, including the socket address for the req
, in reverse
order (i.e. index 0
is the socket address and the last index is the
furthest address, typically the end-user).
$ npm test
FAQs
Parse HTTP X-Forwarded-For header
The npm package forwarded receives a total of 27,616,863 weekly downloads. As such, forwarded popularity was classified as popular.
We found that forwarded demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.