How can downloading a pdf or word file give you a virus?

96 views
0

A pdf file doesnt have any special permissions or anything so i cant think of any way that itd be able to
is viewing a pdf file in chrome completly safe?
how does editing a word document leave you more vulnerable than if you were just viewing it?

In: 4927

> A pdf file

pdf files can be setup in a fillable manner(generally used for forms) meaning it has to use from form of executtion to both read and write into these files(usually javascript that CAN carrry malicious code).

as for word documents, microsoft word at least implements a form of scripting that is normally used to automate tasks inside the application and because its a microsoft product it has some interoperability with the windows OS.

when viewing then online, you are seeing them in protected mode which disables every script the file may have so nothing malicious can execute….unless you allow it to by opening the file for editing

aka: dont open microsoft office files you do not trust the soruce from.

Yes, PDF inside chrome is safe. The rendering library they use is very well tested and secure.

Windows hides file extensions by default (what a bad idea), so if you have a file called `virus.pdf.exe`, Explorer will display it as `virus.pdf` and hide the exe suffix. Exes can have icons inside them, so you can make the exe icon look like the PDF icon. Clicking on it will execute the program and possibly do something terrible to your PC.

There are tricks using a range of unicode features to hide the exe suffix as well.

MS Office documents (word, powerpoint, excel) can have programs hidden inside them (macros written in a variant of VB) which can be used to attack you. Again, this is a mostly terrible idea, but here we are. They are disabled by default for documents downloaded from the web, but people can be tricked into enabling them.

PDFs allow embedded javascript and this can be used to attack your PC if you view the PDF in an insecure program.

**tldr:** computers are very complex and have piles of mostly useless features accumulated over decades, many of which can be repurposed to make you miserable.

PDFs are not just pure documents. For example if they have a signable field it’s using macros that are stored as Javascript code.

This code can be malicious. So your Adobe Reader will run this script if you allow it to and this script can then do harm.

By default you will get a warning if you want to run this code, but plenty of people will just click accept.

You could create a PDF that doesn’t conform to the PDF standard. Your special PDF could exploit a bug in a PDF reader app. Maybe a bug that lets you run code or open a webpage without asking the user when it is fed a specially created file.

Lots of people are talking about Postscript/VB scripts embedded in PDFs and Word documents. That’s one important aspect of it, but not the whole picture. Sometimes even opening an image file (.jpg), displaying just a piece of text, or loading a save file for a game can be dangerous. These are real cases:

– JPG vulnerabilities: [https://umbrella.cisco.com/blog/picture-perfect-how-jpg-exif-data-hides-malware](https://umbrella.cisco.com/blog/picture-perfect-how-jpg-exif-data-hides-malware)

– Text display vulnerabilities: [https://arstechnica.com/information-technology/2015/05/beware-of-the-text-message-that-crashes-iphones/](https://arstechnica.com/information-technology/2015/05/beware-of-the-text-message-that-crashes-iphones/)

– Save game vulnerabilities: [https://wololo.net/2016/05/01/3ds-vhax-released-new-3ds-userland-exploit-for-game-vvvvvv/](https://wololo.net/2016/05/01/3ds-vhax-released-new-3ds-userland-exploit-for-game-vvvvvv/)

These have to do with the fact that the programs used to load those files can have bugs, and files can be specially crafted to exploit such bugs to trigger unexpected behavior, including getting the program or OS to run arbitrary code.

Doc and Pdf files happen to be complicated enough that programs which can open them tend to have a very high number of bugs, so it’s fairly easy to find an exploitable one. But the truth is, nothing is 100% safe no matter how innocent it might feel. This is why security hygiene is the most important. Never trust any files you get from questionable sources.

To see how an exploit might work, imagine a simplified program that looks like:

1: Load the file into slots 3-10.
2: Go to line 11 and continue executing the program from there.
3: (empty slot to hold file content)

10: (empty slot to hold file content)
11: Convert data from slots 3-10 into pixels and display the picture

This assumes the file can only fill 8 slots (#3 through #10). But what if the file is bigger than that, and the program is not careful about limiting its size when loading it? Then after filling up slot 10, it’ll continue writing over slot 11, 12, and so on. The program doesn’t realize this. And when it eventually goes to execute line 11, it’ll be executing arbitrary stuff that was loaded from the file instead of the intended program. This is a classic “buffer overrun” vulnerability. A virus author can make a file such that instructions to encrypt your disk land in slot 11. If you try to open this file, your disk will get encrypted.