Skip to content
Info disclosure Disclosed report Beginner

[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.

mik317 Follow

Originally disclosed on HackerOne

  • 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:

  1. Install the module: npm i expressjs-ip-control
  2. Create a PoC file like this:
JavaScript
// 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)
  1. Run the PoC: node poc.js
  2. Now, test the whitelist protection with this commands:
Bash
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
Screenshot_from_2019-09-12_15-36-06.png
Screenshot_from_2019-09-12_15-36-06.png From the original on HackerOne

Patch

Don't check for the x-forwarded-for header, has it can be changed leading to IP whitelist bypass

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

The original report as published on HackerOne, by mik317. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Install the expressjs-ip-control module.
  2. Create a small Express app that protects a route with an IP whitelist.
  3. Run the app and request the route without any extra header to see the 403 response.
  4. 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.

More by mik317

View all

23 more disclosed reports, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.