Stack-buffer-overflow in pdfi_annot_draw in ghostscript
Summary
OSV-2021-1688: Stack-buffer-overflow in pdfi_annot_draw. Affects ghostscript versions >= 75fbddf52051987287e62d13c659eb73ba16982f, < a7f2474c5aaac7a75a4119478c77d2cafcf45b85. Fixed in a7f2474c5aaac7a75a4119478c77d2cafcf45b85. 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 manipulating PDF documents. The vulnerability in question, identified as OSV-2021-1688, is a stack-buffer-overflow in the pdfi_annot_draw function of Ghostscript. This function is responsible for drawing annotations in PDF documents. The vulnerability allows an attacker to overwrite stack memory, potentially leading to remote code execution or a denial-of-service attack.
Vulnerability Detail
The stack-buffer-overflow vulnerability in pdfi_annot_draw arises due to improper bounds checking when processing annotations in PDF documents. By crafting a malicious PDF file with specially crafted annotations, an attacker can trigger a stack-based buffer overflow, overwriting adjacent memory and potentially gaining control over the execution flow of the program. This can result in arbitrary code execution or a crash of the Ghostscript interpreter.
How To Fix
Minimum fixed version
a7f2474c5aaac7a75a4119478c77d2cafcf45b85
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 disable the processing of annotations in Ghostscript by modifying the configuration or command-line options. By disabling annotation processing, the vulnerability can be mitigated. However, this workaround may impact the functionality of PDF documents that rely on annotations.
Conclusion
The stack-buffer-overflow vulnerability in pdfi_annot_draw in Ghostscript can lead to remote code execution or a denial-of-service attack. It is crucial to update your Ghostscript installation to a version that includes the fix. In the meantime, you can mitigate the vulnerability by disabling annotation processing. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for ghostscript →
FAQ
The vulnerability can potentially allow an attacker to execute arbitrary code or cause a denial-of-service attack by crashing the Ghostscript interpreter.
You can use the Vulert Playground at Vulert Scanner to check if your installation of Ghostscript is affected by this vulnerability. Simply upload your package-lock.json file to the playground, and it will analyze the dependencies and alert you if any vulnerabilities are found.
At the time of this report, there are no known public exploits for this vulnerability. However, it is important to patch your installation as soon as possible to prevent potential attacks.
No, there is no CVE assigned to this vulnerability at the time of this report.
You can find more information about this vulnerability in the OSS-Fuzz report at https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42329.
References
Related vulnerabilities
Recent vulnerabilities recorded for ghostscript.