The answer to the “Can PDFs have viruses in them?” question is yes, which means they can compromise your security, privacy, data, and devices. That said, a PDF is a container rather than a virus in itself; the danger comes from what it carries (scripts, embedded files, and links) and from bugs in the software that opens it. The risk is especially high considering the popularity of the PDF format—its compatibility across platforms and ease of sharing make it a common target.
With that in mind, it’s important that you know how to check if a PDF has a virus and learn how malicious PDF files can harm your system.
In this article, we’ll explore PDF security risks, focusing on how hackers use PDFs to deliver malware, the warning signs of a malicious file, and what to do if you open one. In addition, we’ll offer a few helpful tips on protecting your devices and data from infected PDFs. Let’s begin!
Key Takeaways
- Hackers can exploit PDFs by embedding malicious scripts, exploiting software vulnerabilities, hiding malware in attachments or links, and tricking users through social engineering tactics like spear phishing.
- Signs of a malicious PDF include a suspicious sender or urgent message, mismatched links, strange file behavior, requests to enable content or install software, and unexpected pop-ups that could indicate scareware.
- Opening a malicious PDF can expose you to spyware, ransomware, or data theft, depending on the hacker’s intent; if you suspect infection, disconnect from the internet, scan your device, and change your passwords from a clean device.
- Always scan PDFs for viruses using Windows Security, a trusted antivirus app, or a reputable online scanner like VirusTotal (never upload sensitive documents) before opening them—especially when the source is unknown.
- To protect your devices from malicious PDFs, use a trusted, up-to-date PDF reader or editor, avoid unverified downloads, keep your software updated, and disable JavaScript in your PDF reader to block hidden malicious code.
4 Ways Hackers Exploit PDFs to Deliver Viruses

Hackers exploit PDFs and use them to deliver viruses in several ways, including embedding malicious scripts and active content, exploiting software vulnerabilities, hiding malware in attachments and links, and enabling dangerous content through social engineering.
Let’s explore these more closely to understand how PDFs can carry viruses:
#1. Embedding Malicious Scripts and Active Content
PDFs can have viruses in the form of malicious scripts (usually JavaScript) that turn them into dangerous tools. These small programs can start running when you open the file or interact with it, depending on your reader’s settings. They can cause a number of issues, such as installing malware on your computer, stealing your data, or even giving hackers remote control of your system.
The worst part about a PDF file carrying these viruses is that it can look completely normal, so you often can’t tell it’s dangerous just by looking at it. For this reason, you should only open PDFs from trusted sources.
#2. Exploiting Software Vulnerabilities in PDF Readers
Hackers commonly target PDF reader vulnerabilities, also known as bugs. They look for these weaknesses and craft malicious PDFs to exploit them. For example, when hackers identify a bug, they might write code that triggers it when you open the file.
Simply put, PDFs can have viruses that activate as soon as you open the document if your reader is outdated and unpatched. This allows hackers to manipulate your files and create backdoors for future attacks. Attackers constantly look for such flaws. CISA’s Known Exploited Vulnerabilities catalog, for instance, includes Adobe Acrobat Reader flaws that have been exploited in real attacks.
#3. Hiding Malware in Attachments or Links
Hackers often hide malware in PDFs by embedding files (like a Word document or an executable) or links that look like harmless documents or images. However, if you click on them, you can get redirected to a dangerous website or download malicious content onto your computer. This is one of the major ways PDFs can have viruses like ransomware and spyware.
It’s noteworthy that hackers often disguise these PDFs as invoices, resumes, or other common files to trick you into opening them.
#4. Using Social Engineering to Enable Dangerous Content
PDFs can have viruses that specifically target your personal information. Hackers often use social engineering to design the malicious file to look like something most people would be interested in, like a job offer.
This misleads users into opening a link or allowing permissions, unintentionally activating the virus hidden in the file and giving hackers access to their sensitive data.
That said, this method relies on human error rather than a software bug—and it often works together with the other methods to get a malicious PDF in front of you. In fact, a hacker can tailor their message based on your interests or contacts to make the infected PDF file appear trustworthy. This version of social engineering is known as spear phishing.
Real-World Examples of Malicious PDF Attacks
Can a PDF contain malware in practice? Yes, and two well-documented campaigns show how ordinary-looking PDFs were used to deliver real malware:
- Snake Keylogger (2022). HP Wolf Security researchers found phishing emails with a PDF posing as a remittance invoice. Opening it prompted the reader to open an embedded Word document. If Word’s Protected View was off, that document pulled in an exploit for an old Office bug and installed a keylogger that steals saved credentials, keystrokes, and screenshots, as Threatpost reported.
- STRRAT (2021). Microsoft warned of mass spam sent from compromised email accounts, with what looked like a PDF attachment but was actually an image. Opening it connected to a malicious website and downloaded STRRAT, a remote access trojan that steals saved passwords, runs commands on the infected computer, and fakes ransomware by renaming files with a “.crimson” extension, according to The Record.
Both attacks started with an ordinary-looking attachment, which is why the warning signs and protection tips below matter.
5 Key Signs That Your PDF Might Be Malicious

Now that we know the answer to the question, “Can PDFs have viruses?” let’s look into some key signs your PDF might be malicious.
#1. Suspicious Sender or Urgent Message
A suspicious sender or urgent message is often the clearest sign that a PDF is malicious. Be wary of unexpected attachments, unfamiliar senders, and messages that push you to act fast, such as a “final payment notice” or a job offer you never applied for. Spelling mistakes, mismatched email addresses, and requests for personal or financial details are further red flags.
#2. Mismatched or Suspicious Links
Mismatched or suspicious links are a warning sign because they often lead to credential-stealing pages or malware downloads. Hover over any link in a PDF (or in the email that carried it) before you click. If the address doesn’t match the link text, or it leads to a login page you didn’t ask for, don’t continue.
#3. Unusual File Name, Size, or Behavior
An unusual file name, size, or behavior can signal a malicious PDF. Start with the name: a file called “invoice.pdf.exe” isn’t a PDF but a program disguised with a double extension, so don’t open it. Size can be a clue too, since a simple resume or invoice shouldn’t be hundreds of megabytes, but it isn’t reliable because many malicious PDFs are tiny.
Another red flag is the file’s unusual behavior—if it takes too long to open or keeps crashing your reader, it’s worth treating the file with suspicion, although a corrupted file can cause the same problems.
#4. Requests for Suspicious Permissions
If you try to open a PDF file and see a request asking you to install a piece of software or grant some other suspicious permission (such as “enable content” or “open this embedded file”), you’re probably being targeted by hackers. Following their instructions can open doors for them to exploit your personal information and manipulate your data from afar.
#5. Unexpected Pop-Ups
Getting unexpected pop-ups when you open a PDF or visit the page you downloaded it from can be a sign of scareware. This is a type of virus designed to trick you into believing your system is infected and prompt you to visit a dangerous website or install an antivirus program that’s actually malware. Needless to say, if you comply, you’ll allow hackers access to your system and data.
What Happens if You Open a PDF Containing a Virus?
If you open a PDF containing a virus, you’re potentially exposed to various security risks. “Potentially” is the operative word here—merely opening a malicious file doesn’t automatically mean your device will get infected.
In other words, a virus may be coded to attack your system only if you click on a specific image or link where it’s hidden.
Conversely, some malicious PDF files release malware into your device as soon as you view them, usually by exploiting a bug in an outdated PDF reader.
That said, the consequences of interacting with an infected file (or its elements) depend on the hacker’s intention. Some aim to infect your device with spyware to collect your personal information and commit identity theft or fraud. Others have financial motives and use ransomware to get you to pay them to regain control of your device. Still others install a remote access trojan or keylogger that quietly records your keystrokes or gives attackers remote control.
Common Types of Malware in PDFs
The table below shows the most common types of malware that PDFs can deliver:
Malware Type | What It Does | How It Can Reach You Through a PDF |
|---|---|---|
Remote access trojan | Gives attackers hidden control of your device and steals saved passwords | A disguised attachment that downloads it after you open the file |
Spyware and keyloggers | Records keystrokes, screenshots, and credentials for identity theft | Embedded files or links that install it in the background |
Ransomware | Locks or encrypts your files until you pay | Links or embedded files that download it |
Credential-stealing phishing | Collects logins and financial details through fake forms | “Verify your account” or “view document” links inside the PDF |
Scareware | Pushes fake virus alerts to make you install fake antivirus software | Pop-ups or redirects triggered by the PDF or the page it came from |
Whatever the hacker’s intention, if you open a suspicious PDF on your phone or computer, act fast and follow the steps below to limit the damage.
5 Steps to Take If You Already Opened a Malicious PDF
If you already opened a malicious PDF, follow these five steps in order:
- Disconnect from the internet. Turn off Wi-Fi or unplug your network cable so the malware can’t contact the attacker or spread to other devices.
- Run a full antivirus scan. Use Windows Security or another trusted antivirus tool to scan your entire device, not just the PDF, and remove anything it finds.
- Change your passwords from a clean device. Start with your email, banking, and work accounts, and turn on two-factor authentication, since a keylogger may have captured what you typed.
- Back up only clean files. Wait until the scan comes back clean, because backing up too early can copy infected files into your backup.
- Monitor your accounts. Watch bank and card statements for suspicious activity, and ask an IT professional for help if your device still behaves strangely.
4 Tips on How to Protect Yourself From PDF Viruses
To protect your devices from malicious PDFs, you should use a trusted, regularly updated PDF tool, avoid downloading files from random sources, regularly update software, and disable JavaScript in PDF readers.
Let’s look into these methods in more detail:
#1. Use a Trusted PDF Tool
Using a trusted PDF tool is one of the simplest ways to keep your private information and devices safe when opening, editing, or sharing PDF files. Choose a tool from a verified publisher and, if it works online, make sure it uses encryption and deletes your uploads automatically.
One such tool is the pdf.net editor, which allows you to convert other file formats into PDF and vice versa, and edit your files while preventing unauthorized access.

It’s important that the PDF tool you choose regularly updates its software. This can minimize security vulnerabilities and stop hackers from installing viruses and stealing your data.
#2. Avoid Downloading PDFs From Untrusted Sources
When downloading PDFs, make sure they’re coming from reliable sources. More often than not, hackers will try to infect your system by sending you an unsolicited email with a PDF attachment. If you see a sender you don’t recognize, especially in your spam folder, it’s best not to open their message at all. The same goes for PDFs sent through messaging apps like WhatsApp or Telegram, and for “free” e-books or templates from unofficial websites.
That said, you should be wary of a suspicious email, even if it’s sent from someone you know. As previously mentioned, hackers can customize their messages based on your contacts to mislead you into downloading a malicious file. When in doubt, confirm with the sender through a different channel, such as a phone call, before opening the file.
#3. Update Software Regularly to Fix Security Vulnerabilities
Updating software regularly can reduce the number of security vulnerabilities, which are essentially cracks in the system through which hackers slip viruses. Namely, developers release updates to patch the bugs that malicious PDFs exploit, and an outdated PDF reader, browser, or antivirus program won’t include those fixes or may miss new threats before you open an infected file.
That’s why it’s essential to keep your operating system, PDF reader, browser, Microsoft Office, and antivirus software up to date, and to turn on automatic updates where possible.
#4. Disable JavaScript in PDF Readers
Hackers tend to hide malware in JavaScript code within a PDF file, so you should disable JavaScript plug-ins in your PDF reader. This is especially important when you’re opening PDF files from unknown sources—this way, if the document is malicious, it won’t execute destructive JavaScript code.
Keep in mind that some interactive forms and calculators need JavaScript, so you may have to turn it back on temporarily for PDFs you fully trust.
How to Scan a PDF for Viruses
You should always scan a PDF for viruses, especially if you don’t know its source. You can do it on your computer or use an online virus scanner—here’s how:
Scanning a PDF File on Windows
- Open the Windows Security app and go to Virus & threat protection > Scan options.
- Select Custom scan to check a specific file.

- Click Scan now and choose the PDF file you want to scan.
Keep in mind that these steps depend on the version of your operating system.
Scanning a PDF File on Mac
- Open the CleanMyMac app (or another trusted antivirus tool, since macOS’s built-in XProtect works automatically and has no manual scan option).

- Select the Protection option from the sidebar.

- Click Scan to check your Mac for malware, including any PDF you’ve downloaded

Scanning a PDF File for Viruses Online
- Upload the PDF document into a reputable online scanner.
- Start the scanning process.
- Review the results.
Online scanners upload your file to a third party, so don’t scan documents that contain sensitive or confidential information. Also, keep in mind that no scanner catches everything, so a clean result lowers the risk but doesn’t guarantee a PDF is safe.
Final Thoughts
So, can PDFs have viruses? Yes, but a PDF is only as dangerous as what it carries and how you open it. Hackers rely on malicious scripts, embedded files, outdated readers, and convincing messages, so a few habits go a long way: treat unexpected attachments with suspicion, keep your software updated, disable JavaScript when you don’t need it, scan files from unknown sources, and act fast if you do open something suspicious.
Once you know a file is safe, you can protect your own documents too. For example, you can change PDF permissions to control who can edit, copy, or print them.
Can PDFs Have Viruses? FAQs
#1. Are PDFs safer than Word documents?
Neither PDFs nor Word documents are automatically safer. Word files can run macros, while PDFs can run JavaScript and carry embedded files, and both can exploit bugs in the software that opens them.
#2. Can a password-protected or signed PDF still contain a virus?
Yes, a password-protected or digitally signed PDF can still contain a virus. A password only controls who can open or edit a file, and a digital signature only confirms who signed it and that it hasn’t changed since, so neither checks whether the contents are safe. Be extra cautious with unexpected password-protected PDFs, especially if the password arrives in the same message.
#3. Is it safe to preview a PDF in Gmail, Outlook, or Google Drive?
Previewing a PDF in Gmail, Outlook, or Google Drive is generally safer than downloading and opening it on your device. These services usually render the preview on their own servers and many scan attachments for known malware, so scripts in the PDF are unlikely to run on your computer.
Related Articles
Are Online PDF Editors Safe? What Most Users Don’t Know
Is It Safe to Send Documents via Email? Tips for File Protection
How to Protect a PDF From Copying: Step-by-Step Guide (2026)
