Skip to content
RCE Disclosed report Intermediate CVE-2018-3757

Command injection in 'pdf-image'

The pdf-image npm module fails to validate user input when constructing a shell command, allowing an attacker to inject commands that run on the server.

defmax Follow

Originally disclosed on HackerOne

Medium 6.1 View original
  • Triaged in 4 days
  • Fixed in 41 days
  • Disclosed after 41 days

I would like to report command injection in pdf-image It allows executing commands on the server

Module

module name: pdf-image version: 1.0.5 npm page: https://www.npmjs.com/package/pdf-image

Module Description

Provides an interface to convert PDF's pages to png files in Node.js by using ImageMagick.

Module Stats

[2013] downloads in the last week

Vulnerability

Vulnerability Description

Description about how the vulnerability was found and how it can be exploited, how it harms package users (data modification/lost, system access, other.

Steps To Reproduce:

The constructGetInfoCommand would be initializing the command that is to the passed to 'exec' of getInfo(). The user input is not getting validated in #L26 of constructGetInfoCommand and it leads to command injection in #L43.

https://github.com/mooz/node-pdf-image/blob/master/index.js#L26 https://github.com/mooz/node-pdf-image/blob/master/index.js#L43## Patch

Supporting Material/References:

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

  • Kali linux
  • Nodejs v8.10.0
  • Npm v5.8.0

Wrap up

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

Impact

An attacker could execute arbitrary shell commands

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

Impact

An attacker could execute arbitrary shell commands on the server.

What the attacker needed

Victim uses pdf-image with user input

How it was found

  1. Pass malicious input to the pdf-image module that is used in constructGetInfoCommand.
  2. The input is not validated and is included in the command executed by getInfo().
  3. The injected command runs on the server.

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 package builds a command to run ImageMagick. Because it puts user input directly into that command without checking it, someone can sneak in extra commands that the server will run.

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 defmax

View all

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