Take the 2-minute tour ×

If I'm given a URL that points to a .txt file, is it always safe to open it? Can it possibly contain virus or malicious content?

share|improve this question

closed as off topic by Michael Petrotta, John Watts, Greg Hewgill, Joe, PHeiberg Oct 19 '12 at 21:41


Are you asking as a user? If you are then you're on the wrong forum. If you're asking as a programmer, then I'm no expert on operating systems, but I think it's your responsability to read from the file safely. –  Zecc Oct 19 '12 at 21:19
This isn't really related to programming, so you might want to ask this on Security.SE :) –  Miguel Oct 19 '12 at 21:20
add comment

2 Answers

up vote 3 down vote accepted

A genuine txt-file can contain virus code but it cannot be executed, so it's totally safe. However, a file can use double file extension like this, so watch out:


Windows hides by default .exe because it's a known file type.

share|improve this answer
If it is a URL, why would the extension be hidden? –  Austin Henley Oct 19 '12 at 21:38
add comment

It is not safe to rely solely on a file extension. The real file type can easily be masked by someone changing the extension, so the file could easily be a virus or malicious content.

For example:

MyVirus.exe -> SeeminglyHarmlessFile.txt

share|improve this answer
This answer is rather.. confusing. You should specify, given there are two questions in the OP, not one. –  Daedalus Oct 19 '12 at 21:21
@Daedalus The one question answers the other - since it could contain a virus, it is not always safe to open it. –  Seth Oct 19 '12 at 21:22
Not what I meant; the first question is, 'is it safe to open x', you reply 'absolutely' without specifying which you are replying to. –  Daedalus Oct 19 '12 at 21:23
@Daedalus Clarified. Thanks. –  Seth Oct 19 '12 at 21:24
add comment
