Skip to content
RCE Disclosed report Intermediate

[curling] Remote Code Execution

The curling npm module used an insufficient regular expression to block dangerous characters before passing a command to curl, allowing an attacker to inject curl options. An attacker could read or overwrite arbitrary files on the host.

solov9ev Follow

Originally disclosed on HackerOne

Critical View original
  • Fixed in 3 months
  • Disclosed after 4 months

I would like to report RCE in curling I can bypass the security check for special characters, read / overwrite file

Module

module name: curling version: 1.1.0 npm page: https://www.npmjs.com/package/curling

Module Description

A node wrapper for curl with a very simple api.

Module Stats

[156] weekly downloads

Vulnerability

Vulnerability Description

The regular expression does not perform proper validation and, when combined with curl, leads to disastrous consequences:

JavaScript
/[`$&{}[;|]/g.test(command)

Steps To Reproduce:

  • Run npm i curling

  • Create and run the following POC index.js:

JavaScript
const curling = require('curling');

curling.run('file:///etc/passwd -o ./index.js', function(d, payload){console.log(payload)});
  • The exploit worked and overwritten the file - index.js
curling_rce.mp4 From the original on HackerOne

Patch

Regular expression needs improvement

Wrap up

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

Impact

Command Injection on curling module via insecure command

The original report as published on HackerOne, by solov9ev. 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

Likely the regular expression used to filter dangerous characters was incomplete, so curl options could be injected into the command.

Impact

An attacker could read or overwrite arbitrary files on the host through command injection.

What the attacker needed

Ability to control the command string passed to curling.run

The fix

The regular expression should be improved to properly validate input.

How it was found

  1. Install the curling module.
  2. Create and run a proof-of-concept script that calls curling.run with a crafted command.
  3. Observe that the exploit worked and overwrote the index.js file.

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.

This is a command injection bug. The module tried to stop dangerous characters with a simple pattern check, but missed some, so a user-supplied string could add extra curl instructions. That let an attacker make curl read a system file and write it over another file.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by solov9ev

View all

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

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.