Foxit PDF Reader Javascript removeDataObject Remote Code Execution Vulnerability
A use-after-free flaw in Foxit PDF Reader's JavaScript engine lets a crafted PDF close the active document while a method call is still running, so the method reuses freed memory. An attacker who gets a victim to open the file, or visits a malicious site with the browser plugin enabled, could run arbitrary code.
Originally disclosed on Cisco Talos
An exploitable use-after-free vulnerability exists in the JavaScript engine of Foxit Software’s PDF Reader, version 9.1.0.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 removeDataObject method calls a user-supplied toString function that can close the document and free objects, after which the method keeps using a stale reference to freed memory.
Impact
An attacker could achieve arbitrary code execution, though the victim must open a malicious file or, with the browser plugin enabled, visit a malicious site.
What the attacker needed
Victim opens a crafted PDF; or browser plugin enabled and victim visits a site
The fix
The vendor patched the issue, presumably by keeping the object alive or re-checking it after the callback runs.
How it was found
- Create a PDF with embedded JavaScript that defines an object whose toString method closes the active document.
- Call removeDataObject on the active document, passing that object as the argument.
- Open the PDF in Foxit Reader; the toString call closes the document and frees objects.
- The method continues and dereferences the freed object, causing an access violation.
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 PDF can contain small programs written in JavaScript, the same language many websites use. This reader frees the memory holding a document when the document is closed, but a running function can still try to use that memory afterwards, which is called a use-after-free. Because the freed memory can be filled with attacker-chosen values, the program may then run the attacker's 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.