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

Foxit PDF Reader JavaScript Array.includes remote code execution vulnerability

A bug in the V8 JavaScript engine's Array.includes method causes excessive memory allocation when the array length is set to a large value. In Foxit PDF Reader, the resulting out-of-memory exception is caught and execution continues, leading to memory corruption and potential arbitrary code execution.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

High 8.8 View original

An exploitable memory corruption vulnerability exists in the JavaScript engine of Foxit Software’s Foxit PDF Reader, version 9.4.1.16828. A specially crafted PDF document can trigger an out-of-memory condition which isn’t handled properly, 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 the V8 engine's Array.includes implementation uses a strict less-than check against kMaxUInt32 instead of less-than-or-equal, causing it to take a slow path that allocates excessive memory when the array length is exactly kMaxUInt32; Foxit then improperly handles the out-of-memory exception, allowing execution to continue in an undefined state.

Impact

An attacker could achieve arbitrary code execution by tricking a user 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 visits malicious site if plugin enabled

The fix

The V8 engine check should be changed to less-than-or-equal, and Foxit should properly handle the out-of-memory exception; the vendor patched the issue.

How it was found

  1. Create a PDF document with JavaScript that sets Array.prototype.length to 0xffffffff and calls Array.prototype.includes(0).
  2. Include a page open action that triggers the JavaScript when the document is opened.
  3. Open the PDF in Foxit Reader; the JavaScript causes an out-of-memory condition.
  4. Foxit catches the out-of-memory exception and continues rendering the PDF.
  5. JavaScript execution resumes in an undefined state, leading to memory corruption and 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 PDF file can contain JavaScript code that runs when the document is opened. In this case, a bug in the JavaScript engine causes it to use up all available memory. Normally the program would just crash, but Foxit catches the error and keeps going, leaving the engine in a broken state that can be exploited to run malicious 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.