ECE 509 · Fall 2023 · University of Arizona · Team of 4

Malicious PDF Payloads

A course case study of how PDF files are used to deliver attacks, and what stops them. We tested three attack classes in prepared environments and found that reader defaults, patching and the person at the keyboard decide most outcomes.

My role: Lead developer · built and tested the attacks

  • Security
  • Python
  • pypdf
  • Virtual Machines
  • Threat Analysis

Why PDFs

PDF is one of the most widely used document formats, and it can carry embedded JavaScript and embedded files as well as text, which makes it a vehicle for malware delivery, phishing and remote code execution. For our ECE 509 project, my team of four reviewed the research on PDF malware and its detection, then built test documents for three attack classes and opened them in different environments to see what happens in practice. As lead developer, I built and tested the attacks.

At a glance

Course
ECE 509, Fall 2023
Team
Four students
My role
Lead developer
Attacks
Redirects, phishing, embedded payloads
Opened in
Browser PDF viewers, Adobe Acrobat, virtual machines

The work was strictly educational. This page describes what we studied and learned, not how to repeat it.

Three attacks

Three flow diagrams: a user opens a malicious PDF that forwards to a malicious website, prompts for a username and password, or executes an embedded payload
The three attack classes from our report, each starting with a user opening the file.

The first document tries to send the reader to an arbitrary website the moment it is opened. The second shows a dialog asking for a username and password and tries to send them to a remote server. The third carries an executable payload and relies on a known vulnerability in older versions of Windows 10, since patched.

How we tested

We modified sample PDFs with Python and the pypdf library, checked each result in a text editor, and opened it in three kinds of environment: the PDF viewers built into Firefox, Edge and Chrome; a dedicated reader (Adobe Acrobat); and virtual machines that recreate older systems where past vulnerabilities can still be studied.

That makes four experiments, not three: the embedded payload ran twice. The control was a current Windows install with a current Acrobat, where the file type it abuses is now blocked. The real test was an outdated Windows and reader in a virtual machine, the only place the vulnerability still exists.

Flowchart: a PDF file is modified with PyPDF, verified in a text editor, then run in a PDF reader, a virtual machine or a browser
Every test followed the same loop: modify, verify, pick an environment, observe.
Security warning dialog saying the document is trying to connect to a website, with Allow, Block and Cancel buttons and a ticked Remember this action checkbox
The reader asks before a redirect; note the "Remember this action" checkbox.

What happened

Browsers contained it: they run PDFs in a sandbox, many of our test documents did not work there, and redirects were not executed. Acrobat asked first, warning that the document was trying to connect to a server. The risk sits in its settings: those prompts can be disabled, and ticking "Remember this action" applies the choice to that site for all later PDF documents.

Phishing depends on the person: the credential prompt only works if the user fills it in and submits, and it looks suspicious enough that we expected it to be less effective. The embedded payload needed no approval at all, and no setting on the device could stop it until the vulnerability was patched. Flaws like that grow harder to find as software matures, so the common attacks are the simple ones that rely on someone approving a prompt. People are the weakest link.

What stops it

Keep trust prompts on and do not pre-approve connections. The literature describes disabling JavaScript in the reader as effective against unknown vulnerabilities, though skilled attackers may get around it. Keep the reader and operating system current, and rely on the protections it describes: Data Execution Prevention, Address Space Layout Randomization and a sandboxed rendering engine.

Detection runs from signature and pattern matching, through static analysis tools that inspect the file without opening it (such as PDFiD and peePDF), to dynamic analysis that watches it run. One scanner we reviewed, MPScan, combines dynamic JavaScript de-obfuscation with static detection; its authors report detecting 98% of the malicious samples they tested.

What I took from it

Where a file is opened matters as much as what is in it. The same documents were contained by a browser's sandbox and asked permission in a dedicated reader, so any assessment of a document threat has to name the environment it assumes.

A single checkbox can outweigh the code: "Remember this action" turns one approval into a standing permission, so saved trust decisions deserve auditing too. And the defenses split along the lines our tests drew: patching for the attack that needs no click, settings and training for every attack that needs one.

Where it goes next

The natural follow-up would close the loop with the detection side of our review: run our own test documents through static analyzers such as PDFiD and peePDF and see which they flag. The same method would carry over to other formats with active content, such as office files with macros.

Want the details behind this one, or to talk about similar work?