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

Foxit Reader FileAttachment annotation use-after-free vulnerability

A use-after-free vulnerability in Foxit Reader's JavaScript engine allows a specially crafted PDF to trigger reuse of freed memory, potentially leading to arbitrary code execution. An attacker can exploit this by tricking a user into opening a malicious PDF or visiting a malicious site if the browser plugin is 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 10.1.3.37598. A specially crafted PDF document can trigger the reuse of previously free 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

The annotation object is freed by a page close handler while the annotation creation code is still executing, leading to a use-after-free when the creation code later accesses the freed memory.

Impact

An attacker could potentially execute arbitrary code on the victim's machine by exploiting this use-after-free, though the browser plugin must be enabled and the user must open a malicious file or site.

What the attacker needed

Victim opens a malicious PDF; browser plugin extension enabled

The fix

The vulnerability was fixed by the vendor in a patch released on 2021-05-06.

How it was found

  1. Open a malicious PDF that contains JavaScript to switch to page 1 and add a FileAttachment annotation.
  2. The page switch queues a page close handler for page 0.
  3. The FileAttachment annotation triggers a file chooser dialog, blocking execution.
  4. The page close handler runs and destroys the annotation, freeing its memory.
  5. Dismiss the dialog, causing the annotation creation code to resume and access the freed memory.
  6. This leads to a use-after-free and potential code execution.

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 report describes a memory safety bug in a PDF reader. When a PDF contains JavaScript that creates and then destroys an annotation, the program frees the memory used by that annotation but later tries to use it again. This is called a use-after-free, and an attacker could exploit it 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.