The following vulnerability was reported to Ubuntu's bug tracker [1] by Dan Rosenberg: 1. The Ghostscript interpreter fails to properly handle some cases of infinite recursion. By creating a .ps file with a sequence such as: /A{pop 0 A 0} bind def /product A 0 The interpreter's internal stack will be overflowed with recursive calls. Rather than gracefully handling this situation, the interpreter continues execution by jumping to an (usually invalid) address near (or past) the tail end of the stack. Without further manipulation, this would simply result in a segfault, but it turns out that by altering the number of variable definitions that occur before the call to the infinitely recursive procedure, the user can actually exert control over the address that is jumped to. Combined with the fact that the attacker has an easy way to introduce shellcode (via the .ps file), this can definitely result in arbitrary code execution. I have not developed a fully functional exploit for this case, but the attached reproducer ("infinite.ps") will trigger a segfault in the same location on all of the versions of Ghostscript I have tested, including 8.61, 8.62, 8.64, and 8.70. If you wish to more convincingly verify that this is exploitable, place varying amounts of "/A{ 0 } bind def" strings at the beginning of the file, and observe how the EIP at crash time is altered. Unfortunately, the Ghostscript code is rather complex, so I am unable to determine the root cause of this vulnerability in the source. Reproducers are available from the noted bug report. This was reported to Ubuntu in conjunction with the CVE-2010-1869, but it does not have a CVE name as far as I can see. [1] https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/546009
Reported to full-disclosure here: http://seclists.org/fulldisclosure/2010/May/134
This is CVE-2010-1628.
Adding link to upstream bug as comment, URL is easy to miss: http://bugs.ghostscript.com/show_bug.cgi?id=691295
According to upstream bug, this issue was introduced in upstream revision r7694: http://svn.ghostscript.com/viewvc?view=rev&revision=7694 Code changed in r7694 was first introduced in r6706: http://svn.ghostscript.com/viewvc?view=rev&revision=6706 This change is not included in ghostscript packages in Red Hat Enterprise Linux 3, 4 and 5. Upstream fix to correct PostScript stack overflow causing memory corruption: http://svn.ghostscript.com/viewvc?view=rev&revision=11414 Statement: Not vulnerable. This issue did not affect the versions of ghostscript as shipped with Red Hat Enterprise Linux 3, 4, or 5.
Created ghostscript tracking bugs for this issue Affects: fedora-all [bug 614946]
Verified. Tree:rel-eng/RHEL6.0-20100730.5 $ rpm -q ghostscript ghostscript-8.70-6.el6.x86_64 Both of following executions do not crash ghostscript. $ gs infinite.ps $ gs overflow.ps