[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.
- 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:
/[`$&{}[;|]/g.test(command)
Steps To Reproduce:
-
Run
npm i curling -
Create and run the following POC index.js:
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
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
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
- Install the curling module.
- Create and run a proof-of-concept script that calls curling.run with a crafted command.
- 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.