Skip to content
Path traversal Disclosed report Beginner

Off-by-slash vulnerability in nodejs.org and iojs.org

The nginx configuration files for nodejs.org and iojs.org contained off-by-slash misconfigurations in location blocks, allowing an attacker to access files outside the intended directory. By requesting a path like /metrics../.bashrc, an attacker could read files in the /home/dist directory.

nagaro Follow

Originally disclosed on HackerOne

Bounty$1,200 Medium 5.3 View original
  • Triaged in 6 hours
  • Fixed in 29 hours
  • Paid in 29 hours
  • Disclosed after 43 hours

Summary by the program

Misconfiguration Report for Nodejs.org

The fix linked below is to correct a nginx off-by-slash misconfiguration. While Nodejs.org is not a standard in scope asset for IBB rewards for Node.js, the intent behind the Node.js bounty program is to reward vulnerabilities that could broadly impact users of the ecosystem, therefore the high level impact of this vulnerability warranted special attention.

Thank you to Nobuhiro Nagai from N.F.Laboratories for reporting this vulnerability.

Link to pull info: https://github.com/nodejs/build/pull/2993

The report

Original Report: https://hackerone.com/reports/1631350 The reason for submitting this report is written in the comment of the original report.


Summary: Configuration files for Nginx in nodejs/build repository have multiple off-by-slash misconfigurations. Because nodejs.org and iojs.org are deployed using those files, it is possible for an attacker to gain access to unexpected directories. (This report is not related to nodejs/node. Therefore, I understand that this report is not eligible to Bounty.)

Description: The following files have multiple off-by-slash misconfigurations.

For example, the following /metrics endpoint has no trailing slash, while the alias parameter has a trailing slash.

    location /metrics {
        alias /home/dist/metrics/;
        autoindex on;
        default_type text/plain;
    }

The setting as above is commonly known as an off-by-slash misconfiguration. In this case, an attacker can access files in /home/dist directory via /metrics../ endpoint.

Steps To Reproduce:

For example, you can browse the contents of /home/dist/.bashrc by accessing https://nodejs.org/metrics../.bashrc.

Impact:

If sensitive files exist in the dist user's home directory, it is possible for an attacker to view their contents.

Supporting Material/References:

Impact

An attacker can access files in the /home/dist directory of the nodejs.org and iojs.org servers.

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

nodejs.org and iojs.org are served by nginx, and the nginx configuration for those sites lives in the nodejs/build repository. Two files in that repository are the subject of this report:

  • https://github.com/nodejs/build/blob/main/ansible/www-standalone/resources/config/nodejs.org
  • https://github.com/nodejs/build/blob/main/ansible/www-standalone/resources/config/iojs.org

The researcher is explicit that the report concerns these configuration files and not the Node.js source code itself: "This report is not related to nodejs/node." The feature at issue is nginx's alias directive inside a location block, which maps a URL prefix onto a directory on disk.

Setup

No accounts, roles or special tooling are described. The only precondition is that the two configuration files above are the ones used to deploy nodejs.org and iojs.org, which the researcher states as the reason the misconfiguration is reachable in production. The reproduction is a plain browser request.

Finding it

The researcher reviewed the nginx configuration files in the build repository and found multiple off-by-slash misconfigurations. The pattern is a location prefix without a trailing slash combined with an alias value that has one. The report gives the /metrics block as the example:

Text
    location /metrics {
        alias /home/dist/metrics/;
        autoindex on;
        default_type text/plain;
    }

With this combination, a request whose path begins with /metrics but continues with something other than / is resolved by nginx against the alias target with the location prefix stripped. Because the alias ends in / and the location does not, the remainder of the request path is appended directly to /home/dist/metrics/, and a .. segment in that remainder walks up out of the intended directory. The researcher notes that this setting is commonly known as an off-by-slash misconfiguration, and that it lets an attacker reach files in the /home/dist directory through a /metrics../ path.

Exploitation

Step 1: request a file above the alias directory

The researcher gives the following URL as the reproduction:

HTTP
https://nodejs.org/metrics../.bashrc

The path starts with the /metrics location prefix, so nginx selects that block. The remainder after the prefix is ../.bashrc, which is appended to the alias /home/dist/metrics/, resolving to /home/dist/.bashrc. The report states that browsing this URL returns the contents of /home/dist/.bashrc. No response body or headers are reproduced in the report.

Root cause

The mistake is the mismatch between the location prefix and the alias value: the location is written without a trailing slash while the alias is written with one. nginx performs a textual substitution of the matched prefix with the alias path, so the unmatched remainder of the request path, including .. segments, is carried into the filesystem path. The autoindex on directive in the same block is not the cause, but it makes directory listings available where the path resolves to a directory. The report does not describe any other defence that was present or bypassed.

Impact

An attacker can access files in the /home/dist directory on the nodejs.org and iojs.org servers. The researcher hedges the severity on content: if sensitive files exist in the dist user's home directory, it is possible for an attacker to view their contents. The report does not enumerate which files were sensitive or what they contained beyond the .bashrc example.

The program's summary explains why it paid despite the asset not being a standard in-scope target for IBB rewards for Node.js: the intent of the Node.js bounty programme is to reward vulnerabilities that could broadly impact users of the ecosystem, so the high-level impact warranted special attention.

Fix

The program summary states that the fix corrects an nginx off-by-slash misconfiguration and links to the pull request:

Text
https://github.com/nodejs/build/pull/2993

The report does not describe the contents of that change. The general correction for this pattern is to make the location prefix and the alias value agree on the trailing slash, so that the remainder appended to the alias cannot begin with ...

Variants to test

  • Look for location blocks whose prefix lacks a trailing slash while the alias has one, as in the /metrics example. A positive result is a request such as /prefix../somefile returning content from the parent of the alias directory.
  • Check every location in the same configuration files, since the researcher reports multiple off-by-slash misconfigurations rather than a single one. A positive result is the same traversal behaviour on a different prefix.
  • Where autoindex on is set, request the prefix followed by ../ and look for a directory listing of the parent directory. A positive result is a directory listing of the parent directory.
  • Try reading well-known files in the parent directory, as the report does with .bashrc. A positive result is file content returned from the parent directory.

Hunting notes

This class of bug hides in deployment configuration rather than application code, so the productive places to look are public configuration repositories for the target: Ansible roles, container images and site configs that are committed alongside the application. The signal during recon is an nginx location and alias pair whose trailing slashes disagree, especially where the alias points into a home directory or another directory that holds more than the intended static content. The report shows impact with a single request that returns a file from outside the alias directory, which is enough to demonstrate the issue without further exploitation.

Disclosure

The program credits Nobuhiro Nagai from N.F.Laboratories for reporting the vulnerability.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

Two websites, nodejs.org and iojs.org, are the public faces of Node.js, a popular tool for running JavaScript outside a browser. Those sites are not served by hand: a web server program called nginx reads a configuration file and uses it to decide, for every incoming request, which file on the server's disk to send back.

The configuration files for these two sites are not secret. They are published in a public code repository called nodejs/build, which is where the people who run the Node.js project keep the scripts and settings used to deploy their infrastructure. Anyone, including a security researcher, can read them.

The researcher, Nobuhiro Nagai from N.F.Laboratories, read those files and spotted a small but meaningful mistake in how a particular folder was mapped to a web address. The mistake has a nickname: an off-by-slash misconfiguration. In plain terms, one line was written with a trailing slash (/) at the end and the line next to it was written without one, and that tiny difference lets a visitor step out of the folder the site intended to expose and into the folder above it.

Using nothing more than a browser, the researcher showed that a specially crafted web address returned the contents of a file called .bashrc from the home directory of the user that runs the site. That file sits outside the folder that was meant to be public.

The report is careful to say it is about the deployment configuration, not about the Node.js software itself: "This report is not related to nodejs/node." Even so, the bug bounty programme behind Node.js decided to pay a reward, because a problem on the project's own websites can affect the many people who rely on the ecosystem.

Context

What nginx is

nginx (pronounced "engine-x") is a web server. When your browser asks for a page, nginx is often the program that receives the request, works out which file on the server should answer it, and sends that file back. Think of it as a receptionist in a large building: you give a room name, and the receptionist looks up which corridor and door that name corresponds to.

nginx is configured with text files. Each file contains blocks of instructions. Two kinds of instruction matter here:

  • A location block tells nginx: "when a request's address starts with this piece of text, use the rules inside this block."
  • An alias instruction inside that block tells nginx: "the files for this address actually live in this folder on disk."

Where the configuration lives

nodejs.org and iojs.org are served by nginx, and the configuration for those sites lives in the nodejs/build repository. Two files in that repository are the subject of this report:

  • https://github.com/nodejs/build/blob/main/ansible/www-standalone/resources/config/nodejs.org
  • https://github.com/nodejs/build/blob/main/ansible/www-standalone/resources/config/iojs.org

A repository is a shared storage space for files, usually with a history of every change. Because these two files are public, the researcher did not need any special access to study them.

The researcher is explicit that the report concerns these configuration files and not the Node.js source code itself: "This report is not related to nodejs/node." The feature at issue is nginx's alias directive inside a location block, which maps a URL prefix onto a directory on disk.

Setup

No accounts, roles or special tooling are described. The only precondition is that the two configuration files above are the ones used to deploy nodejs.org and iojs.org, which the researcher states as the reason the misconfiguration is reachable in production. The reproduction is a plain browser request.

In other words, you do not need to install anything, log in anywhere, or write a program. You need a browser and the knowledge of which address to type.

Finding it

The researcher reviewed the nginx configuration files in the build repository and found multiple off-by-slash misconfigurations. The pattern is a location prefix without a trailing slash combined with an alias value that has one. The report gives the /metrics block as the example:

Text
    location /metrics {
        alias /home/dist/metrics/;
        autoindex on;
        default_type text/plain;
    }

Line by line:

  • location /metrics { opens a rule that applies to any request whose address begins with /metrics. Notice there is no slash after metrics.
  • alias /home/dist/metrics/; says that the files for this address are found in the folder /home/dist/metrics/ on the server's disk. Notice there is a slash at the end here.
  • autoindex on; tells nginx that if the address points at a folder rather than a file, it should show a list of what is in that folder, like the file listing you see in a computer's file manager.
  • default_type text/plain; says that files served from here should be labelled as plain text, so the browser displays them rather than trying to download or render them.
  • } closes the block.

With this combination, a request whose path begins with /metrics but continues with something other than / is resolved by nginx against the alias target with the location prefix stripped. Because the alias ends in / and the location does not, the remainder of the request path is appended directly to /home/dist/metrics/, and a .. segment in that remainder walks up out of the intended directory.

To unpack that: nginx works by text matching. It takes the part of the address that matched /metrics, removes it, and glues what is left onto the folder path. If the leftover text starts with .., and .. is the standard way of writing "the folder above this one" on a computer, then the final path points one level higher than intended. The researcher notes that this setting is commonly known as an off-by-slash misconfiguration, and that it lets an attacker reach files in the /home/dist directory through a /metrics../ path.

Exploitation

Step 1: request a file above the alias directory

The researcher gives the following URL as the reproduction:

HTTP
https://nodejs.org/metrics../.bashrc

Breaking this address down:

  • https:// is the normal secure web protocol, the same one your browser uses for online banking.
  • nodejs.org is the site being asked.
  • /metrics../.bashrc is the path, the part that tells nginx which file is wanted.

The path starts with the /metrics location prefix, so nginx selects that block. The remainder after the prefix is ../.bashrc, which is appended to the alias /home/dist/metrics/, resolving to /home/dist/.bashrc. The report states that browsing this URL returns the contents of /home/dist/.bashrc. No response body or headers are reproduced in the report.

Why this works, in everyday terms: imagine a building where the receptionist is told "anything starting with the word 'metrics' goes to room 12". You say "metrics, go back one room, then open the file called .bashrc". The receptionist hears the word "metrics", follows the rule, and then obediently walks back one room, ending up somewhere the rule never intended to send you.

.bashrc is a small settings file that a Linux user account keeps in its home folder; it is read automatically when that user opens a terminal. It is not normally something a website visitor should be able to read.

Root cause

The mistake is the mismatch between the location prefix and the alias value: the location is written without a trailing slash while the alias is written with one. nginx performs a textual substitution of the matched prefix with the alias path, so the unmatched remainder of the request path, including .. segments, is carried into the filesystem path. The autoindex on directive in the same block is not the cause, but it makes directory listings available where the path resolves to a directory. The report does not describe any other defence that was present or bypassed.

A useful comparison: if a postal clerk is told "any letter addressed to 'Park Street' goes to the Park Street depot", and someone writes "Park Street, then turn around and go to the depot behind it", the clerk follows the words literally. The rule was never designed to handle the extra instruction. The fix is to write the rule so precisely that no extra instruction can slip through.

Impact

An attacker can access files in the /home/dist directory on the nodejs.org and iojs.org servers. The researcher hedges the severity on content: if sensitive files exist in the dist user's home directory, it is possible for an attacker to view their contents. The report does not enumerate which files were sensitive or what they contained beyond the .bashrc example.

In other words, the bug does not by itself hand over a password or a database. It opens a door to a folder, and how much that matters depends on what is in the folder. The researcher demonstrated one file to prove the door opens.

The program's summary explains why it paid despite the asset not being a standard in-scope target for IBB rewards for Node.js: the intent of the Node.js bounty programme is to reward vulnerabilities that could broadly impact users of the ecosystem, so the high-level impact warranted special attention.

A bug bounty programme is a scheme where organisations pay people who find and report security problems responsibly. "In scope" means the rules say that particular target is eligible for a reward. Here the configuration repository was not a standard in-scope target, but the programme made an exception because the websites belong to the project and a problem there could affect its users.

Fix

The program summary states that the fix corrects an nginx off-by-slash misconfiguration and links to the pull request:

Text
https://github.com/nodejs/build/pull/2993

A pull request is a proposed change to files in a repository, which other people can review before it is accepted. The report does not describe the contents of that change. The general correction for this pattern is to make the location prefix and the alias value agree on the trailing slash, so that the remainder appended to the alias cannot begin with ...

Variants to test

If you were looking for this kind of mistake yourself, here is how the researcher's approach generalises. Each item below is a thing to try and a sign that it worked.

  • Look for location blocks whose prefix lacks a trailing slash while the alias has one, as in the /metrics example. A positive result is a request such as /prefix../somefile returning content from the parent of the alias directory.
  • Check every location in the same configuration files, since the researcher reports multiple off-by-slash misconfigurations rather than a single one. A positive result is the same traversal behaviour on a different prefix.
  • Where autoindex on is set, request the prefix followed by ../ and look for a directory listing of the parent directory. A positive result is a directory listing of the parent directory.
  • Try reading well-known files in the parent directory, as the report does with .bashrc. A positive result is file content returned from the parent directory.

A 403 response means "forbidden", and a 404 means "not found". Seeing a list of files or the contents of a file instead of one of those errors is the signal that the door opened.

Hunting notes

This class of bug hides in deployment configuration rather than application code, so the productive places to look are public configuration repositories for the target: Ansible roles, container images and site configs that are committed alongside the application. The signal during recon is an nginx location and alias pair whose trailing slashes disagree, especially where the alias points into a home directory or another directory that holds more than the intended static content. The report shows impact with a single request that returns a file from outside the alias directory, which is enough to demonstrate the issue without further exploitation.

Ansible is a tool for automating server setup, and its roles are bundles of instructions for configuring machines. Recon, short for reconnaissance, is the early stage of a security review where you gather information about a target before trying anything. Container images are packaged snapshots of a program and everything it needs to run. All of these can accidentally publish the same kind of configuration detail the researcher found here.

Disclosure

The program credits Nobuhiro Nagai from N.F.Laboratories for reporting the vulnerability.

Glossary

  • nginx: A web server program that receives browser requests and sends back the matching files, guided by configuration files.
  • Configuration file: A text file of settings that tells a program how to behave.
  • location block: An nginx rule that applies to requests whose address begins with a given piece of text.
  • alias directive: An nginx instruction that maps a web address prefix to a folder on the server's disk.
  • autoindex on: An nginx setting that shows a list of files when the address points at a folder.
  • default_type text/plain: An nginx setting that labels served files as plain text so the browser displays them.
  • Off-by-slash misconfiguration: A mistake where a location prefix and an alias value disagree about a trailing slash, letting a request escape the intended folder.
  • Path traversal: A class of bug where crafted input containing .. makes a program read files outside the folder it was meant to use.
  • ..: The standard way of writing "the folder above this one" in a file path.
  • .bashrc: A settings file in a Linux user's home folder, read when that user opens a terminal.
  • Home directory: The personal folder belonging to a user account on a server.
  • Repository: A shared storage space for files, usually keeping a history of changes.
  • Pull request: A proposed change to files in a repository, reviewed by others before acceptance.
  • Bug bounty programme: A scheme where organisations pay people who responsibly report security problems.
  • In scope: A target that the rules of a bug bounty programme say is eligible for a reward.
  • CVSS score: A standard numeric rating of how severe a vulnerability is; 5.3 is in the medium range.
  • Medium severity: A severity band between low and high, indicating a real but limited problem.
  • Ansible: A tool for automating server setup; its roles are bundles of configuration instructions.
  • Container image: A packaged snapshot of a program and everything it needs to run.
  • Recon: The information-gathering stage of a security review, done before attempting anything.
  • 403 / 404: Standard web responses meaning "forbidden" and "not found" respectively.
  • 200 response: The standard web response meaning the request succeeded and content is being returned.
  • Disclosure: The point at which a reported vulnerability is made public.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.