Foxit PDF Reader JavaScript getNthFieldName 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 getNthFieldName method is called with a crafted object that closes the document, leaving a stale reference that is later reused.
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.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 getNthFieldName method calls the toString method of its argument, which can close the document and free objects, but the method continues to use a stale reference to a freed object.
Impact
An attacker could execute arbitrary code by tricking a user into opening a malicious PDF, or by visiting a malicious site if the browser plugin is enabled.
What the attacker needed
Victim opens a malicious PDF; or visits a malicious site if plugin enabled
The fix
The vendor patched the vulnerability in version 9.1.0.5096.
How it was found
- Create a PDF with embedded JavaScript that defines an object with a custom toString method.
- The toString method calls closeDoc on the active document.
- Call getNthFieldName with that object as 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 is a use-after-free bug, which happens when a program frees some memory but then keeps using it. In this case, 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 control that freed memory 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.