Skip to content
Open redirect Disclosed report Beginner CVE-2018-3743

[hekto] open redirect when target domain name is used as html filename on server

The hekto module redirects requests for extensionless HTML files by appending a slash to the request URL. When the request path begins with two slashes, the redirect Location header becomes a protocol-relative URL pointing to an external domain, enabling an open redirect.

brainpanic Follow

Originally disclosed on HackerOne

  • Triaged in 43 days
  • Fixed in 3 months
  • Disclosed after 3 months

Hi,

There is an open redirect in hekto when target domain name is used as html filename on server.

Module

module name: hekto version: 0.2.3 npm page: https://www.npmjs.com/package/hekto

Module Description

This package exposes a directory and its children to create, read, update, and delete operations over http.

Module Stats

[0] downloads in the last day [21] downloads in the last week [216] downloads in the last month

~[2600] estimated downloads per year

Vulnerability

Vulnerability Description

When processing extensionless html, hekto launches a redirection.

//https://github.com/herber/hekto/blob/master/bin/hekto.js#L184
      // Add trailing slash for extensionless html.
      if (fs.existsSync(file + '.html') && fs.lstatSync(file + '.html').isFile()) {
        this.status = 307;
        this.redirect(this.request.url + '/' + query);

        return ;
      }

For example, if there is a file named "hackerone.com.html" in document root dir, accessing http://<server>/hackerone.com will leads to a redirection to http://<server>/hackerone.com/.

But when accessing http://<server>//hackerone.com, the server would redirect ro //hackerone.com.

Steps To Reproduce:

  1. install hekto module

$ npm install hekto

  1. create a file named hackerone.com.html

$ touch hackerone.com.html

  1. run server from command line

$ ./node_modules/hekto/bin/hekto.js serve

  1. test redirection
$ curl -i http://127.0.0.1:3000//hackerone.com
HTTP/1.1 307 Temporary Redirect
Vary: Accept-Encoding
X-Powered-By: Hekto
Location: //hackerone.com/
Content-Type: text/html; charset=utf-8
Content-Length: 63
Date: Wed, 28 Feb 2018 08:22:31 GMT
Connection: keep-alive

Redirecting to <a href="//hackerone.com/">//hackerone.com/</a>.

Supporting Material/References:

State all technical information about the stack where the vulnerability was found

  • macOS 10.13.3
  • Node.js v9.6.1
  • npm 5.6.0
  • curl 7.54.0

Wrap up

  • I contacted the maintainer to let him know: [N]
  • I opened an issue in the related repository: [N]

Impact

This vulnerability can be used to phishing attacks

The original report as published on HackerOne, by brainpanic. 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 redirect location is built by concatenating the raw request URL with a slash, without validating that the resulting path is relative to the current host, so a leading double slash turns it into a protocol-relative external URL.

Impact

This vulnerability can be used in phishing attacks.

What the attacker needed

Hekto server running; a file named after the target domain exists

How it was found

  1. Install the hekto module.
  2. Create a file named after a target domain with an .html extension in the document root.
  3. Start the hekto server from the command line.
  4. Request the path with two leading slashes followed by the domain name and observe the redirect to that domain.

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.

An open redirect is when a website sends you to another site based on something you put in the link. Here, if a file named after a domain exists, a request with two slashes at the start makes the server redirect to that domain instead of staying on the same site. Attackers can use this to make phishing links look like they belong to the trusted site.

What is Open redirect?

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.

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.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.