Skip to main content
Mallory
HighCISA KEVExploited in the wildPublic exploit

Ghostscript -dSAFER Bypass and Remote Command Execution via .rsdparams Type Confusion

IdentifiersCVE-2017-8291CWE-843· Access of Resource Using…

CVE-2017-8291 is a vulnerability in Artifex Ghostscript, affecting versions through 2017-04-26, in which the -dSAFER sandbox can be bypassed via type confusion involving .rsdparams. A crafted PostScript/EPS document containing a "/OutputFile (%pipe%" substring can cause Ghostscript to treat attacker-controlled data in a way that defeats the intended safety restrictions and permits command execution. The issue is particularly relevant when Ghostscript is invoked to process untrusted EPS input, including indirectly through applications that render or preview EPS content. The provided context notes exploitation in the wild in April 2017 and specifically references use against the Hangul word processor, where opening a malicious attachment triggered exploitation and shellcode execution.

Share:
For your environment

Are you exposed to this one?

Mallory correlates every CVE against your assets, your vendors, and active adversary campaigns. Know which vulnerabilities matter for you, not just which ones are loud.

ANALYST BRIEF

Impact, mitigation & remediation

What it means. What to do now. Patch path, mitigations, and the assume-compromise checklist.

Impact

What an attacker gets, and what they’ve been doing with it.

Successful exploitation allows bypass of Ghostscript's -dSAFER protection and leads to remote command execution on the host processing the malicious EPS/PostScript content. In practical terms, this enables arbitrary command execution in the security context of the Ghostscript process or the calling application, which can be used to stage additional payloads, establish persistence, and conduct follow-on compromise. The supplied context indicates the vulnerability was used in phishing campaigns to execute shellcode and deploy malware.

Mitigation

If you can’t patch tonight, do this now.

Do not process untrusted EPS/PostScript documents with vulnerable Ghostscript versions. Disable or restrict EPS/PostScript rendering and conversion where not required, especially in desktop document viewers, print pipelines, and server-side document processing services. Where possible, sandbox Ghostscript execution at the OS or container level, block dangerous interpreter features, and filter or quarantine inbound documents containing EPS content from untrusted sources. In environments such as Hangul or other document handlers that may invoke Ghostscript indirectly, disable automatic rendering/preview of embedded EPS content until patched.

Remediation

Patch, then assume compromise.

Upgrade Artifex Ghostscript to a version containing the fix for CVE-2017-8291. Any software bundle or downstream application embedding or invoking a vulnerable Ghostscript build should also be updated, including document-processing workflows that handle EPS/PostScript content. If a vendor application statically bundles Ghostscript or relies on an affected external installation, remediation requires updating that bundled or dependent component as well.
PUBLIC EXPLOITS

Exploits

4 valid exploits after Mallory filtered fakes, detection scripts, and README-only repos.

VALID 4 / 4 TOTALView more in app
PIL-CVE-2017-8291MaturityPoCVerified exploit

This repository provides a proof-of-concept (POC) exploit for the GhostButt vulnerability (CVE-2017-8291) affecting Python's PIL/Pillow library when used with GhostScript. The repository contains a simple Flask web application (app.py) that allows users to upload PNG files, which are then processed using PIL. The vulnerability arises because PIL determines file type based on file headers, not extensions, and passes EPS files to GhostScript for processing. The included poc.png is actually a malicious EPS file disguised as a PNG, containing PostScript code that exploits the GhostScript sandbox bypass to execute arbitrary commands on the server (demonstrated by creating /tmp/aaaaa). The Dockerfile and docker-compose.yml facilitate easy setup of the vulnerable environment. The README files provide detailed background, exploitation steps, and references. The main attack vector is via network (HTTP file upload), and the exploit demonstrates arbitrary command execution on the server. The repository is a clear, functional POC for CVE-2017-8291, targeting Python web applications using PIL/Pillow and GhostScript.

DaniilOrchikovDisclosed Dec 3, 2025pythondockerfilenetwork
PIL-CVE-2017-8291MaturityPoCVerified exploit

This repository demonstrates a remote command execution exploit targeting Python web applications that use the PIL/Pillow library with Ghostscript for image processing. The main application (app.py) is a Flask web server that allows users to upload images, which are then processed using PIL. If a user uploads a specially crafted EPS file (disguised as a PNG), Ghostscript is invoked by PIL to process the file. Due to vulnerabilities in Ghostscript (CVE-2017-8291 and CVE-2018-16509), the '-dSAFER' sandbox can be bypassed, allowing arbitrary shell commands to be executed on the server. The repository includes proof-of-concept EPS files (poc.png, poc_ctf.png) that demonstrate file creation and reverse shell payloads. The attack vector is network-based, exploiting the web upload endpoint at http://localhost:8000. The exploit is operational, providing real command execution on vulnerable systems. The repository is structured with a main Python application, documentation, Docker configuration for easy setup, and example payloads.

hkcfsDisclosed Jun 13, 2025pythonnetwork
CVE-2017-8291MaturityPoCVerified exploit

This repository demonstrates a proof-of-concept exploit for CVE-2017-8291, a remote command execution vulnerability affecting Python's PIL/Pillow library when used in conjunction with a vulnerable version of GhostScript (<=9.21). The repository contains a simple Flask web application (app.py) that allows users to upload PNG images, which are then processed using PIL. Due to the way PIL determines image type by file header, an attacker can upload a malicious EPS file disguised as a PNG. When processed, GhostScript executes embedded PostScript code, bypassing the '-dSAFER' sandbox and allowing arbitrary command execution. The provided POC (poc.png) creates a file '/tmp/aaaaa' on the server, but this can be modified to execute any command, including spawning a reverse shell. The repository includes setup instructions using Docker, a detailed README in both English and Chinese, and a sample exploit file. The main attack vector is via the web application's file upload endpoint, and exploitation requires the backend to process user-supplied images with PIL and GhostScript.

shun1403Disclosed Apr 27, 2025pythonyamlnetwork
PIL-CVE-2017-8291-studyMaturityPoCVerified exploit

This repository demonstrates a proof-of-concept (POC) exploit for CVE-2017-8291, a remote code execution vulnerability in the Python Imaging Library (PIL) when used with GhostScript. The exploit leverages the fact that PIL determines image type based on file headers, not extensions, allowing an attacker to upload a malicious EPS file disguised as a PNG. When the server processes this file (using GhostScript), arbitrary shell commands embedded in the EPS are executed. The repository includes a Flask web application (app.py) that accepts PNG uploads, a docker-compose.yml for environment setup, and a crafted poc.png file that, when uploaded, causes the server to create a file at /tmp/aaaaa, demonstrating code execution. The README provides detailed setup and exploitation instructions. The main attack vector is via HTTP file upload to the web interface at http://localhost:8000/. The exploit is a POC but can be weaponized by modifying the payload to execute more impactful commands, such as spawning a reverse shell.

shun1403Disclosed Apr 27, 2025pythonyamlnetwork
EXPOSURE SURFACE

Affected products & vendors

Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.

VendorProductType
Artifex SoftwareGhostscriptapplication
DebianDebian Linuxoperating_system
Red HatEnterprise Linux Desktopoperating_system
Red HatEnterprise Linux Eusoperating_system
Red HatEnterprise Linux Serveroperating_system
Red HatEnterprise Linux Server Ausoperating_system
Red HatEnterprise Linux Server Tusoperating_system
Red HatEnterprise Linux Workstationoperating_system

Vendor-confirmed product mapping. Mallory continuously reconciles this list against your asset inventory.

What this page doesn’t show

The version that knows your environment.

This page is what’s public. Mallory adds the parts that aren’t: which of your assets are affected, which adversaries are exploiting it right now, which detections to deploy, and what to do tonight.
Exposure mapping

Query your assets running an affected version, and investigate the blast radius.

Threat actor evidence1

Every observed campaign linking this CVE to a named adversary.

Associated malware1

Malware families riding this exploit, with evidence and IOCs.

Detection signatures2

YARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.

Vendor-by-vendor mapping

Cross-references every affected SKU, including bundled OEM variants.

Social activity

Community discussion across Reddit, Mastodon, and other social sources.