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?
Asked
Active
Viewed 1.3k times
5

John
- 4,596
- 11
- 37
- 43
-
1Are 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](http://security.stackexchange.com/) :) – Miguel Oct 19 '12 at 21:20
2 Answers
5
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:
a-virus-file.txt.exe
Windows hides by default .exe because it's a known file type.
3
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

Seth
- 1,353
- 1
- 8
- 17
-
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