Skip to content
RCE Advisory Intermediate CVE-2018-3836

Leptonica gplotMakeOutput Command Injection Vulnerability

The gplotMakeOutput function in Leptonica 1.74.4 builds a shell command from an unsanitised rootname argument and passes it to system(), allowing an attacker who controls that argument to inject and execute arbitrary commands.

Marcin 'Icewall' Noga Follow

Originally disclosed on Cisco Talos

High 7.0 View original

An exploitable command injection vulnerability exists in the gplotMakeOutput function of Leptonica 1.74.4. A specially crafted gplot rootname argument can cause a command injection resulting in arbitrary code execution.

Marcin 'Icewall' Noga, on Cisco Talos

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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 rootname argument is copied into gplot->cmdname without sanitisation and later concatenated into a shell command passed to system().

Impact

An attacker could execute arbitrary commands with the privileges of the application that calls the vulnerable function.

What the attacker needed

Attacker controls the rootname argument; application calls gplotMakeOutput

The fix

The rootname argument should be sanitised to remove shell metacharacters before being used in a command, or the command should be executed without a shell.

How it was found

  1. Create a GPLOT object with gplotCreate, supplying a rootname that contains shell metacharacters.
  2. Call gplotMakeOutput on that object.
  3. The function builds a command string including the unsanitised rootname and executes it with system().

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.

Leptonica is a library for image processing. When it creates a plot, it runs an external program called gnuplot using a system command. The name of the plot file is inserted into that command without cleaning, so if an attacker can choose the name, they can add extra shell commands that the computer 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 Marcin 'Icewall' Noga

View all

146 more disclosed reports, best first.

More from Cisco Talos

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.