Skip to content
Security

Ghostscript Upload2Shell (CVE-2026-125396): What to Do

Upload2Shell, CVE-2026-125396, lets an uploaded file run commands through Ghostscript. Safe versions, fixes for cPanel and other servers, and what HostGrap did.

Ghostscript Upload2Shell vulnerability CVE-2026-125396, cPanel servers fixed

Upload2Shell is a vulnerability in Ghostscript, tracked as CVE-2026-125396, that can let an attacker run commands on a server. It affects every Ghostscript version before 10.08.0, and websites and webmail that create previews or thumbnails from uploaded files can be a way in. cPanel's advice is to update WordPress, update Roundcube webmail through cPanel, and, where that is not possible yet, block Ghostscript in ImageMagick. HostGrap has applied the fix on all of our cPanel hosting servers. If you have a VPS or VDS, you manage that server yourself, so follow the steps in this guide to protect it.

What is Ghostscript and why does this matter?

Ghostscript is a program that reads PostScript and PDF files. Most people never use it directly, but it is installed on many Linux servers because ImageMagick, the image tool that websites use to resize photos and make thumbnails, calls Ghostscript whenever it meets a PDF or PostScript file.

That is what makes this flaw serious on web servers. As the name Upload2Shell suggests, a specially made file that is uploaded to a website, for example as a profile picture, a document or an email attachment, can reach Ghostscript when the website tries to make a preview of it. On a vulnerable version, that file can make Ghostscript run commands on the server with the same rights as the website.

Who is affected?

Any server with a Ghostscript version earlier than 10.08.0 is affected when software on it passes uploaded files to ImageMagick or Ghostscript. On cPanel servers, cPanel names two common paths: WordPress, which makes image previews and thumbnails when you upload media, and Roundcube, the webmail in cPanel, which can make previews of attachments.

If you rent shared, WordPress, business or reseller hosting, the hosting company has to fix the server. If you run your own VPS, VDS or dedicated server, you are the one who has to fix it.

Which versions fix it?

SoftwareSafe version
Ghostscript10.08.0 or newer
WordPress6.8.8, 6.9.7, 7.0.4 or newer
Roundcube (cPanel)1.6.20 or newer

Some Linux distributions add security fixes to their own Ghostscript packages without changing the main version number, so on those systems check your distribution's security notices as well as the version.

What has HostGrap done?

We have applied the fix on all HostGrap cPanel hosting servers, the ones that run our cPanel, WordPress, business and reseller hosting. Customers on these plans don't need to do anything on the server side.

You should still keep WordPress itself up to date, because the WordPress versions above contain their own fix. Most WordPress websites install these minor updates on their own. To check, log in to WordPress and look at the version in Dashboard, Updates, or use WP Toolkit in cPanel to update every WordPress website in your account at once.

How do I fix it on my own cPanel VPS or VDS?

If you have a HostGrap VPS or VDS with cPanel & WHM, start by checking the Roundcube version over SSH as root:

rpm -q cpanel-roundcubemail

If the version is lower than 1.6.20, update cPanel & WHM, which also updates Roundcube:

/scripts/upcp

Then update every WordPress website on the server to 6.8.8, 6.9.7, 7.0.4 or newer. If WP Toolkit is installed in WHM, it can update all of them from one screen.

How do I fix it on a VPS or VDS without cPanel?

On a server without cPanel, update Ghostscript with your system's package manager and restart your web server and PHP. First check the installed version:

gs --version

On Ubuntu or Debian, install the latest packages:

apt update && apt upgrade

On AlmaLinux, Rocky Linux or CloudLinux, use:

dnf update

Then restart your web server and PHP-FPM so they load the updated libraries, and update any WordPress websites on the server.

What if I can't update yet?

Until Ghostscript 10.08.0 or a patched package is available for your system, you can stop ImageMagick from handing files to Ghostscript. This is cPanel's recommended temporary fix. Open the ImageMagick policy file:

nano /etc/ImageMagick-*/policy.xml

Inside the <policymap> section, add these lines:

<!-- Begin mitigation for CVE-2026-125396 -->
<policy domain="delegate" rights="none" pattern="gs" />
<policy domain="coder" rights="none" pattern="PS" />
<policy domain="coder" rights="none" pattern="PS2" />
<policy domain="coder" rights="none" pattern="PS3" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="none" pattern="PDF" />
<policy domain="coder" rights="none" pattern="XPS" />
<!-- End mitigation for CVE-2026-125396 -->

Save the file, then restart Apache and PHP-FPM so they use the new policy. On a cPanel server:

/scripts/restartsrv_apache
/scripts/restartsrv_apache_php_fpm

This blocks the attack path, but it also stops ImageMagick from reading PDF and PostScript files. Previews and thumbnails of PDF files in WordPress, Roundcube and other apps may stop working while it is in place. Once Ghostscript is on version 10.08.0 or newer, remove these lines and restart the services again.

Do HostGrap customers need to do anything?

It depends on your service. If you have cPanel, WordPress, business or reseller hosting, the server is already fixed. The only step for you is to make sure your WordPress websites are on 6.8.8, 6.9.7, 7.0.4 or newer.

If you have a HostGrap VPS or VDS, you have full control of the server and the software on it, so the fix is yours to install. Follow the steps above for a server with or without cPanel. If you're not sure how, message us on WhatsApp or open a support ticket, and HostGrap AI or our team will help.

This is the third server security update this month. You can also read about the phpAfterShell PHP flaw and the cPanel & WHM reseller SSL vulnerability, and our WordPress security checklist for keeping your website safe.

Share this article

More from the blog

All posts