Stack-buffer-overflow in pdfi_oc_is_ocg_visible in ghostscript
Summary
OSV-2021-1763: Stack-buffer-overflow in pdfi_oc_is_ocg_visible. Affects ghostscript versions >= 75fbddf52051987287e62d13c659eb73ba16982f, < fabad29820734af831cf4f2ae6c4beb4179d4733. Fixed in fabad29820734af831cf4f2ae6c4beb4179d4733. How to fix ↓
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.
No signup required · Results in about 60 seconds
Background
Ghostscript is an open-source interpreter for the PostScript language and the PDF file format. It is widely used for rendering and converting documents. The vulnerability in question, identified as OSV-2021-1763, is a stack-buffer-overflow issue that affects the pdfi_oc_is_ocg_visible function in Ghostscript. This function is responsible for determining the visibility of Optional Content Groups (OCGs) in a PDF file. The vulnerability can be triggered by a specially crafted PDF file, potentially leading to a crash or arbitrary code execution.
Vulnerability Detail
The stack-buffer-overflow vulnerability in pdfi_oc_is_ocg_visible arises from a write operation that exceeds the bounds of a stack-allocated buffer. An attacker can exploit this vulnerability by providing a malicious PDF file with carefully crafted OCG data. When the vulnerable function attempts to process the OCG data, it writes beyond the allocated buffer, corrupting adjacent memory. This can result in a crash or enable an attacker to execute arbitrary code with the privileges of the Ghostscript process. The vulnerability has been assigned a severity rating of HIGH.
How To Fix
Minimum fixed version
fabad29820734af831cf4f2ae6c4beb4179d4733
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 consider disabling the processing of OCGs in Ghostscript. This can be achieved by modifying the Ghostscript configuration or command-line options to exclude OCG-related functionality. However, this workaround may impact the rendering or functionality of certain PDF files that rely on OCGs.
Conclusion
In conclusion, the stack-buffer-overflow vulnerability in pdfi_oc_is_ocg_visible in Ghostscript can be exploited by a specially crafted PDF file, potentially leading to a crash or arbitrary code execution. Users are advised to update their installations to a version that includes the fix or apply the provided workaround. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for ghostscript →
FAQ
Ghostscript is an open-source interpreter for the PostScript language and the PDF file format. It is commonly used for rendering and converting documents.
The vulnerability can lead to a crash or enable an attacker to execute arbitrary code with the privileges of the Ghostscript process.
To fix this vulnerability, update Ghostscript to a version that includes the fix. Refer to the provided commit or subsequent releases.
As a temporary workaround, consider disabling the processing of OCGs in Ghostscript. However, this may affect certain PDF files that rely on OCGs.
For more information, refer to the provided OSS-Fuzz report and the source link in the database-specific details.
References
Related vulnerabilities
Recent vulnerabilities recorded for ghostscript.