Foxit PDF Reader JavaScript this.event.target Remote Code Execution Vulnerability
A use-after-free flaw in Foxit PDF Reader's JavaScript engine lets a crafted PDF close the document and then touch a freed event target object. An attacker who gets the victim to open the file could run arbitrary code.
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 JavaScript engine keeps a reference to this.event.target after closeDoc frees the document's objects, and later dereferences it without checking that it is still valid.
Impact
If the freed memory is placed under attacker control, a double dereference could lead to control over the called address and thus arbitrary code execution; the closeDoc call needs higher privileges, so the document must come from a trusted location or the user must approve a dialog, and the browser plugin offers another route.
What the attacker needed
Victim opens a crafted PDF; script runs (trusted location or dialog); browser plugin enabled for web route
The fix
The vendor patched the issue in version released on 2018-09-28.
How it was found
- Create a PDF with embedded JavaScript that defines a function which closes the active document and then modifies the toString method of this.event.target.
- Call that function so the document closes and the freed object is reused.
- Open the PDF in the affected reader, allowing the script to run, and observe the crash from the freed memory access.
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 scripts, and this reader runs them. The script closes the document, which frees memory, but the script keeps using a reference to an object that no longer exists. That is a use-after-free: the program reads memory it has already given back, and an attacker who can fill that memory can steer the program into running their 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.