CVE-2023-36664
📋 TL;DR
CVE-2023-36664 is a security bypass vulnerability in Artifex Ghostscript that allows arbitrary command execution through improper permission validation for pipe devices. Attackers can exploit this by crafting malicious PostScript files that use pipe device prefixes to execute system commands. This affects all systems running vulnerable Ghostscript versions that process untrusted PostScript files.
💻 Affected Systems
- Artifex Ghostscript
📦 What is this software?
Fedora by Fedoraproject
Fedora by Fedoraproject
Ghostscript by Artifex
⚠️ Risk & Real-World Impact
Worst Case
Full system compromise with remote code execution as the Ghostscript process user, potentially leading to data theft, ransomware deployment, or lateral movement within the network.
Likely Case
Local privilege escalation or arbitrary command execution when processing malicious PostScript files, potentially leading to data exfiltration or further system compromise.
If Mitigated
Limited impact if Ghostscript runs in sandboxed environments with minimal privileges and only processes trusted files.
🎯 Exploit Status
Exploitation requires the ability to supply malicious PostScript files to Ghostscript. Proof-of-concept examples are available in the bug reports. The vulnerability is straightforward to exploit once an attacker can control input to Ghostscript.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 10.02.0 and later
Vendor Advisory: https://bugs.ghostscript.com/show_bug.cgi?id=706761
Restart Required: No
Instructions:
1. Upgrade Ghostscript to version 10.02.0 or later. 2. For Linux systems: Use package manager (apt-get update && apt-get upgrade ghostscript, yum update ghostscript, etc.). 3. For Windows: Download and install the latest version from the official website. 4. For source installations: Download and compile the latest version from the Git repository.
🔧 Temporary Workarounds
Disable pipe devices via configuration
allConfigure Ghostscript to disable pipe devices by modifying the device permissions
Add '-dSAFER -dDELAYSAFER' to Ghostscript command line arguments
Set 'GS_DEVICES=' in environment to exclude pipe devices
Sandbox Ghostscript execution
linuxRun Ghostscript in a restricted environment with minimal privileges
Use Linux namespaces: unshare -r -m -p -f -U --mount-proc
Use Docker containers with limited capabilities
Use SELinux/AppArmor policies to restrict Ghostscript
🧯 If You Can't Patch
- Implement strict input validation to reject PostScript files containing pipe device syntax (%pipe% or | prefixes)
- Run Ghostscript as an unprivileged user with minimal filesystem access and network capabilities
🔍 How to Verify
Check if Vulnerable:
Check Ghostscript version: gs --version. If version is 10.01.2 or earlier, the system is vulnerable.
Check Version:
gs --version
Verify Fix Applied:
After patching, verify version is 10.02.0 or later with: gs --version. Test with a safe pipe device command to confirm restrictions.
📡 Detection & Monitoring
Log Indicators:
- Ghostscript process spawning unexpected child processes
- Error logs containing pipe device syntax
- Unusual command execution patterns from Ghostscript processes
Network Indicators:
- Ghostscript processes making unexpected network connections
- Outbound connections from document processing systems to suspicious destinations
SIEM Query:
process_name:"gs" AND (command_line:"%pipe%" OR command_line:"|")
🔗 References
- https://bugs.ghostscript.com/show_bug.cgi?id=706761
- https://git.ghostscript.com/?p=ghostpdl.git%3Ba=commit%3Bh=0974e4f2ac0005d3731e0b5c13ebc7e965540f4d
- https://git.ghostscript.com/?p=ghostpdl.git%3Ba=commit%3Bh=505eab7782b429017eb434b2b95120855f2b0e3c
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/2ICXN5VPF3WJCYKMPSYER5KHTPJXSTJZ/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/5EWMEK2UPCUU3ZLL7VASE5CEHDQY4VKV/
- https://security.gentoo.org/glsa/202309-03
- https://www.debian.org/security/2023/dsa-5446
- https://bugs.ghostscript.com/show_bug.cgi?id=706761
- https://git.ghostscript.com/?p=ghostpdl.git%3Ba=commit%3Bh=0974e4f2ac0005d3731e0b5c13ebc7e965540f4d
- https://git.ghostscript.com/?p=ghostpdl.git%3Ba=commit%3Bh=505eab7782b429017eb434b2b95120855f2b0e3c
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/2ICXN5VPF3WJCYKMPSYER5KHTPJXSTJZ/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/5EWMEK2UPCUU3ZLL7VASE5CEHDQY4VKV/
- https://security.gentoo.org/glsa/202309-03
- https://www.debian.org/security/2023/dsa-5446