← Back to Feed CACHED · 2026-08-06 14:04:24 · CACHE_KEY CVE-2017-8291
CVE-2017-8291 · CWE-843 · Disclosed 2017-04-27

Artifex Ghostscript through 2017-04-26

ASSESSED — NOISGATE V0.5
Vendor
Reassessed
Verdict:
Do you agree?
01 · The Real Story

The front door says 'upload your résumé' but the mail slot feeds straight into a loaded gun called Ghostscript

CVE-2017-8291 is a type confusion in Artifex Ghostscript ≤ 9.21 that lets an attacker bypass the -dSAFER sandbox and execute arbitrary OS commands by crafting a malicious .eps (or .ps) file containing a /OutputFile (%pipe%… directive routed through .rsdparams. The bug was a zero-day exploited in the wild in April 2017. Affected versions: Ghostscript ≤ 9.21, which ships as a default dependency on most Linux distributions and is invoked transparently by ImageMagick, Pillow (PIL), GraphicsMagick, and dozens of document-conversion pipelines. Fixed in Ghostscript 9.22 and backported via RHSA-2017:1230, DSA-3838, and equivalent distro advisories.

The vendor scored this 7.8 HIGH with a AV:L (Local) vector, which dramatically understates real-world risk. In practice, Ghostscript is almost never invoked by a human sitting at a terminal — it is called *server-side* by web applications that accept file uploads (image thumbnailing, PDF conversion, résumé parsing). That turns AV:L into effectively AV:N with no authentication. Combined with a CISA KEV listing, a Metasploit module, an EPSS of 96.14%, and the sheer ubiquity of ImageMagick on Linux hosts, the vendor severity is too low. noisgate upgrades this to CRITICAL.

"CVSS says Local but ImageMagick makes this remote RCE. KEV-listed, Metasploit-armed, and still hunted."
02 · The Attack Path

4 steps from start to impact.

STEP 01

Craft malicious EPS/PS payload

The attacker creates a PostScript or Encapsulated PostScript file embedding a .rsdparams type-confusion trigger. The payload includes a /OutputFile (%pipe%<command>) directive that, once the sandbox is bypassed, pipes output to a shell command. Metasploit's exploit/unix/fileformat/ghostscript_type_confusion automates this entirely, including reverse-shell generation.
Conditions required:
  • Attacker has the Metasploit module or public PoC (trivially available since 2017)
Where this breaks in practice:
  • None — payload generation is fully automated
Detection/coverage: Yara rules for %pipe% in PostScript preambles; ClamAV signatures exist for known variants.
STEP 02

Deliver payload to a Ghostscript consumer

The attacker uploads the malicious file to any endpoint that processes images or documents server-side — profile picture uploads, document converters, ticket attachment handlers, CI pipelines that render PDFs. The file extension can be .eps, .ps, .pdf, or even .jpg with PostScript magic bytes, because ImageMagick's delegate subsystem routes based on content type, not extension.
Conditions required:
  • Target application accepts file uploads or processes attacker-supplied documents
  • Server-side processing chain includes ImageMagick, Pillow, or direct Ghostscript invocation
Where this breaks in practice:
  • Modern ImageMagick policy.xml can disable Ghostscript delegates (but many deployments ship defaults)
  • WAFs may inspect uploads but rarely parse PostScript internals
Detection/coverage: WAF rules matching %pipe% in uploaded file content; application-layer logging of ImageMagick delegate invocations.
STEP 03

Ghostscript processes file, -dSAFER bypassed

When Ghostscript ≤ 9.21 evaluates the crafted file, the type confusion in .rsdparams / .eqproc allows the attacker to escape the -dSAFER sandbox. The /OutputFile (%pipe%…) directive is now evaluated in an unrestricted context, passing the embedded command string to /bin/sh.
Conditions required:
  • Ghostscript version ≤ 9.21 is installed on the processing host
Where this breaks in practice:
  • Any host patched to Ghostscript ≥ 9.22 (or distro backport from mid-2017) is immune
  • Container-based deployments may use pinned, updated base images
Detection/coverage: Version detection via gs --version; Nessus plugin 100497; Qualys QID 170234.
STEP 04

Arbitrary command execution as web-service user

The attacker's command runs as the user executing Ghostscript — typically the web server user (www-data, nobody, nginx, or the application's service account). From here, standard post-exploitation applies: reverse shell, credential harvesting from environment variables, lateral movement via cloud metadata endpoints (169.254.169.254), or container escape if the workload is unprivileged but not hardened.
Conditions required:
  • Ghostscript runs without additional sandboxing (no seccomp, no AppArmor/SELinux confinement)
Where this breaks in practice:
  • Containerized or SELinux-confined Ghostscript limits blast radius
  • Cloud workloads may lack direct outbound connectivity for reverse shells
Detection/coverage: EDR/auditd alerting on child process spawned by gs; outbound connection from Ghostscript process.
03 · Intelligence Metadata

The supporting signals.

In-the-Wild ExploitationConfirmed — exploited as a zero-day in April 2017. CISA added to KEV catalog 2022-05-24 with remediation deadline 2022-06-14, indicating continued relevance years after disclosure.
Proof-of-ConceptPublic and weaponized. Metasploit module exploit/unix/fileformat/ghostscript_type_confusion by hdm (EDB-41955). Vulhub has a turnkey Docker lab (vulhub/python/PIL-CVE-2017-8291). Original PoC on Ghostscript bug tracker #697808.
EPSS0.9614 (96th percentile) — top 4% of all CVEs for predicted exploitation probability.
KEV StatusListed. Date added: 2022-05-24. Due date: 2022-06-14. Vendor/Project: Artifex. Product: Ghostscript.
CVSS VectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H — 7.8 HIGH. The AV:L is technically correct (Ghostscript is a local binary) but misleading: the real attack surface is remote file upload → ImageMagick → gs, making this effectively network-reachable.
Affected VersionsGhostscript ≤ 9.21 (all releases through 2017-04-26). Affects RHEL 6/7, Debian 8 (Jessie), Ubuntu 14.04–16.04, SLES 12, and any system with an unpatched Ghostscript package.
Fixed VersionsGhostscript 9.22 (upstream). Distro backports: RHSA-2017:1230 (RHEL 7), DSA-3838 (Debian), USN-3272-1 (Ubuntu). All major distros shipped fixes by June 2017.
Scanning / ExposureGhostscript is not directly network-exposed, so Shodan/Censys/GreyNoise do not index it. Exposure is indirect — any web application using ImageMagick with default policy.xml on an unpatched host is vulnerable. Censys shows millions of web servers running Linux; the subset still on Ghostscript ≤ 9.21 is shrinking but nonzero, particularly in legacy on-prem and neglected cloud instances.
Disclosure Date2017-04-27 (public disclosure; zero-day exploitation observed prior).
Researcher / ReporterOriginally reported via Ghostscript bug tracker (#697808). Metasploit module by HD Moore (hdm). CISA KEV addition indicates ongoing threat actor interest.
04 · The Call

noisgate verdict.

Final Verdict
UPGRADED to CRITICAL (9.0/10)

The single most decisive factor is that the CVSS AV:L vector fundamentally misrepresents the real attack surface — Ghostscript is canonically invoked server-side by ImageMagick on web application hosts processing untrusted uploads, making this effectively unauthenticated remote code execution. Combined with a KEV listing, weaponized Metasploit module, and 96th-percentile EPSS, the vendor's 7.8 HIGH is insufficient.

HIGH Vulnerability mechanics and exploitation path are well-documented since 2017
HIGH KEV listing and EPSS confirm real-world exploitation relevance
MEDIUM Current installed base of Ghostscript ≤ 9.21 is declining but unquantified

Why this verdict

  • AV:L is a misnomer for this deployment pattern. Ghostscript is overwhelmingly consumed as a server-side delegate via ImageMagick/Pillow in web applications. An attacker uploads a crafted .eps to a profile photo endpoint and gets RCE — no local access needed. This alone warrants rescoring the access vector to Network.
  • KEV-listed with weaponized tooling. CISA added this to KEV in May 2022 — five years post-disclosure — indicating sustained threat actor interest. A Metasploit module, Vulhub lab, and multiple public PoCs lower the attacker skill bar to near-zero.
  • EPSS 96.14% confirms ongoing exploitation signal. This CVE sits in the top 4% of all CVEs for predicted exploitation, meaning threat intelligence feeds and honeypots continue to observe attempts.
  • Role multiplier: Ghostscript-via-ImageMagick is deployed on *web application servers*, which are a high-value-role component (line-of-business, often holding session secrets, database credentials, cloud IAM roles). Compromise of the web tier enables lateral movement to databases, internal APIs, and cloud metadata endpoints. On CI/CD hosts that use ImageMagick for artifact processing, this becomes a supply-chain pivot. The blast radius is host → tenant → potentially fleet depending on the compromised service's access. This floors the verdict at HIGH and the remote-equivalent access pushes it to CRITICAL.

Why not higher?

The reassessed score of 9.0 already reflects upgrade to CRITICAL. A 10.0 would require wormable, zero-interaction, network-facing exploitation. This chain still requires the attacker to deliver a file to an upload endpoint and depends on unpatched Ghostscript ≤ 9.21 — a version nearly a decade old. Most maintained environments have patched.

Why not lower?

Despite the vulnerability being nine years old, the KEV listing (added 2022, not 2017) proves threat actors still target it. The Metasploit module makes exploitation trivial. The ImageMagick delegate pattern turns a local binary vuln into unauthenticated remote RCE. Any system still running Ghostscript ≤ 9.21 is almost certainly also missing other critical patches, making it a soft target. The floor from the web-server role multiplier prevents downgrade below HIGH, and the remote-equivalent access vector pushes past that floor to CRITICAL.

05 · Compensating Control

What to do — in priority order.

  1. Disable Ghostscript delegates in ImageMagick policy.xml — Edit /etc/ImageMagick-6/policy.xml (or -7) and add <policy domain="delegate" rights="none" pattern="gs" /> and <policy domain="coder" rights="none" pattern="{PS,PS2,PS3,EPS,PDF,XPS}" />. This kills the attack chain at step 2 without removing Ghostscript. Deploy within the noisgate mitigation SLA of 3 days for CRITICAL.
  2. Upgrade Ghostscript to ≥ 9.22 (or apply distro backport) — This is the definitive fix. On RHEL/CentOS: yum update ghostscript. On Debian/Ubuntu: apt-get update && apt-get install ghostscript. The patch has been available since mid-2017. Complete within the noisgate remediation SLA of 90 days.
  3. Confine Ghostscript with AppArmor/SELinux/seccomp — If Ghostscript must remain at an older version temporarily, enforce mandatory access control that prevents gs from spawning child processes or writing outside its working directory. Use aa-enforce on Ubuntu or semanage on RHEL.
  4. Block PostScript file types at upload ingestion — At the application layer or WAF, reject uploads with PostScript magic bytes (%!PS) or extensions .eps, .ps. This prevents the payload from reaching Ghostscript entirely.
What doesn't work
  • Network-layer firewalling / segmentation alone — the payload arrives as an HTTP file upload through legitimate web traffic on ports 80/443. A firewall sees normal HTTPS, not an exploit.
  • -dSAFER flag — this is exactly the sandbox that CVE-2017-8291 bypasses. Relying on -dSAFER is relying on the broken control.
  • Antivirus file scanning on upload — traditional AV engines may not parse PostScript deeply enough to detect the type-confusion trigger; signature coverage is inconsistent outside of ClamAV's specific rules.
06 · Verification

Crowdsourced verification payload.

Run this script on each target Linux host where Ghostscript may be installed. Execute as any user: bash check_cve_2017_8291.sh. No elevated privileges required — it checks the installed Ghostscript version and ImageMagick delegate configuration.

noisgate-verify.sh
BASHREAD-ONLYSAFE
#!/usr/bin/env bash
# check_cve_2017_8291.sh — Detect CVE-2017-8291 exposure
# Run on target Linux host. No root required.
# Exit codes: 1=VULNERABLE, 0=PATCHED, 2=UNKNOWN

set -euo pipefail

VULNERABLE=0

# Check if Ghostscript is installed
if ! command -v gs &>/dev/null; then
  echo "PATCHED — Ghostscript is not installed on this host."
  exit 0
fi

# Get Ghostscript version
GS_VERSION=$(gs --version 2>/dev/null || echo "unknown")
echo "[*] Ghostscript version detected: $GS_VERSION"

if [[ "$GS_VERSION" == "unknown" ]]; then
  echo "UNKNOWN — Could not determine Ghostscript version."
  exit 2
fi

# Compare version — vulnerable if <= 9.21
# Split version into major.minor
MAJOR=$(echo "$GS_VERSION" | cut -d. -f1)
MINOR=$(echo "$GS_VERSION" | cut -d. -f2)

if [[ "$MAJOR" -lt 9 ]] || { [[ "$MAJOR" -eq 9 ]] && [[ "$MINOR" -le 21 ]]; }; then
  echo "[!] Ghostscript $GS_VERSION is VULNERABLE to CVE-2017-8291 (<=9.21)"
  VULNERABLE=1
else
  echo "[+] Ghostscript $GS_VERSION is PATCHED (>=9.22)"
fi

# Check for distro backport via package version (RPM-based)
if command -v rpm &>/dev/null; then
  PKG=$(rpm -q ghostscript 2>/dev/null || echo "not-installed")
  echo "[*] RPM package: $PKG"
  # RHSA-2017:1230 patched ghostscript-9.07-20.el7_3.5 and later
  if echo "$PKG" | grep -qE 'el[67].*\.(5|[6-9]|[1-9][0-9])\.' 2>/dev/null; then
    echo "[+] Distro backport likely applied — verify with: rpm -q --changelog ghostscript | grep CVE-2017-8291"
  fi
fi

# Check ImageMagick delegate policy
for POLICY in /etc/ImageMagick-{6,7}/policy.xml /usr/local/etc/ImageMagick-{6,7}/policy.xml; do
  if [[ -f "$POLICY" ]]; then
    echo "[*] Checking ImageMagick policy: $POLICY"
    if grep -qi 'pattern="gs".*rights="none"' "$POLICY" 2>/dev/null || \
       grep -qi 'pattern="{.*PS.*}".*rights="none"' "$POLICY" 2>/dev/null || \
       grep -qi 'pattern="PS".*rights="none"' "$POLICY" 2>/dev/null; then
      echo "[+] ImageMagick Ghostscript delegates appear to be disabled."
    else
      echo "[!] ImageMagick Ghostscript delegates are NOT disabled — exploitation via upload is possible."
      if [[ $VULNERABLE -eq 1 ]]; then
        echo "[!!] CRITICAL: Vulnerable Ghostscript + open ImageMagick delegates = remote RCE risk."
      fi
    fi
  fi
done

if [[ $VULNERABLE -eq 1 ]]; then
  echo ""
  echo "VULNERABLE"
  exit 1
else
  echo ""
  echo "PATCHED"
  exit 0
fi
07 · Bottom Line

If you remember one thing.

TL;DR
Monday morning: Query your fleet for Ghostscript version (gs --version) and prioritize any host returning ≤ 9.21. Per the noisgate mitigation SLA for CRITICAL, disable Ghostscript delegates in ImageMagick's policy.xml across all web-facing and CI/CD hosts within 3 days — this kills the remote attack chain without removing Ghostscript. Because this is KEV-listed with active exploitation history, treat mitigation as urgent even within that 3-day window. Then, under the noisgate remediation SLA, upgrade Ghostscript to ≥ 9.22 (or confirm distro backport) on all affected hosts within 90 days. Any host still running Ghostscript 9.21 in 2026 likely has deeper patch-debt problems — flag those systems for comprehensive vulnerability assessment, not just this CVE.

Sources

  1. NVD — CVE-2017-8291 Detail
  2. Exploit-DB — Ghostscript 9.21 Type Confusion (Metasploit)
  3. Rapid7 — Ghostscript CVE-2017-8291
  4. GitHub Advisory — GHSA-rh88-cwv2-gjxm
  5. Vulhub — PIL CVE-2017-8291 Docker Lab
  6. Debian Security Advisory DSA-3838
  7. Software Secured — ImageMagick RCE via Ghostscript
  8. CISA KEV Catalog
Peer Review

What defenders are saying.

Submit a review attribution: handle + country only
0 flags selected · stored anonymously
Validation Results

Crowdsourced verification outputs.

Results submitted by users who ran the verification payload against their environment.