Most people think of PDFs as static documents — invoices, contracts, reports. But beneath that clean surface, PDFs support a feature that most users never see: the ability to embed other files inside them. It's a legitimate feature used for attaching supporting documents, but attackers have weaponized it to deliver malware, bypass security filters, and exfiltrate data.

If you're analyzing suspicious PDFs or responsible for securing your organization's document workflow, understanding embedded files is essential. This is one of those attack vectors that flies under the radar because the average user has no idea it exists.

How PDF Embedded Files Work

The PDF specification includes a /Filespec object that lets a PDF contain other files. These embedded files live inside the PDF as named attachments. When you open such a PDF in Adobe Reader or another viewer, you might see a paperclip icon in the sidebar — that's the attachment panel showing files bundled inside.

The embedded file can be just about anything: a Word document, an executable, a ZIP archive, another PDF, or even raw binary data. The PDF specification doesn't restrict file types. A malicious actor can embed a JavaScript file, a PowerShell script, or a compiled executable — then use various triggers to launch it.

What makes this dangerous is that the embedded file often bypasses traditional email filters and perimeter security. The outer PDF passes through as a legitimate document file. Only when it reaches the endpoint and the victim interacts with it does the embedded payload activate.

Common Attack Scenarios

1. The Double-Extension Trick

Attackers embed an executable inside a PDF and name it with a double extension — something like invoice.pdf.exe. When the victim extracts and tries to open the attachment, they unknowingly run the malware. This technique predates PDFs but remains effective, especially against users who don't pay attention to file type warnings.

2. Auto-Launch via Launch Actions

PDFs can contain /Launch actions that automatically execute embedded programs when the document opens. The attacker sets up a Launch action pointing to the embedded executable, and Adobe Reader — depending on version and security settings — may execute it without sufficient warning. This has been patched in recent versions, but older readers remain vulnerable.

3. Embedded JavaScript with File Access

More sophisticated attacks embed JavaScript code that runs when the PDF opens. This script can access the file system, download additional payloads, or manipulate the embedded files. With the right conditions, the JavaScript can extract the embedded executable to the victim's temp folder and run it.

4. Data Exfiltration

It's not always about delivering malware inward. Attackers also use embedded files for data theft. A compromised PDF can capture local files, embed them as hidden attachments, and attempt to send them out — essentially using the PDF as a smuggling container for stolen data.

How to Detect Embedded Files in PDFs

Using pdfid.py

The first tool in your arsenal is Didier Stevens's pdfid.py. Run it against any suspicious PDF and look for the /EmbeddedFiles count:

pdfid.py suspicious.pdf

If you see /EmbeddedFiles with a value greater than 0, you've got attachments. Normal business PDFs rarely embed files — an invoice or contract almost never needs one. An unexpected embedded file is a red flag.

Using peepdf

For deeper analysis, peepdf lets you explore the embedded file structure interactively. Load the PDF and use commands like embedded_files to list what's inside. You can extract any embedded file directly for analysis:

peepdf -f suspicious.pdf
> embedded_files
> extract embedded_file_0 output.bin

Using pdf-parser.py

pdf-parser.py from the same toolkit helps you search for /Filespec objects directly. These objects define the embedded files and contain metadata like the filename and MIME type. Look for patterns like:

pdf-parser.py -s Filespec suspicious.pdf

Real-World Example: The Invoice Trap

Here's a scenario security teams encounter regularly: you receive an email with a PDF attachment claiming to be an overdue invoice. The email looks urgent — past due notice, action required, the usual pressure tactics.

You open the PDF. It looks like a standard invoice. Maybe there's a notice at the bottom saying "Open the attached document for details." You see a paperclip icon. Clicking it reveals "invoice_details.pdf" embedded inside.

You extract and open that attachment, not realizing it's actually an executable renamed to look like a PDF. The moment you try to open it, malware executes — and your endpoint is compromised.

This exact pattern has been used in countless phishing campaigns. The outer PDF serves as social engineering bait, making the victim feel like they're being reasonable by "safely" opening a PDF rather than clicking a suspicious link. The embedded file does the damage.

Defense Strategies

Disable PDF embedding at the endpoint. Most users don't need to handle embedded files. Configure Adobe Reader and other PDF viewers to block automatic launching of embedded content.

Use advanced email filtering. Some modern security solutions can unpack PDFs and scan embedded attachments before delivery. This adds a layer of protection at the mail gateway.

Patch PDF readers aggressively. Adobe Reader and other viewers release frequent security patches. Keep them updated — many of the launched action vulnerabilities have been fixed in recent versions.

Educate users on file attachments. Train your team to treat any unexpected attachment with suspicion, regardless of file type. If someone receives an unexpected PDF with embedded files, that's a signal to escalate to security.

Analyze suspicious files in a sandbox. When in doubt, open PDFs in a controlled environment — a virtual machine or sandbox — where any malicious payload can't reach production systems.

Final Thoughts

PDF embedded files represent a real and often overlooked attack surface. Most security awareness training focuses on malicious links and macro-enabled Office documents. But PDFs have their own attachment mechanism, and it's just as dangerous when abused.

The good news is that detecting embedded files is straightforward with the right tools. pdfid, peepdf, and pdf-parser are free, well-documented, and part of any solid PDF forensics workflow. Add embedded file checks to your document inspection process, and you'll catch attacks that slip past traditional signature-based detection.

Stay suspicious. Stay sharp.