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

Foxit PDF Reader Javascript createTemplate nPage Remote Code Execution Vulnerability

A use-after-free vulnerability in Foxit PDF Reader's JavaScript engine allows a crafted PDF to execute arbitrary code when the user opens it. An attacker can trick the user into opening a malicious file or visiting a malicious site if the browser plugin is enabled.

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 createTemplate method calls the toString method of its argument, which can close the document and free objects, and then continues to use a stale reference to a freed object.

Impact

An attacker could execute arbitrary code on the victim's machine by tricking them into opening a malicious PDF or visiting a malicious site if the browser plugin is enabled.

What the attacker needed

Victim opens malicious PDF; or victim visits malicious site (plugin enabled)

How it was found

  1. Create a PDF with embedded JavaScript that defines an object with a custom toString method.
  2. The toString method closes the active document, freeing memory.
  3. Call createTemplate on the active document with that object as argument.
  4. The createTemplate method invokes toString, closing the document, then continues and uses a freed object, causing a crash.

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 happens when a program frees memory but keeps using it, letting an attacker control what happens next. Here, a malicious PDF can close itself while JavaScript is still running, causing the program to use freed memory and potentially run the attacker's code. The attacker just needs the victim to open the PDF or visit a malicious site with the browser plugin.

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.