Skip to content
File upload Advisory Intermediate CVE-2023-39542

Foxit Reader Javascript saveAs arbitrary file creation vulnerability

Foxit Reader's JavaScript saveAs method did not validate the file path or type, allowing a malicious PDF to create an HTA file in the Windows Startup folder. When the system restarts, that HTA file executes, leading to arbitrary code execution.

Kamlapati Choubey Follow

Originally disclosed on Cisco Talos

High 8.8 View original

A code execution vulnerability exists in the Javascript saveAs API of Foxit Reader 12.1.3.15356. A specially crafted malformed file can create arbitrary files, which can lead to remote code execution.

Kamlapati Choubey, 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 saveAs method failed to validate the destination path and file type, allowing creation of executable file types in sensitive locations.

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 victim visits malicious site with plugin

How it was found

  1. Create a PDF with JavaScript that calls saveAs to write an HTA file to the Startup folder.
  2. Include an embedded file object with a Filter key so Foxit writes it without encoding.
  3. Open the PDF in Foxit Reader, which creates the HTA file.
  4. On system startup, the HTA file executes and runs the embedded script.

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 reader can run JavaScript to make forms interactive. The saveAs function lets that script save a file, but it did not check where or what type of file was saved. An attacker could use this to drop a harmful file that runs automatically when the computer starts.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

More by Kamlapati Choubey

View all

8 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.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.