Skip to content
RCE Disclosed report Beginner

[imagickal] Remote Code Execution

The imagickal npm module passed user-supplied input into ImageMagick shell commands without sanitisation, so a crafted filename could inject extra shell commands. An attacker who controls the input could run arbitrary commands on the victim's machine.

solov9ev Follow

Originally disclosed on HackerOne

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

I would like to report RCE in imagickal It allows to execute arbitrary commands on the victim's PC

Module

module name: imagickal version: 4.2.0 npm page: https://www.npmjs.com/package/imagickal

Module Description

node wrapper for ImageMagick commands

Module Stats

[42] weekly downloads

Vulnerability

Vulnerability Description

Code injection while processing a photo

Steps To Reproduce:

  • Run npm i imagickal
  • Create and run the following POC index.js:
JavaScript
var im = require('imagickal');

im.identify('image.jpg;touch HACKED;').then(function (data) {
  console.log(data);
});
  • The exploit worked and created the file - HACKED
imagickal_rce.mp4 From the original on HackerOne

Patch

Check input before command

Wrap up

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

Impact

Command Injection on imagickal 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 module concatenated user input into a shell command string without escaping or validation, allowing shell metacharacters to break out of the intended command.

Impact

An attacker could execute arbitrary commands on the victim's PC when a crafted filename is processed.

What the attacker needed

Victim processes attacker-supplied filename

How it was found

  1. Install the imagickal package with npm.
  2. Write a small script that calls the identify function with a crafted filename.
  3. Run the script and observe that an extra file was created.

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 module is a small helper that runs the ImageMagick program to inspect photos. It built a command line by gluing the filename straight into it, so a filename containing shell punctuation could add a second command. That let the author of the filename run their own programs on the computer doing the processing.

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.