CVE-2021-3781: OS Command Injection

Published Sep 8, 2021
·
Updated

A trivial sandbox (enabled with the -dSAFER option) escape flaw was found in the ghostscript interpreter by injecting a specially crafted pipe command. This flaw allows a specially crafted document to execute arbitrary commands on the system in the context of the ghostscript interpreter. The highest threat from this vulnerability is to confidentiality, integrity, as well as system availability.

Other sources

The file access protection built into Ghostscript proved insufficient for the "%pipe%" PostScript device, when combined with Ghostscript's requirement to be able to create and control temporary files in the conventional temporary file directories (for example, "/tmp" or "/temp). This exploit is restricted to Unix-like systems (i.e., it doesn't affect Windows). The most severe claimed results are only feasible if the exploit is run as a "high privilege" user (root/superuser level) -- a practice we would discourage under any circumstances.

Resolution: The solution involves including the device specifier string ("%pipe%") in the permissions checking, meaning the entire file name string is validated, rather than (as before) only the sub-string following the device specifier.

This flaw allows to trivially escape the sandbox (enabled with the -dSAFER option). A specially crafted document could use this flaw to execute command on the system, in the context of the ghostscript interpreter.

This flaw affects only version from 9.50 onward.

Upstream bug : https://bugs.ghostscript.com/showbug.cgi?id=704342

Red Hat

Affected Software

6 affected componentsFixes available
redhat/ghostpdl<9.55.0
9.55.0
Artifex Ghostscript=9.50
Artifex Ghostscript=9.52
Artifex Ghostscript=9.53.3
Artifex Ghostscript=9.54.0
Fedoraproject Fedora=34

Event History

Sep 8, 2021
Data Sourced
via Red Hat·11:46 AM
DescriptionSeverityAffected Software
Feb 16, 2022
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
DescriptionWeakness

Frequently Asked Questions

1

What is CVE-2021-3781?

CVE-2021-3781 is a vulnerability found in the ghostscript interpreter that allows a specially crafted document to execute arbitrary commands on the system.

2

What is the severity of CVE-2021-3781?

CVE-2021-3781 has a severity rating of 9.9 (Critical).

3

How does CVE-2021-3781 impact Artifex Ghostscript?

CVE-2021-3781 affects the following versions of Artifex Ghostscript: 9.50, 9.52, 9.53.3, and 9.54.0.

4

How can I fix CVE-2021-3781?

To fix CVE-2021-3781, it is recommended to update Artifex Ghostscript to a patched version provided by the vendor.

5

Where can I find more information about CVE-2021-3781?

You can find more information about CVE-2021-3781 in the references provided: [Reference 1](https://bugzilla.redhat.com/show_bug.cgi?id=2002271), [Reference 2](https://ghostscript.com/CVE-2021-3781.html), [Reference 3](https://security.gentoo.org/glsa/202211-11).

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203