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

Foxit PDF Reader JavaScript JSON.Stringify this remote code execution vulnerability

A use-after-free vulnerability in Foxit PDF Reader's JavaScript engine allows an attacker to execute arbitrary code by tricking a user into opening a malicious PDF. The flaw occurs when a document is closed during JavaScript execution and a stale reference is used in JSON.stringify.

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 JavaScript engine allows a document to be closed while script execution continues, and then invoking JSON.stringify on a stale reference to a freed object leads to use-after-free.

Impact

An attacker could execute arbitrary code on the victim's machine by convincing them to open a malicious PDF or visit a malicious site if the browser plugin is enabled.

What the attacker needed

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

The fix

The vulnerability was fixed by the vendor in version 9.1.0.5096? Actually the tested version is 9.1.0.5096 and the timeline shows vendor patched on 2018-09-28, so it was fixed.

How it was found

  1. Create a PDF with embedded JavaScript that defines a function.
  2. In the function, store a reference to the 'this' object.
  3. Close the active document using app.activeDocs[0].closeDoc().
  4. Call JSON.stringify with the stored reference as argument.
  5. Open the PDF in Foxit Reader to trigger the 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.

This is a use-after-free bug, where a program keeps using memory after it has been freed. In Foxit PDF Reader, JavaScript code in a PDF can close the document, freeing memory, but then call a function that still uses that freed memory. An attacker can craft a PDF that exploits this to run their own code on the victim's computer.

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.