Memcpy-param-overlap in ghostscript: pdfi_set_input_stream
Summary
OSV-2021-1683: Memcpy-param-overlap in pdfi_set_input_stream. Affects ghostscript versions >= 75fbddf52051987287e62d13c659eb73ba16982f, < 2be8b436910cfc8b013a13df000c3c854cf3c5c5. Fixed in 2be8b436910cfc8b013a13df000c3c854cf3c5c5. 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 PDF file format. It is widely used for rendering and manipulating PDF files. The pdfi_set_input_stream function in Ghostscript is responsible for setting the input stream for PDF interpretation. This vulnerability, identified as Memcpy-param-overlap, allows an attacker to exploit a memory overlap issue in the pdfi_set_input_stream function, potentially leading to a crash or arbitrary code execution.
Vulnerability Detail
The vulnerability arises due to a memory overlap issue in the pdfi_set_input_stream function. By providing specially crafted input, an attacker can trigger a memcpy operation with overlapping source and destination buffers. This can result in undefined behavior, including crashes or the execution of arbitrary code. The vulnerability has a medium severity rating and was discovered through OSS-Fuzz, a continuous fuzzing service for open-source software.
How To Fix
Minimum fixed version
2be8b436910cfc8b013a13df000c3c854cf3c5c5
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 PDF files with Ghostscript to mitigate the risk of exploitation. It is also advisable to follow best practices for secure handling of PDF files, such as using up-to-date antivirus software and exercising caution when opening PDF files from unknown or untrusted sources.
Conclusion
In conclusion, the Memcpy-param-overlap vulnerability in Ghostscript's pdfi_set_input_stream function can be exploited to cause crashes or execute arbitrary code. Users are advised to update to a fixed version of Ghostscript and follow security best practices when handling PDF files. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for ghostscript →
FAQ
This vulnerability can potentially lead to crashes or arbitrary code execution in Ghostscript, depending on how it is exploited. An attacker could craft a malicious PDF file to trigger the vulnerability and potentially gain control over the affected system.
This vulnerability was discovered through OSS-Fuzz, a continuous fuzzing service for open-source software. The service automatically tests software by providing random inputs and monitoring for crashes or other abnormal behavior. The vulnerability was reported and fixed by the Ghostscript development team.
At the time of this report, there is no known public exploit for this vulnerability. However, it is important to apply the recommended fix and follow security best practices to mitigate the risk of exploitation.
No, not all versions of Ghostscript are affected by this vulnerability. The issue was introduced in commit 75fbddf52051987287e62d13c659eb73ba16982f and fixed in commit 2be8b436910cfc8b013a13df000c3c854cf3c5c5. Users should update to a version that includes the fix to ensure they are protected.
More information about this vulnerability can be found in the OSS-Fuzz report: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42268. Additionally, the source code changes related to the fix can be viewed in the Ghostscript Git repository.
References
Related vulnerabilities
Recent vulnerabilities recorded for ghostscript.