Security Experts:

Connect with us

Hi, what are you looking for?



Data Leak in Ghostscript Could Allow Command Execution

Data leak vulnerabilities in Ghostscript could allow an attacker to take over a routine and even execute commands on systems, Google Project Zero researcher Tavis Ormandy has discovered. 

Data leak vulnerabilities in Ghostscript could allow an attacker to take over a routine and even execute commands on systems, Google Project Zero researcher Tavis Ormandy has discovered. 

A suite of software based on an interpreter for Adobe’s PostScript and PDF page description languages, Ghostscript is maintained by Artifex and is widely used in both stand-alone and web applications, including highly popular packages such as GIMP and ImageMagick.

The software is not vulnerability-free, and some of the security bugs found in it were previously exploited by North Korea-linked hackers. Last year, Ormandy revealed that multiple critical vulnerabilities in Ghostscript also impacted ImageMagick, Evince, GIMP, and most other PDF/PS tools.

In December 2018, a month after Ghostscript 9.26 was released, the security researcher discovered that Ghostscript didn’t protect subroutines correctly, which could result in data leaks and in an attacker taking over the routine. 

The researcher explains that the manner in which subroutines are defined in PostScript could allow users to “peek inside and get references to operators they shouldn’t be allowed to use” if subroutines are not marked as executeonly when using system operators.

Furthermore, he notes that, even if subroutines are properly marked, they could still expose the contents to error handlers, meaning that they need to be made pseudo-operators with odef. 

On top of that, contents need to be bind, otherwise “name resolution happens on execution, not when you define it,” allowing an intruder to change the dictstack “so that commands and operators do something different than when you defined the subroutine.”

However, it’s not only simple routines that need to be marked executeonly, made pseudo-operators with odef, and bind to be protected, but the more complicated ephemeral routines as well, and Ghostscript failed to apply the proper protections to some ephemeral routines, Ormandy discovered. 

The researcher also published proof-of-concept code that works with Ghostscript 9.26 and which allows the user to take over names that couldn’t be resolved at define time, thus providing a high degree of control over the routine. 

“This exploit should work via evince, ImageMagick, nautilus, less, gimp, gv, etc, etc. It might require some adjustment to work on older versions, because it requires precise alignment of the operand stack, but 9.26 and earlier are all affected,” Ormandy says. 

The researcher reported the discovery to Artifex in early December. After a series of failed fixes, the maintainers managed to address the bugs with patches released earlier this month. The vulnerability is tracked as CVE-2019-6116

The fix replaces references to operators with name objects in saved stacks for error handlers; makes all ephemeral procedures that contain dangerous operators executeonly, and any outer procedures; changes how error handlers behave in executeonly procedures so that faulting operators don’t leak; rewrites code so fewer pseudo-operators are exposed to users.

“I think this will work, although it’s hard to be confident they found all the transient routines – PostScript is really hard to read,” Ormandy says. 

Related: Unpatched Ghostscript Vulnerabilities Impact Popular Software

Related: North Korean Hackers Prep Attacks Against Cryptocurrency Exchanges: Report

Written By

Ionut Arghire is an international correspondent for SecurityWeek.

Click to comment

Expert Insights

Related Content

Cloud Security

VMware vRealize Log Insight vulnerability allows an unauthenticated attacker to take full control of a target system.

IoT Security

Lexmark warns of a remote code execution (RCE) vulnerability impacting over 120 printer models, for which PoC code has been published.

Mobile & Wireless

Apple rolled out iOS 16.3 and macOS Ventura 13.2 to cover serious security vulnerabilities.

Email Security

Microsoft is urging customers to install the latest Exchange Server updates and harden their environments to prevent malicious attacks.

Mobile & Wireless

Technical details published for an Arm Mali GPU flaw leading to arbitrary kernel code execution and root on Pixel 6.


Security researchers have observed an uptick in attacks targeting CVE-2021-35394, an RCE vulnerability in Realtek Jungle SDK.


Google has awarded more than $25,000 to the researchers who reported the vulnerabilities patched with the release of the latest Chrome update.

Application Security

Drupal released updates that resolve four vulnerabilities in Drupal core and three plugins.