Foxit PDF Reader JavaScript getPageNthWord remote code execution vulnerability
A use-after-free vulnerability in Foxit PDF Reader's JavaScript engine allows an attacker to execute arbitrary code by tricking a user into opening a malicious PDF. The flaw occurs when the getPageNthWord method is called with a crafted object that closes the document during argument conversion, leading to reuse of freed memory.
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 getPageNthWord method does not properly handle the case where the document is closed during the conversion of its argument to a string, resulting in a stale pointer being used after the document's objects are freed.
Impact
An attacker could execute arbitrary code on the victim's machine by convincing them to open a malicious PDF, or by having them visit a malicious site if the browser plugin is enabled.
What the attacker needed
Victim opens a malicious PDF; or visits a malicious site with plugin enabled
The fix
The vulnerability was fixed by the vendor in a later version.
How it was found
- Create a PDF with embedded JavaScript that defines an object with a custom toString method.
- The toString method closes the active document.
- Call getPageNthWord on the active document, passing the crafted object as the second argument.
- Open the PDF in Foxit Reader to trigger the use-after-free.
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.
This report describes a memory safety bug in a PDF reader. When a PDF contains JavaScript, it can run code that closes the document while a function is still using data from it. That leaves the program pointing to memory that has been freed, and an attacker can take advantage of that to run their own 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.