Skip to content
Memory corruption Advisory Advanced CVE-2021-21893

Foxit Reader Field OnFocus event use-after-free vulnerability

A use-after-free vulnerability exists in Foxit Reader's JavaScript engine when handling form field events, allowing an attacker to execute arbitrary code by tricking a user into opening a malicious PDF or visiting a malicious site with the browser plugin enabled.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

High 8.8 View original

A use-after-free vulnerability exists in the JavaScript engine of Foxit Software’s PDF Reader, version 11.0.0.49893. A specially crafted PDF document can trigger the reuse of previously freed memory, which can lead to 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 event handler cleanup frees parts of the event.target object while a JavaScript reference to it is still held, leading to a use-after-free when that reference is later accessed.

Impact

This could lead to arbitrary code execution, but the attacker must first trick the user into opening a malicious file or visiting a malicious site with the browser plugin enabled.

What the attacker needed

Victim opens malicious PDF; or victim visits malicious site with plugin

How it was found

  1. Create a PDF with a text field named 'Text Field0'.
  2. Set an OnFocus action on that field that calls a function which assigns event.target to a global object.
  3. Trigger the focus event on the field.
  4. Access the global object after the event handler completes, causing a use-after-free.

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 in a PDF reader. When a PDF contains JavaScript that manipulates form fields, the reader frees some memory but keeps a reference to it. If the attacker can control what gets written into that freed memory, they can 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.