Skip to content
Memory corruption Advisory Advanced CVE-2019-5130

Foxit PDF Reader Javascript createTemplate Invalid Page Code Execution Vulnerability

A use-after-free flaw in Foxit PDF Reader's JavaScript template handling allows a crafted PDF to trigger reuse of freed memory, potentially leading to arbitrary code execution. An attacker must convince the user to open a malicious file or visit 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 Foxit PDF Reader version 9.7.0.29435. 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

Likely improper validation of parameters in the createTemplate and removeTemplate JavaScript methods allows a sequence of calls that frees an object still referenced, leading to use-after-free.

Impact

By controlling the freed memory, an attacker could potentially achieve arbitrary code execution, though the report only demonstrates a crash.

What the attacker needed

Victim opens a malicious PDF; or visits a malicious site if plugin enabled

How it was found

  1. Call createTemplate with an undefined name, which succeeds and creates a template with undefined name.
  2. Call removeTemplate with an empty string, which succeeds.
  3. Call createTemplate with a valid page number to allocate an object.
  4. Call createTemplate with an invalid page number (-1) to free the object.
  5. Call createTemplate with an invalid page number (-1) again to reuse the 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 a piece of memory but then keeps using it, like deleting a file and then trying to open it. Here, a sequence of JavaScript calls in a PDF makes the reader free an object and then use it again, which can crash the program or let an attacker run their own code. The attacker needs the victim to open a malicious PDF or visit a malicious website.

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.