The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2021-3781

CVE-2021-3781: Artifex Ghostscript RCE Vulnerability

CVE-2021-3781 is a sandbox escape RCE vulnerability in Artifex Ghostscript that bypasses the -dSAFER option to execute arbitrary commands. This article covers the technical details, affected versions, and mitigation strategies.

Published: February 25, 2026

CVE-2021-3781 Overview

A trivial sandbox escape flaw was discovered in the Ghostscript interpreter that allows attackers to bypass the -dSAFER sandbox protection by injecting specially crafted pipe commands. This vulnerability enables arbitrary command execution on the target system within the context of the Ghostscript interpreter, posing severe risks to confidentiality, integrity, and system availability.

Critical Impact

This sandbox escape vulnerability allows attackers to execute arbitrary commands on the system by bypassing Ghostscript's -dSAFER protection mechanism through malicious document processing.

Affected Products

  • Artifex Ghostscript 9.50
  • Artifex Ghostscript 9.52
  • Artifex Ghostscript 9.53.3
  • Artifex Ghostscript 9.54.0
  • Fedora Project Fedora 34

Discovery Timeline

  • 2022-02-16 - CVE CVE-2021-3781 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2021-3781

Vulnerability Analysis

This vulnerability represents a Command Injection flaw (CWE-78) combined with Improper Input Validation (CWE-20) in the Ghostscript interpreter. The -dSAFER option is designed to restrict potentially dangerous operations when processing PostScript and PDF documents, creating a sandbox environment. However, the flaw allows attackers to circumvent this sandbox entirely by injecting specially crafted pipe commands into documents processed by Ghostscript.

When a malicious document is processed, the injected pipe commands are executed with the same privileges as the Ghostscript process, which could be elevated depending on the system configuration. This is particularly dangerous because Ghostscript is widely used in document processing pipelines, print servers, and web applications for PDF rendering and conversion.

Root Cause

The root cause lies in insufficient input validation within the Ghostscript interpreter's pipe handling mechanism. The -dSAFER sandbox mode fails to properly sanitize or restrict pipe command constructs, allowing specially crafted PostScript or PDF content to escape the sandbox boundaries and execute arbitrary system commands.

Attack Vector

The attack is network-accessible, requiring low privileges and no user interaction. An attacker can exploit this vulnerability by:

  1. Crafting a malicious PostScript or PDF document containing embedded pipe commands
  2. Delivering the document to a target system that processes it with Ghostscript
  3. When the document is processed (even with -dSAFER enabled), the injected pipe commands execute
  4. The attacker gains arbitrary command execution in the context of the Ghostscript interpreter process

This vulnerability has a scope change impact, meaning exploitation can affect resources beyond the vulnerable component's security scope, potentially compromising the entire host system.

The exploitation mechanism involves injecting pipe commands within PostScript constructs that bypass the -dSAFER restrictions. For detailed technical information about the vulnerability mechanism, refer to the Ghostscript CVE-2021-3781 Details advisory.

Detection Methods for CVE-2021-3781

Indicators of Compromise

  • Unexpected child processes spawned by Ghostscript (gs) processes
  • Anomalous network connections originating from Ghostscript processes
  • Suspicious PostScript or PDF files containing pipe command syntax (e.g., %pipe%)
  • Unusual system command execution patterns following document processing events

Detection Strategies

  • Monitor process creation events where the parent process is gs or ghostscript for suspicious command line arguments
  • Implement file scanning rules to detect PostScript/PDF documents containing pipe command injection patterns
  • Deploy endpoint detection rules that alert on Ghostscript processes attempting to spawn shells or execute system utilities
  • Review application logs for Ghostscript errors or warnings that may indicate exploitation attempts

Monitoring Recommendations

  • Enable comprehensive logging for document processing services and print spoolers
  • Configure SentinelOne Singularity to monitor Ghostscript process behavior and detect anomalous child process spawning
  • Implement network segmentation to limit the impact of potential compromise from document processing systems
  • Set up alerts for Ghostscript processes accessing sensitive files or making unexpected network connections

How to Mitigate CVE-2021-3781

Immediate Actions Required

  • Update Artifex Ghostscript to a patched version immediately
  • Audit systems for any versions of Ghostscript in the affected range (9.50, 9.52, 9.53.3, 9.54.0)
  • Review document processing workflows to identify exposure points
  • Consider temporarily disabling Ghostscript-based document processing if immediate patching is not possible

Patch Information

Artifex has released security updates to address this vulnerability. Organizations should apply the latest Ghostscript security patches as documented in the official advisory. For detailed patch information, refer to the Ghostscript CVE-2021-3781 Details page and the Red Hat Bug Report #2002271. Fedora users should update to patched versions available through their distribution's package manager.

Workarounds

  • Implement strict input validation for all documents before Ghostscript processing
  • Use application sandboxing (containers, SELinux, AppArmor) to limit Ghostscript process capabilities
  • Disable or restrict Ghostscript usage in automated document processing pipelines until patched
  • Deploy network-level controls to prevent compromised document processors from initiating outbound connections
bash
# Configuration example
# Verify installed Ghostscript version
gs --version

# Check if Ghostscript is in use on the system
which gs
rpm -qa | grep ghostscript  # For RPM-based systems
dpkg -l | grep ghostscript  # For Debian-based systems

# Update Ghostscript on Fedora systems
sudo dnf update ghostscript

# Apply SELinux confinement for additional protection
sudo semanage fcontext -a -t ghostscript_exec_t /usr/bin/gs
sudo restorecon -v /usr/bin/gs

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechGhostscript

  • SeverityCRITICAL

  • CVSS Score9.9

  • EPSS Probability9.27%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-20

  • CWE-78
  • Technical References
  • Gentoo GLSA 202211-11 Advisory
  • Vendor Resources
  • Red Hat Bug Report #2002271

  • Ghostscript CVE-2021-3781 Details
  • Related CVEs
  • CVE-2025-27830: Artifex Ghostscript Buffer Overflow Flaw

  • CVE-2025-27837: Artifex Ghostscript Path Traversal Issue
Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English