Skip to content
Memory corruption Advisory Advanced CVE-2018-3940

Foxit PDF Reader Javascript removeDataObject Remote Code Execution Vulnerability

A use-after-free flaw in Foxit PDF Reader's JavaScript engine lets a crafted PDF close the active document while a method call is still running, so the method reuses freed memory. An attacker who gets a victim to open the file, or visits a malicious site with the browser plugin enabled, could run arbitrary code.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

High 8.0 View original

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.

Aleksandar Nikolic, on Cisco Talos

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 removeDataObject method calls a user-supplied toString function that can close the document and free objects, after which the method keeps using a stale reference to freed memory.

Impact

An attacker could achieve arbitrary code execution, though the victim must open a malicious file or, with the browser plugin enabled, visit a malicious site.

What the attacker needed

Victim opens a crafted PDF; or browser plugin enabled and victim visits a site

The fix

The vendor patched the issue, presumably by keeping the object alive or re-checking it after the callback runs.

How it was found

  1. Create a PDF with embedded JavaScript that defines an object whose toString method closes the active document.
  2. Call removeDataObject on the active document, passing that object as the argument.
  3. Open the PDF in Foxit Reader; the toString call closes the document and frees objects.
  4. The method continues and dereferences the freed object, causing an access violation.

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 programs written in JavaScript, the same language many websites use. This reader frees the memory holding a document when the document is closed, but a running function can still try to use that memory afterwards, which is called a use-after-free. Because the freed memory can be filled with attacker-chosen values, the program may then run the attacker's 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.

More by Aleksandar Nikolic

View all

147 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.