Heap-use-after-free vulnerability in ghostscript

ghostscript Updated 02 Oct 2025

Summary

04/01/2022
HIGH
Yes i
High
Not published

OSV-2022-1: Heap-use-after-free in pdfi_dereference. Affects ghostscript versions >= c7cd63be10c23c712921d9ad7359ddbe5d282e44, < 3f5a2b75b2914b41ee600ab6226f1b4061bf267e. Fixed in 3f5a2b75b2914b41ee600ab6226f1b4061bf267e. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Ghostscript is an open-source interpreter for the PostScript language and the PDF file format. It is widely used for rendering and converting PDF files. This vulnerability affects the ghostscript package and is related to a heap-use-after-free issue in the pdfi_dereference function. The vulnerability can be triggered when processing a specially crafted PDF file, leading to potential security breaches and system crashes.

Vulnerability Detail

The vulnerability originates from a heap-use-after-free read of 4 bytes. The crash occurs in the pdfi_dereference function, specifically in the pdfi_dict_next and pdfi_check_Resources functions. This vulnerability has been reported by OSS-Fuzz, and more details can be found in their bug report (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43268). The severity of this vulnerability is considered high.

How To Fix

Minimum fixed version

3f5a2b75b2914b41ee600ab6226f1b4061bf267e

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, users can avoid processing untrusted or unknown PDF files with the vulnerable version of ghostscript. This can help mitigate the risk of exploitation until the package is updated.

Conclusion

In conclusion, the ghostscript package is vulnerable to a heap-use-after-free issue in the pdfi_dereference function. This vulnerability can be exploited by processing a specially crafted PDF file, potentially leading to security breaches and system crashes. It is recommended to update the ghostscript package to the latest version to mitigate this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for ghostscript →

Share this vulnerability

FAQ

Ghostscript is an open-source interpreter for the PostScript language and the PDF file format. It is commonly used for rendering and converting PDF files.

A heap-use-after-free vulnerability occurs when a program attempts to access memory that has already been freed. This can lead to crashes, memory corruption, and potential security vulnerabilities.

This vulnerability can be exploited by crafting a malicious PDF file and tricking a user or system into processing it with the vulnerable version of ghostscript. This can lead to potential security breaches and system crashes.

Yes, this vulnerability has been fixed in version 3f5a2b75b2914b41ee600ab6226f1b4061bf267e or later of the ghostscript package.

The severity of this vulnerability is considered high.

Related vulnerabilities

Recent vulnerabilities recorded for ghostscript.

How To Fix

Minimum fixed version

3f5a2b75b2914b41ee600ab6226f1b4061bf267e

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback