[expressjs-ip-control] Whitelist IP bypass leads to authorization bypass and sensitive info disclosure
The expressjs-ip-control module trusted the client-supplied X-Forwarded-For header when deciding whether a request came from a whitelisted IP. An attacker could add that header with a whitelisted address and reach pages that were meant to be restricted to local or trusted machines.
- Triaged in 46 hours
- Fixed in 13 months
- Disclosed after 14 months
I would like to report a unauthenticated access/authorization bypass issue in the expressjs-ip-control module.
It allows to bypass the whitelist IP check in order to bypass the authorization check and possibly expose sensitive datas.
Module
module name: [MODULE NAME]
version: [MODULE VERSION]
npm page: https://www.npmjs.com/package/[MODULE NAME]
Module Description
Expressjs package to whitelist IP addresses also support for x-forwarded-for ip addresses.
Module Stats
[N/A] downloads in the last day
[17] downloads in the last week
[~250] downloads in the last month
Vulnerability Description
The issue arises because the module checks if is present in the request a X-Forwarded-For header, and bases the authorization on that check ... as we know, that header can be simply manipulated, in order to bypass the protection, leading to sensitive information disclosure.
Steps To Reproduce:
- Install the module:
npm i expressjs-ip-control - Create a PoC file like this:
// poc.js
const express = require('express')
const app = express()
const ipControl = require('expressjs-ip-control')
app.get('/', ipControl({
whitelist: '127.0.0.1, 192.168.10.10',
}), (req, res) => res.send('SECRET TOKEN ACCESSIBLE ONLY BY LOCAL PC'))
app.listen(3000)
- Run the PoC:
node poc.js - Now, test the
whitelistprotection with this commands:
curl 'http://localhost:3000/' # Obtain *403* response --> *You do not have rights to visit this page*
curl 'http://localhost:3000/' -H 'X-Forwarded-For: 127.0.0.1' # Obtain *200* response --> secret token

Patch
Don't check for the
x-forwarded-forheader, has it can be changed leading toIP whitelistbypass
Supporting Material/References:
- [OPERATING SYSTEM VERSION]: Kali Linux
Wrap up
- I contacted the maintainer to let them know: [N]
- I opened an issue in the related repository: [N]
I'm not sure you'll consider this issue valid, as the x-forwarded-for header support, is a feature of the library. However, this "feature" leads to the issue I've described. If you won't consider this valid, pls be clement and also, can I know if you consider valid the same issue applied to a blacklist module? (in that case, it could allow attackers blacklisted to change IP without change PC and so continue DOS/spam the server :))
Impact
Whitelist IP bypass, leading toAuthorization issue on expressjs-ip-control, may lead to sensitive information disclosure
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The module made an access decision using the X-Forwarded-For header, which is fully controlled by the client, instead of only the real connection address.
Impact
An unauthenticated attacker could bypass the IP whitelist and reach restricted content, potentially exposing sensitive information.
What the attacker needed
The module is used for access control; attacker can send custom headers
The fix
The module should not trust the X-Forwarded-For header for access decisions, as the reporter suggests in the patch.
How it was found
- Install the expressjs-ip-control module.
- Create a small Express app that protects a route with an IP whitelist.
- Run the app and request the route without any extra header to see the 403 response.
- Repeat the request with an X-Forwarded-For header set to a whitelisted address to get the protected content.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Some web apps try to restrict pages to certain computers by looking at the address a request comes from. This library also looked at an extra header called X-Forwarded-For, which the visitor's own browser or tool can set to anything. So anyone could pretend to be a trusted machine and see the protected page.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.