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.
Originally disclosed on Cisco Talos
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.
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
- Create a PDF with JavaScript that calls saveAs to write an HTA file to the Startup folder.
- Include an embedded file object with a Filter key so Foxit writes it without encoding.
- Open the PDF in Foxit Reader, which creates the HTA file.
- 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.