Skip to main content
Mallory
HighExploited in the wildCISA KEVPublic exploitVulnerability

CVE-2017-8291: Ghostscript .rsdparams Type Confusion and SAFER Bypass

Published Apr 27, 2017 · Updated 1 month ago
Trending this weekNot trendingOutside this week’s top 100
Mention activity · 30 daysNo mention activity in the last 30 days.
CVSS7.8High · v3.1
EPSS97.0%100th percentile
CISA KEVYesAdded May 24, 2022
In the wildActivePer CISA KEV
Vendors
Debian ProjectRed HatArtifex Software
IdentifiersCVE-2017-8291CWE-843 · Access of Resource Using…

CVE-2017-8291 is a type-confusion vulnerability in the .rsdparams operator of Artifex Ghostscript affecting versions through April 26, 2017. Processing a specially crafted Encapsulated PostScript (EPS) document can bypass the -dSAFER restriction and execute attacker-controlled commands. The vulnerability also affects applications that process EPS through a vulnerable Ghostscript component, including older versions of Hangul Word Processor. Exploitation was observed in the wild in April 2017 and subsequently in malicious-document campaigns.

Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Analyst brief

Impact, mitigation & remediation

What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.

Impact

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

Successful exploitation bypasses Ghostscript's SAFER security restrictions and permits attacker-controlled command or code execution on the system processing the document. Observed attacks used embedded EPS objects in Hangul documents to execute shellcode and download additional malware, including CRAT and M2RAT.

Mitigation

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

Disable EPS processing or remove the Ghostscript-based EPS-processing module from affected document applications where feasible. Do not process untrusted EPS documents or open untrusted Hangul attachments with vulnerable software. The -dSAFER option alone does not prevent exploitation because the vulnerability bypasses that restriction.

Remediation

Patch, then assume compromise.

Apply vendor updates that correct CVE-2017-8291 in Ghostscript, including any Ghostscript component bundled with document-processing applications. Update affected Hangul Word Processor installations to versions that no longer include the vulnerable EPS-processing module. A specific fixed Ghostscript release is not identified in the available information; referenced distribution advisories include Debian DSA-3838, Red Hat RHSA-2017:1230, and Gentoo GLSA-201708-06.

Public exploits

Exploits

5 exploits validated by Mallory's analysis.

View more in app →
ghostscript_type_confusion.rbThis repository contains a single Metasploit module targeting a type confusion vulnerability in Ghostscript (CVE-2017-8291). The exploit is weaponized and generates a malicious EPS file (default: msf.eps) that, when processed by a vulnerable Ghostscript instance (version 9.21 or earlier), results in arbitrary command execution. The vulnerability can be triggered directly or via libraries such as ImageMagick or Pillow, making it relevant for server-side image processing scenarios. The module allows the user to specify a payload command, which is embedded into the EPS template. The structure is typical for a Metasploit file format exploit, with the main logic in the 'exploit' method, which creates the malicious file. The only endpoints present are the generated EPS file and an example output file path (/dev/null) used in demonstration commands.Disclosed Apr 27, 2017 · Framework: metasploit · ruby · fileformatWeaponizedPIL-CVE-2017-8291This 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.hkcfs · Disclosed Jun 13, 2025 · python · networkOperationalCVE-2017-8291This 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.shun1403 · Disclosed Apr 27, 2025 · python · yaml · networkPoCPIL-CVE-2017-8291-studyThis 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.shun1403 · Disclosed Apr 27, 2025 · python · yaml · networkPoCPIL-CVE-2017-8291This 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.DaniilOrchikov · Disclosed Dec 3, 2025 · python · dockerfile · networkPoC
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
Debian ProjectDebian 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
FAQ

Frequently asked questions

Is CVE-2017-8291 exploited in the wild?
Yes. As of Oct 16, 2026, Mallory has reports of exploitation in the wild, and CISA added it to KEV on May 24, 2022.
Is there a public exploit for CVE-2017-8291?
Yes. Mallory tracks 5 public exploits or proofs of concept for CVE-2017-8291, the earliest disclosed Apr 27, 2017.
Is there a patch for CVE-2017-8291?
Apply vendor updates that correct CVE-2017-8291 in Ghostscript, including any Ghostscript component bundled with document-processing applications. Update affected Hangul Word Processor installations to versions that no longer include the vulnerable EPS-processing module.
What products are affected by CVE-2017-8291?
Artifex Software Ghostscript, Debian Project Debian Linux, Red Hat Enterprise Linux Desktop, Red Hat Enterprise Linux Eus, Red Hat Enterprise Linux Server, and 3 more.
How severe is CVE-2017-8291?
CVE-2017-8291 has a CVSS v3.1 score of 7.8 (High) and an EPSS score of 97.0% (100th percentile) as of Oct 16, 2026.
Mallory platform

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, and which detections to deploy tonight.
Exposure mappingQuery your assets running an affected version, and investigate the blast radius.
Threat actor evidence6Every report linking this CVE to a named adversary.
Associated malware16Malware families linked to this CVE, with evidence and IOCs.
Detection signatures2YARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Vendor-by-vendor mappingCross-references every affected SKU, including bundled OEM variants.
Social activityCommunity discussion across Reddit, Mastodon, and other social sources.