Foxit Reader deletePages Field Calculate use-after-free vulnerability
A use-after-free vulnerability in Foxit Reader's JavaScript engine allows a crafted PDF to free objects associated with pages and then reuse the freed memory, potentially leading to arbitrary code execution. An attacker could exploit this by tricking a user into opening a malicious PDF or visiting a malicious site if the browser plugin is enabled.
Originally disclosed on Cisco Talos
A use-after-free vulnerability exists in the JavaScript engine of Foxit Software’s PDF Reader, version 12.0.1.12430. By prematurely deleting objects associated with pages, a specially-crafted PDF document can trigger the reuse of previously freed memory, which can lead to 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 frees objects associated with pages when deletePages is called, but a subsequent setFocus call queued in the event loop later accesses those freed objects, causing a use-after-free.
Impact
This could lead to arbitrary code execution, and exploitation is possible if a user opens a malicious PDF or visits a malicious site with the browser plugin enabled.
What the attacker needed
Victim opens a malicious PDF; or victim visits a malicious site with plugin
The fix
The vulnerability was fixed in a vendor patch release.
How it was found
- Create a PDF with a text field that has a Calculate action set to a function that calls deletePages twice and setFocus on another field.
- Trigger the Calculate action by calling setFocus on a different field.
- The action frees page-related objects and queues a setFocus call.
- After the event handler returns, the queued setFocus accesses freed memory, causing a crash or potential 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 bug happens when a program frees some memory but then keeps using it, like deleting a file and then trying to open it. In this case, Foxit Reader's JavaScript engine frees objects when pages are deleted, but then later tries to use them, which can let an attacker take control of the program. The attacker needs to convince a victim to open a malicious PDF file.
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.