Foxit PDF Reader Javascript MailForm Remote Code Execution Vulnerability
A use-after-free vulnerability in Foxit PDF Reader's JavaScript engine allows an attacker to execute arbitrary code by crafting a PDF that closes the document while a method call is still using freed objects. An attacker could achieve remote code execution if the victim opens the malicious PDF or visits a malicious site with the browser plugin enabled.
Originally disclosed on Cisco Talos
An exploitable use-after-free vulnerability exists in the JavaScript engine of Foxit Software’s Foxit PDF Reader version 9.1.5096. A specially crafted PDF document can trigger a previously freed object in memory to be reused, resulting in arbitrary code execution.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The mailForm method does not properly handle the document being closed during argument conversion, leading to a stale pointer being dereferenced.
Impact
An attacker could execute arbitrary code on the victim's machine, but the victim must open a malicious PDF or visit a malicious site with the browser plugin enabled.
What the attacker needed
Victim opens malicious PDF; or victim visits malicious site with plugin
How it was found
- Create a PDF with embedded JavaScript that defines an array with a custom toString method.
- The toString method calls closeDoc on the active document.
- Call mailForm on the active document with the crafted array as the second argument.
- When mailForm converts the argument to a string, it calls toString, which closes the document and frees objects.
- After returning, mailForm uses a stale pointer, causing a use-after-free.
- Add a heap spray to control the freed memory and achieve code execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A use-after-free happens when a program frees memory but keeps using it, like deleting a file and then trying to open it. Here, a PDF's JavaScript can close the document while a function is still running, so the function later uses memory that has been freed. An attacker can fill that freed memory with their own data to run code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.