A quick look within the recent PDF zero day
December 29, 2009 at 1:27 pm
The recent PDF Javascript zero-day (CVE-2009-4324) vulnerability has been making quite some noise lately – both in the media and in the wild. The nature of the vulnerability exploited by the samples in the wild is now clearer: It is a use-after-free vulnerability. Here is a peek at the vulnerable code, to provide a base for future research and mitigation.
The incriminated code handling the “doc.media” object is in the file “plugins\Multimedia.api”; here, when function “newPlayer()” is being called, a block of 0×4C bytes is allocated on the heap, at the first address highlighted in red on figure 1 below:
Then it goes to free this 0×4C bytes long block – as can be seen on figure 2 below – because of the unexpected input fed by the malicious Javascript code.
However, when the Javascript interpretation ends (normally, or because of any other actions bringing the same effect, such as “util.printd()” in the sample), the memory of this freed block is used again:
As we can see on figure 3, the first pointer in the previously-freed block is stored in edx for the purpose of being used as a vtable pointer (aka vpointer). Then, the function at index 0×04 in the vtable is called (highlighted address on Figure 3). In other words, the EIP is set to [[lpBlock] + 4].
Therefore, successful exploitation lays in the attacker’s ability to control the first DWORD value in the block, so as to have it point to his/her own crafted “vtable”, and branch to his/her own “vfunction” (the shellcode). The easiest way we can think of to achieve this is to insert some PDF Javascripts; this hopefully will reallocate memory at the same spot as the freed block, because the Javascript engine uses the same heap. This is the approach implemented in the sample seen in the wild.
As the vendor’s patch is currently planned to be available on January 12, 2010 after Christmas and New Year, Fortinet customers should ensure that your IPS and AV definitions are up-to-date, we released updates to detect the exploits on Dec 15th, 2009 (more details can be found in our FortiGuard Advisory FGA-2009-47).
Guillaume Lovet contributed to this post



Twitter
FaceBook
LinkedIn
YouTube