Skip to content
Path traversal Disclosed report Beginner

[domokeeper] Unintended Require

The domokeeper server passes a user-supplied path directly to require() without sanitisation, allowing an attacker to load arbitrary modules or read JSON files. This can lead to unintended code execution or information disclosure.

ermilov Follow

Originally disclosed on HackerOne

Medium 5.9 View original
  • Triaged in 24 days
  • Fixed in 3 months
  • Disclosed after 3 months

I would like to report Unintended Require vulnerability in domokeeper It allows reading arbitary json files and load non-production code.

Module

module name: domokeeper version: 0.2.0 npm page: https://www.npmjs.com/package/domokeeper

Module Description

domokeeper server: a pluggable domotic control server for Raspberry Pi 2/3

Module Stats

[24] downloads in the last day [45] downloads in the last week [72] downloads in the last month

Vulnerability

Vulnerability Description

domokeeper is an express server which dynamically loads (with help of require()) some parts of the code. As long as the path to required module is passed in a HTTP request without any sanitization, anybody can cause code to load that was not intended to run on the server.

source code example:

index.js line 83

app.get('/plugins/:id', function (req, res) {
  var plugin = require(req.params.id);
  res.json(plugin);
})

In addition, the fact that output of the module is passed to server response directly (in the example above) leads to an information leakage. For example it is possible to read package.json file or any other json file.

Detailed description of this bug can be found here: https://nodesecroadmap.fyi/chapter-1/threat-UIR.html

Steps To Reproduce:

  • install domokeeper
npm i domokeeper
  • run it
node node_modules/domokeeper/bin.js
  • by default it starts at localhost:43569, so by navigating to http://localhost:43569/plugins/.%2Fpackage.json in the browser you are able to read the output of package.json file

Patch

Supporting Material/References:

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

  • OS: Linux Mint current
  • Node.js: 8.15.0
  • NPM:6.4.0

Wrap up

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

Impact

An attacker is able to control the x in require(x) and cause code to load that was not intended to run on the server or read json files.

The original report as published on HackerOne, by ermilov. 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 application uses the require() function with an unsanitised user-controlled path from the HTTP request.

Impact

An attacker could load non-production code or read arbitrary JSON files, potentially leading to code execution or information leakage.

What the attacker needed

Domokeeper server running

How it was found

  1. Install the domokeeper package.
  2. Run the server using its bin script.
  3. Navigate to the plugins endpoint with a path that points to package.json.

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.

The server takes part of the web address and uses it to load a file or piece of code. Because it does not check what is supplied, someone can ask it to load files it should not, like configuration files, or even run code that was not meant to run.

What is Path traversal?

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

More by ermilov

View all

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

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.