Heap-buffer-overflow in read_xref in ghostscript

ghostscript Updated 02 Oct 2025

Summary

19/05/2022
MEDIUM
Yes i
Medium
Not published

OSV-2022-417: Heap-buffer-overflow in read_xref. Affects ghostscript versions >= f89a938877ccaee51b3143b916f66b5ec9c8f0b5, < 7ab96e83d85165801894e887816db6042ea2f9be. Fixed in 7ab96e83d85165801894e887816db6042ea2f9be. 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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. The vulnerability in question, identified as OSV-2022-417, is a heap-buffer-overflow in the read_xref function of Ghostscript. This function is responsible for reading cross-reference tables in PDF files. The vulnerability can be triggered when processing a specially crafted PDF file, leading to a heap-buffer-overflow read of 8 bytes.

Vulnerability Detail

The heap-buffer-overflow vulnerability in read_xref can have serious consequences. An attacker could exploit this vulnerability by crafting a malicious PDF file and tricking a user into opening it with Ghostscript. If successful, the attacker may be able to execute arbitrary code or cause a denial-of-service condition. The vulnerability was discovered through the OSS-Fuzz project, and the affected versions of Ghostscript are those introduced before commit f89a938877ccaee51b3143b916f66b5ec9c8f0b5 and fixed in commit 7ab96e83d85165801894e887816db6042ea2f9be.

How To Fix

Minimum fixed version

7ab96e83d85165801894e887816db6042ea2f9be

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 workaround, users can exercise caution when opening PDF files from untrusted sources. Avoiding opening PDF files from unknown or suspicious sources can help mitigate the risk of exploitation. Additionally, using alternative PDF viewers that are not affected by this vulnerability can provide an extra layer of protection.

Conclusion

In conclusion, the heap-buffer-overflow vulnerability in the read_xref function of Ghostscript can be exploited by a specially crafted PDF file, potentially leading to arbitrary code execution or a denial-of-service condition. It is crucial to update Ghostscript to a fixed version and exercise caution when handling PDF files from untrusted sources. 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.

The vulnerability can allow an attacker to execute arbitrary code or cause a denial-of-service condition by exploiting a heap-buffer-overflow in the read_xref function of Ghostscript.

To fix this vulnerability, it is recommended to update Ghostscript to a version that includes the fix commit 7ab96e83d85165801894e887816db6042ea2f9be or later.

As a workaround, users can exercise caution when opening PDF files from untrusted sources and consider using alternative PDF viewers that are not affected by this vulnerability.

More information about this vulnerability can be found in the OSS-Fuzz report: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47501

Related vulnerabilities

Recent vulnerabilities recorded for ghostscript.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

7ab96e83d85165801894e887816db6042ea2f9be

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