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

Foxit PDF Reader JavaScript getPageRotation remote code execution vulnerability

A use-after-free flaw in Foxit PDF Reader's JavaScript engine lets a crafted PDF close the active document while a method call is still running, leaving a stale reference to freed memory. An attacker who gets a victim to open the file, or visits a malicious site with the browser plugin enabled, could reuse that memory to 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 getPageRotation method calls the argument's toString, which can close the document and free objects, and then continues using a stale reference to freed memory.

Impact

An attacker could achieve arbitrary code execution, but only if the user opens the malicious file or, with the browser plugin enabled, visits a malicious site.

What the attacker needed

Victim opens a crafted PDF; or browser plugin enabled and malicious site

The fix

The vendor patched the issue, though the text does not describe the code change.

How it was found

  1. Create a JavaScript object and override its toString method with a function.
  2. Call getPageRotation on the active document, passing that object as the argument.
  3. In the toString function, close the active document, which frees objects.
  4. Let getPageRotation continue, reusing the freed object and crashing.

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 scripts, and this reader runs them. The bug is that a script can close the document in the middle of another operation, so the program keeps using memory it has already given back. Because the attacker can influence what sits in that reused memory, the program can be made to jump to attacker-chosen 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.