Foxit Reader removeField use-after-free vulnerability
A use-after-free vulnerability exists in Foxit Reader's JavaScript engine when the removeField method is called with an empty string, causing all fields to be removed and memory to be freed. An attacker could exploit this by crafting a malicious PDF that triggers memory corruption, potentially leading to arbitrary code execution.
Originally disclosed on Cisco Talos
A use-after-free vulnerability exists in the JavaScript engine of Foxit Software’s PDF Reader, version 10.1.3.37598. 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
Likely, the removeField method does not properly handle an empty string argument, treating it as a request to remove all fields and free their memory, but the freed memory is later reused within the same event handler.
Impact
This could lead to arbitrary code execution, allowing an attacker to run malicious code on the victim's machine.
What the attacker needed
Victim opens a malicious PDF; or visits a malicious site with plugin enabled
How it was found
- Create a PDF with JavaScript that sets up fields and actions, including a call to removeField with an empty string inside a Calculate event handler.
- Open the PDF in Foxit Reader to trigger the Calculate event.
- The removeField call frees memory associated with fields.
- Subsequent code in the event handler accesses the 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 mishandles a call to removeField with an empty string, freeing memory that is later accessed. An attacker can craft a PDF that exploits this to run their own code on the victim's computer.
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.