CVE-2021-3781 Command injection in ghostscript

Critical 9.9 Published Updated

Attackers can execute arbitrary commands via crafted documents in Ghostscript when the safer sandbox mode is enabled.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2021-3781?

CVE-2021-3781 is a critical command injection vulnerability in Artifex Ghostscript, published on 16 Feb 2022. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

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.

Weakness: CWE-78, CWE-20

Which versions are affected by CVE-2021-3781?

It affects 2 products.

Linux distribution packages (40)
ghostscript SUSE:Enterprise Storage 6All versions9.52-155.1
libspectre SUSE:Enterprise Storage 6All versions0.2.8-3.12.1
ghostscript SUSE:HPE Helion OpenStack 8All versions9.52-23.42.1
libspectre SUSE:HPE Helion OpenStack 8All versions0.2.7-12.12.1
ghostscript SUSE:Linux Enterprise High Performance Computing 15 SP1-ESPOSAll versions9.52-155.1
libspectre SUSE:Linux Enterprise High Performance Computing 15 SP1-ESPOSAll versions0.2.8-3.12.1
ghostscript SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSSAll versions9.52-155.1
libspectre SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSSAll versions0.2.8-3.12.1
ghostscript SUSE:Linux Enterprise High Performance Computing 15-ESPOSAll versions9.52-155.1
libspectre SUSE:Linux Enterprise High Performance Computing 15-ESPOSAll versions0.2.8-3.12.1
ghostscript SUSE:Linux Enterprise High Performance Computing 15-LTSSAll versions9.52-155.1
libspectre SUSE:Linux Enterprise High Performance Computing 15-LTSSAll versions0.2.8-3.12.1
ghostscript SUSE:Linux Enterprise Module for Basesystem 15 SP2All versions9.52-155.1
ghostscript SUSE:Linux Enterprise Module for Basesystem 15 SP3All versions9.52-155.1
libspectre SUSE:Linux Enterprise Module for Desktop Applications 15 SP2All versions0.2.8-3.12.1
libspectre SUSE:Linux Enterprise Module for Desktop Applications 15 SP3All versions0.2.8-3.12.1
ghostscript SUSE:Linux Enterprise Server 12 SP2-BCLAll versions9.52-23.42.1
libspectre SUSE:Linux Enterprise Server 12 SP2-BCLAll versions0.2.7-12.12.1
ghostscript SUSE:Linux Enterprise Server 12 SP3-BCLAll versions9.52-23.42.1
libspectre SUSE:Linux Enterprise Server 12 SP3-BCLAll versions0.2.7-12.12.1
ghostscript SUSE:Linux Enterprise Server 12 SP3-LTSSAll versions9.52-23.42.1
libspectre SUSE:Linux Enterprise Server 12 SP3-LTSSAll versions0.2.7-12.12.1
ghostscript SUSE:Linux Enterprise Server 12 SP4-LTSSAll versions9.52-23.42.1
libspectre SUSE:Linux Enterprise Server 12 SP4-LTSSAll versions0.2.7-12.12.1
ghostscript SUSE:Linux Enterprise Server 12 SP5All versions9.52-23.42.1
libspectre SUSE:Linux Enterprise Server 12 SP5All versions0.2.7-12.12.1
ghostscript SUSE:Linux Enterprise Server 15 SP1-BCLAll versions9.52-155.1
libspectre SUSE:Linux Enterprise Server 15 SP1-BCLAll versions0.2.8-3.12.1
ghostscript SUSE:Linux Enterprise Server 15 SP1-LTSSAll versions9.52-155.1
libspectre SUSE:Linux Enterprise Server 15 SP1-LTSSAll versions0.2.8-3.12.1
ghostscript SUSE:Linux Enterprise Server 15-LTSSAll versions9.52-155.1
libspectre SUSE:Linux Enterprise Server 15-LTSSAll versions0.2.8-3.12.1
ghostscript SUSE:Linux Enterprise Server for SAP Applications 12 SP3All versions9.52-23.42.1
libspectre SUSE:Linux Enterprise Server for SAP Applications 12 SP3All versions0.2.7-12.12.1
ghostscript SUSE:Linux Enterprise Server for SAP Applications 12 SP4All versions9.52-23.42.1
libspectre SUSE:Linux Enterprise Server for SAP Applications 12 SP4All versions0.2.7-12.12.1
ghostscript SUSE:Linux Enterprise Server for SAP Applications 12 SP5All versions9.52-23.42.1
libspectre SUSE:Linux Enterprise Server for SAP Applications 12 SP5All versions0.2.7-12.12.1
ghostscript SUSE:Linux Enterprise Server for SAP Applications 15All versions9.52-155.1
libspectre SUSE:Linux Enterprise Server for SAP Applications 15All versions0.2.8-3.12.1

Products include Artifex Ghostscript, Fedoraproject Fedora.

How do I fix CVE-2021-3781?

Apply the vendor's patch.

Upgrade, and pass arguments to programs as a list instead of through a shell. More about Command injection.

Is CVE-2021-3781 being exploited?

There is no known exploitation of CVE-2021-3781 in the wild and no public exploit code.

All Artifex Ghostscript vulnerabilities

Sources

Also known as ALPINE-CVE-2021-3781, DEBIAN-CVE-2021-3781, DSA-4972-1, GHSA-gf7q-r6ff-xwg6, MGASA-2021-0436, OESA-2022-1560 and 6 more.

Is CVE-2021-3781 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free