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

Foxit PDF Reader JavaScript getPageBox remote code execution vulnerability

Foxit PDF Reader's JavaScript engine contained a use-after-free: a crafted PDF could close the document from inside a callback invoked by the getPageBox method, leaving a stale reference that was then reused. An attacker who convinced a user to open the file, or to visit a malicious site with the browser plugin enabled, could potentially 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 getPageBox method called a user-supplied toString callback that could close the document and free objects, then continued using a reference to the freed object without checking it was still valid.

Impact

A specially crafted PDF could lead to arbitrary code execution, but the attacker must first persuade the victim to open the file, or to visit a malicious site if the browser plugin is enabled.

What the attacker needed

Victim opens a crafted PDF; or visits a malicious site with the plugin on

The fix

The vendor patched the issue, presumably by keeping the document and its objects alive while getPageBox runs or by validating the reference before reuse.

How it was found

  1. Create a JavaScript object and replace its toString method with a function that closes the active document.
  2. Call getPageBox on the active document, passing the crafted object as an argument.
  3. The reader invokes toString, which closes the document and frees memory.
  4. getPageBox resumes and dereferences the freed object, causing a crash that can be steered towards 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 PDF can contain small programs written in JavaScript, the same language many websites use. This reader let such a program close the document while a built-in function was still running, so the function later used memory that had already been handed back, like reading a note after the pad it was written on has been reused. Because the attacker can influence what now sits in that memory, the program could be made to run the attacker's 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.

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.