cbcvebase.
CVE-2017-8291
published 2017-04-27

CVE-2017-8291: Artifex Ghostscript through 2017-04-26 allows -dSAFER bypass and remote command execution via .rsdparams type confusion with a "/OutputFile (%pipe%" substring…

PriorityP187high7.8CVSS 3.1
AVLACLPRNUIRSUCHIHAH
KEVITWEXPLOITInitial access
CISA Known Exploited Vulnerabilitydue 2022-06-14
Exploited in the wild
EPSS
96.97%
99.9th percentile
Artifex Ghostscript through 2017-04-26 allows -dSAFER bypass and remote command execution via .rsdparams type confusion with a "/OutputFile (%pipe%" substring in a crafted .eps document that is an input to the gs program, as exploited in the wild in April 2017.

Affected

29 ranges· showing 25
VendorProductVersion rangeFixed in
artifexghostscript< 9.219.21
artifexghostscript>= 0 < 9.20~dfsg-3.19.20~dfsg-3.1
artifexghostscript>= 0 < 9.20~dfsg-3.19.20~dfsg-3.1
artifexghostscript>= 0 < 9.20~dfsg-3.19.20~dfsg-3.1
artifexghostscript>= 0 < 9.20~dfsg-3.19.20~dfsg-3.1
artifexghostscript>= 0 < 9.10~dfsg-0ubuntu10.79.10~dfsg-0ubuntu10.7
artifexghostscript>= 0 < 9.10~dfsg-0ubuntu10.99.10~dfsg-0ubuntu10.9
artifexghostscript>= 0 < 9.18~dfsg~0-0ubuntu2.49.18~dfsg~0-0ubuntu2.4
artifexghostscript>= 0 < 9.18~dfsg~0-0ubuntu2.69.18~dfsg~0-0ubuntu2.6
debiandebian_linux
debianghostscript< ghostscript 9.20~dfsg-3.1 (bookworm)ghostscript 9.20~dfsg-3.1 (bookworm)
redhatenterprise_linux_desktop
redhatenterprise_linux_desktop
redhatenterprise_linux_eus
redhatenterprise_linux_eus
redhatenterprise_linux_eus
redhatenterprise_linux_eus
redhatenterprise_linux_eus
redhatenterprise_linux_server
redhatenterprise_linux_server
redhatenterprise_linux_server_aus
redhatenterprise_linux_server_aus
redhatenterprise_linux_server_aus
redhatenterprise_linux_server_aus
redhatenterprise_linux_server_tus

Detection & IOCsextracted from sources · hover to see the quote

filenamemsf.eps
pathdata/exploits/CVE-2017-8291/msf.eps
commandgs -q -dNOPAUSE -dSAFER -sDEVICE=ppmraw -sOutputFile=/dev/null -f exploit2.eps
other/OutputFile (%pipe%
  • Detect CVE-2017-8291 exploitation by scanning EPS/PostScript content for the '/OutputFile (%pipe%' substring, which is the key trigger for the -dSAFER bypass and arbitrary command execution via .rsdparams type confusion.
  • Detect CRAT C2 HTTP POST traffic by matching the URL-encoded form data pattern containing 'code=', 'token=', 'content=', 'frags=', and 'limit=10' fields, with requests appended with a '?ts=' timestamp parameter.
  • Detect shellcode execution from within a Ghostscript/HWP exploit chain that spawns PowerShell invoking regsvr32 to download and execute a remote payload — indicative of CRATv1 delivery.
  • The Lazarus campaign's C2 infrastructure relies entirely on IP addresses rather than domains; network detections should focus on direct-IP HTTP C2 beaconing from gs.exe or HWP-spawned child processes.
  • ·The CVE-2017-8291 exploit is triggered via embedded PostScript inside HWP documents in observed Lazarus campaigns, but the NVD description confirms it can be triggered via any crafted .eps file passed to the gs program — detection scope should not be limited to HWP files.
  • ·The exploit bypasses -dSAFER, meaning Ghostscript instances launched with the SAFER flag are still vulnerable; do not rely on -dSAFER as a mitigation for this CVE.
  • ·The four-byte XOR key used to obfuscate the first-stage shellcode is altered between lure documents; signatures based on a specific XOR key value will not generalize across all samples in this campaign.
  • ·The vulnerability affects Ghostscript 9.21 and earlier and is exploitable through wrapper libraries such as ImageMagick and Pillow, not only direct gs invocations — detection and patching must cover all products embedding Ghostscript.

CVSS provenance

nvdv3.17.8HIGHCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
nvdv2.06.8MEDIUMAV:N/AC:M/Au:N/C:P/I:P/A:P
osv7.8HIGH
vulncheck7.8HIGH
cisa7.8HIGH
vendor_debian7.8HIGH
vendor_redhat7.8HIGH
vendor_ubuntu5.5MEDIUM
CVEs like this are exactly what “Exploited This Week” covers.

Every Monday: what got weaponized or added to CISA KEV in the last seven days — each CVE cross-linked to its PoC, Nuclei template, and detection rule. Free, one email a week, unsubscribe in one click.