Open Bug 488672 Opened 11 years ago Updated 9 years ago

Downloaded file disappears after scanning for viruses

Categories

(Toolkit :: Downloads API, defect, major)

x86
Windows Vista
defect
Not set
major

Tracking

()

UNCONFIRMED

People

(Reporter: xit090416, Unassigned)

References

(Blocks 1 open bug, )

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.5) Gecko/200812122 Firefox/3.0.5

Any file that I download gets deleted automatically when "Scanning for viruses" completes. I can actually see this happening if I look in the target folder. At the start of downloading you see the filename created and another file with the same name and PART extension. When the download completes the PART file is deleted, leaving just the downloaded file. Then the virus scan starts. When this completes you see the file get deleted automatically from the target folder.

If I turn off automatic virus scanning using browser.download.manager.scanWhenDone=FALSE, then everything is OK again. 

I'm using AVG Anti Virus V7.5. Needless to say, there is no actual virus in the file when I scan the file explicitly with AVG.

It seems I'm not the only one to experience this problem. I found lots of similar reports on the net and in the Mozillazine forum. 

Reproducible: Always

Steps to Reproduce:
1. Download any file.
2. Observe the contents of the target folder in another window.

Actual Results:  
1. When you start the download two files are created - file.exe and file.exe.PART
2. Download completes. You see just file.exe
3. Scanning for viruses starts. You still see file.exe
4. Scanning for viruses completes. You see file.exe disappear and a status box pops up at the bottom of the screen saying download complete.

Expected Results:  
You get the file you wanted file.exe
Component: General → Download Manager
Product: Firefox → Toolkit
QA Contact: general → download.manager
This is similar to bug 427258, but different. In that case the user had manually removed some AV components (Windows Defender) and left garbage in the registry. I have not removed anything. I have a supposedly clean installation of AVG. It's also similar to bug 478020.

In both cases there was no proper fix. The user managed to find a workaround and lost interest. The bug is still there. It's only the most dedicated power user that wants to mess around changing obscure config and registry entries. If Firefox screws up and deletes your file, it should at least tell you that it's done it. Not report "Download complete".
I bumped this up to Major. Users affected cannot download *any* files and there's no error message to show what's happened. I'm disappointed that nothing's happened since April.
Severity: normal → major
>Firefox screws up and deletes your file
that doesn't seem to be a true statement, the AV Scanner deleted the file.
Hi Matti. Thanks for your comment. I don't have the tools to investigate exactly what happens. But I don't think it is the AV program that deletes the file. The reasons are ...

1. The downloaded file does *not* contain any virus. This bug happens with *every* file I download on the affected system.
2. AVG is installed correctly as far as I know. It will scan the file without any problem if you invoke it directly. 
3. When the file is deleted there is no error message from AVG to say that it has found a problem with the file. 

The problem seems to be where the AV program returns control to FF. How does FF interpret the results? What does FF do with the file if it thinks there has been an error? What error message does FF display in such a case?

I think some further investigation is needed in this area.
1 and 2) doesn't matter.

It works with most systems and issues that files are disappearing are very very rare. that means that it must be your AV software and it doesn't matter if the file is without virus or that it works if if you invoke it directly.

Firefox is using the official Windows API for virusscans and the AV software must support it and must itself register as API handler.

>What does FF do with the file if it thinks there has been an error?
There is no way for an error on the Firefox side.
http://msdn.microsoft.com/en-us/library/ms537370(VS.85).aspx

It can only be a bug in the AV Software if FF calls the AV software and the file is gone after that- Very easy to test of you disable the AV Scan via about:config and the file doesn't disappear
Hi Matti. We are making slow progress. Are you in a position to help me with debugging or to walk through the code? I have no skills in this. If not, I will have to try with someone else.

Thanks for the link to the Microsoft API documentation. I notice it says that after you invoke the API the file will still be opened "regardless of the HRESULT value" returned. The HRESULT can be S_OK, S_FALSE or E_FAIL, according to whether it found a virus or not. The important question is what does FF do with these values that are returned to it? Do you have this info? 

FF should check the returned values and respond accordingly. The message "Download complete" is only valid if the result is S_OK.
It can't help you debugging because I'm only a bug triager and I would work on fixing bugs instead of bug triage if i would be in a position to do it.


>The important question is what does FF dowith these values that are returned to it? 

from http://mxr.mozilla.org/mozilla-central/source/toolkit/components/downloads/src/nsDownloadScanner.cpp

>* Both the good and ugly states leave the user with a benign file, so they
>* transition to the finished state. Bad files are sent to the blocked state.
>* The failed and timedout states transition to finished downloads.



>FF should check the returned values and respond accordingly. The message
>"Download complete" is only valid if the result is S_OK.

> // Any failure means the file download/exec will be blocked by the system.
> // S_OK or S_FALSE imply it's ok.
I'd suggest, if you haven't already, upgrading to 3.5 and upgrading your AVG to the latest. (8.5) We've had problems with older versions of AVG exception faulting and removing downloads. I'm not saying that's it but making sure you have all the latest updates would help.
Blocks: 443215
I've done some further testing. I upgraded to FF 3.5.2. I was already using AVG 8.5.408. 

I've now managed to get a trace using Process Monitor. I looked at all operations on the target file during download. There's a lot of stuff happening. But it's *definitely* FF that deletes the file at the end (not the AV program). This happens when Firefox does SetDispositionInformationFile Delete:true. 

To recap on my position ... It may turn out that there is something wrong with the way the AV program(s) are set up on my machine. The problem as I see it is that FF *silently* deletes the file without telling me what it has done. This leaves the user completely in the dark.
Does your win security policy allow you to download files? Check Control panel -> Internet Options -> Internet Settings -> Downloads -> File downloads option. Sounds like your group policy has this option disabled.
(In reply to comment #10)
> Does your win security policy allow you to download files? Check Control panel
> -> Internet Options -> Internet Settings -> Downloads -> File downloads option.
> Sounds like your group policy has this option disabled.

Thinking about it a bit, we did add code to compensate for this so that the download manager would display something in this case, but if you could check this option anyway that would be great.
Hi Jim. I'm not sure exactly which Control Panel settings you mean. I'm running Vista. I looked at Control Panel /Internet Options /Security /Internet. This is set to "medium-high". Under custom level it shows Downloads enabled. 

As I said in my OP, I can download successfully when I turn off virus scanning by setting browser.download.manager.scanWhenDone = FALSE.

Does anyone want to look at the Process Monitor trace?
> Does anyone want to look at the Process Monitor trace?

Sure, that might help.
tenbob0(bug opener), as browser.download.manager.scanWhenDone=false is a workaround of your problem, dup of bug 427258.
Same issue.. I tried 5.0 and Aurora. After I disabled auto-start of AVG services on my workstation, downloads stopped being saved. Spending a few hours with no success was enough for me to uninstall FF altogether. After that, I've found the workaround above (Comment #14), which helped. Major bug, IMO.
You need to log in before you can comment on or make changes to this bug.