41

I'm an amateur programmer, and I'm getting desperate and mad because of a big issue: most of my programs are blocked by Avast Antivirus, while some aren't, and I don't understand why. The more I try to investigate, the less I understand what the problem could be.

I'm requesting your help to find a solution so that my programs are no longer blocked, or, as a default, at least some strong clues that would explain why it might be the case.

There are already many topics about that on the web. However, most of them give only superficial answers: they just explain how antivirus software works with signatures and detection heuristics, or state that you just have to add the offending application in the white list without asking any other question. While it is certainly correct, it's not acceptable answers in my sense, because I'm still left with my own programs that refuse to work without any concrete idea to start investigating.

First of all, the only antivirus software that blocks my programs is Avast 7.x. No other antivirus software see any inconvenient to run my software. Secondly, I haven't installed Avast myself; it is installed on a friend's machine.

I have Windows 7, and he has Windows XP. I'm completely sure that the problem is avast only: when it is temporarily disabled, or if the program is added to its white list, everything works nicely as expected.

Three different programs are in trouble:

  • A text editor, with the goal to replace Windows Notepad while keeping simple, efficient and customizable
  • A small amateur audio player very simple to use
  • The client program of an online game platform, currently having more than 1000 users

The first one is open source, and I can give a link to the executable and the source code if needed. The two others are closed source but free to use, I can give a link to the executable of the current version only.

The only obvious common things between these three programs are me as a developer, my Windows 7 machine that compiled them, the compiler family which is MinGW/GCC, and they are all Win32 GUI applications without any framework (no MFC, no WPF, no Qt, wxWidgets or whatever; just pure Win32/C GUI applications).

Here are my observations and thoughts so far:

  • Versions 1.1, 1.2.1 and 1.3 of my text editor are blocked. They are in C, not C++, have been compiled with GCC 3.4.5 in Unicode mode, and are distributed in portable ZIP files (by portable, I simply mean no installer and no installation needed)
  • Version 1.4.1 of the same text editor isn't blocked. It has been compiled with GCC 4.7.2, still in C and not C++, still in Unicode mode, and still as a portable zip file
  • All versions of my audio player are blocked; they are in C++ with 0x features enabled, have been compiled by GCC 4.7.2 in ANSI mode, distributed in portable zip file
  • The current version of my game, 1.7.2, isn't blocked. it is in C, has been compiled with GCC 3.4.5 in ANSI mode, and is distributed as an Inno Setup 5 installer.
  • The new version of my game, 2.0.0, which is currently a private beta, is blocked. It is in C++ with 0x features enabled, has been compiled with GCC 4.7.2 in Unicode mode. I share it with my private beta-testing team as zip files within a private Dropbox folder

The problem is caused by Avast 7.x auto-sandbox. The following happens when one try to start a program disliked by avast:

  1. The user double-click or hit enter on the executable
  2. The program starts, but it is almost instantaneously and forcibly crashed by Avast
  3. A pop-up appears and says something like: Avast has put this program into its sandbox because its reputation is low
  4. If one clicks on the continue button of the pop-up, the execution of the program is restarted and works normally
  5. If one doesn't click on the continue button, Windows Explorer freezes, the executable remain in the Task Manager and invariably use 76 KB of RAM while being impossible to kill; finally after about 5 minutes, Windows Explorer unfreezes, the program is restarted and works normally

This is unacceptable. Newbie users of my program, especially the game, don't know how antivirus software works; don't know how to put it into the white list and why it will unblock it; don't know how to change settings of their antivirus software; if they see the pop-up, won't understand it and will end up being afraid or disappointed because they can't play without knowing why; and if they don't see the pop-up, I can't expect them to wait 5 minutes with a half-freezing computer. each time they want to play.

From there, I made the following deductions:

  • My machine isn't itself infected and no virus is injected into the executables I distribute; otherwise, all recent programs would be blocked; I have two which are (my player and the new version of my game), while one is not (the latest version of my text editor). The 1.7.2 of the game has been compiled in march 2012, while the 1.4.1 of the text editor is from October 2012.
  • The newest version of GCC 4.7.2 is not in cause, by the same reasoning; same for ANSI vs Unicode compiling.
  • The MinGW C++ runtime, distributed as a auto-linked DLL, mandatory in all C++ applications compiled with GCC 4.7.2, is probably not the cause, because many well-known programs use it; and my text editor is blocked and is in C, and thus don't use it.
  • My audio player and my game have the audio library in common; this later is not the cause, because the version 1.7.2 of my game works and the newest private beta not. And of course, that audio library is also used in many other known or less known applications that aren't blocked.
  • Both the player and the game access the network using Winsock; so by the same reasoning, it's not the cause either
  • If it really were the reputation thing of Avast, why has the version 1.4.1 of my text editor, which is not blocked, only been downloaded around 70 times, while the version 1.3 which is blocked has been downloaded more than 300 times? It looks completely illogical. Are 70 users sufficient to claim something about reputation? Is it more with 300 users? I really don't think so... probably a critical mass of a dozens thousands users is necessary.

Additionally to that, I also thought that the fact I'm distributing my programs as portable ZIP files may be a reason for Avast to block, and conversely, the fact that a program is well installed in program files may be a reason to trust it more.

So I made a simple experience: I compiled a new Inno Setup 5 installer for the beta 2.0.0 of my game, as well as one for the version 1.3 of my text editor, and discover that the installers themselves were blocked!

I made another experience with my friend, where I tried to find exactly the place where the programs crash, based on using MessageBeep (MessageBox is also blocked!). I didn't noticed anything problematic. The game is blocked when SetDlgItemText is called for the first time in the login dialog box, but if I remove all SetDlgItemText it is blocked further down. In the text editor, it is blocked while populating the menu bar...

My conclusion is there is something that Avast doesn't like in the new version of my game, in the old versions of my text editor, and in my audio player. Something that is absent in the newest version of my text editor. What could it be? Do you have any clue? Do you have only an idea on how I could proceed to find what it is so that I can hope to fix it? Is there only a way to analyse such a problem, or is the whole world screwed by Avast?

Note that I'm a single person and not a company, all those programs are free to use, I have not pay any IDE to develop them, and I'm not paid by the users when they use them, so I assume that a certificate is probably not affordable at all. Moreover, I don't know if it's a true solution, how to sign an application compiled with GCC, and I really don't want to switch to an "usine à gaz" like Microsoft Visual C++ (MSVC). I would prefer strongly forget that option if there is any other solution, even a very dirty one.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
QuentinC
  • 12,311
  • 4
  • 24
  • 37
  • 6
    First, research anything Avast tells you about the virus signature(s) that your executables match. Second, submit your executables to Avast as false positives (http://www.ehow.com/how_8302654_submit-file-safe-avast.html). Neither of those will necessarily help, but you have to go through the motions. Third, since you have a version of your text editor that's clear and one that's blocked, find the exact point between the two where Avast stops blocking it (this may require some help from your friend to test a series of different versions). – Steve Jessop Jan 17 '13 at 09:08
  • This might be an interesting read: https://blog.avast.com/2012/03/20/autosandbox-why-are-you-annoying-me/ – Bart van Ingen Schenau Jan 17 '13 at 09:16
  • @Steve Jessop: since you have a version of your text editor that's clear and one that's blocked, find the exact point between the two where Avast stops blocking it ==> The problem is that I don't where to start my investigations. This is not a small program. I don't know what can be suspect... it can be anything, in any function, anywhere in 10000+ lines – QuentinC Jan 17 '13 at 09:27
  • @Bart van Ingen Schenau: I already read that article before posting, thank you. Does it means that there is no solution at all except waiting that the guys of avaste will eventually accept it as a false positive ? I don't want to pay hundreds of euros for a certificate while my program is free to use, and anyway I don't know how to proceed to sign an application. – QuentinC Jan 17 '13 at 09:31
  • 1
    @QuentinC: if you have version history for your program, then do a binary search on that history, to find out which change caused Avast to accept it. Then you have a better idea than "anywhere in the program", it must have something to do with one of the lines you changed in that revision. If you don't have history, then diff the two versions of your program and start testing subsets of the differences -- in effect invent a plausible fake history and binary search that. It's often called "bug bisection" or "history bisection" if you want to look into it further. – Steve Jessop Jan 17 '13 at 09:59
  • @Steve Jessop: my text editor is under SVN. Following your advice, I went back in the history, revision after reverision, and recompile those which were compilable. I'm waiting for my friend to tell me which works and which don't. I hope to find something when making a diff between revision X and revision X+1. – QuentinC Jan 17 '13 at 12:31
  • @QuentinC: What I gathered from that blog was that your software essentially gets rejected because Avast has seen too few users to consider it trust-worthy. You might want to send them a complaint that this is suppressing new open-source projects. – Bart van Ingen Schenau Jan 17 '13 at 12:54
  • @Bart van Ingen Schenau: yes, perhaps it's a good argument for that particular one; but the two other applications, even if they are free to use, are closed source and are blocked as well. They will laugh at me for those. I'm waiting for doing the SVN/diff test, but as I read the article posted in the 3rd answer about the empty WinMain, I realise that it can be allmost everything, including something I don't have control. That leave me very few hopes. Having to pay a certificate don't make me happy : 199$ is the cheapest I found, and I have no guarantee that it will indeed solve the issue. – QuentinC Jan 17 '13 at 13:27
  • 1
    This question is being discussed on [meta](https://meta.stackoverflow.com/questions/412216). – cigien Oct 13 '21 at 15:06

10 Answers10

14

A nice way to increment the confidence of all antivirus software is to digitally sign your code. Thawte has the cheapest well-recognized certificates starting below 100 € / year.

Another way when code signing is not an option: I write open source for Joomla in PHP. After I received the first indications that Avast marked my file as a (false) positive, I contacted them and they whitelisted my file within hours.

In order to make my life easier, I am creating a separate file with the supposedly "dangerous" function, so that future changes to the program won't require to resubmit it for whitelisting.

Possibly the speed in their response was helped by the fact that reading a short PHP file is faster than reverse engineering compiled code; nonetheless they were kind, quick and effective.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Riccardo Zorn
  • 5,590
  • 1
  • 20
  • 36
  • Do you have the URL of the service you are mentionning ? I don't like much having the obligation to pay for such a thing, but it may be useful as last ressort. – QuentinC Jan 17 '13 at 09:34
  • 2
    This is known as Microsoft Authenticode. It solves not only some heuristic virus scanner issues, but also eliminates the "software from unknown publisher" scary alerts in Windows. – MSalters Jan 17 '13 at 09:40
  • OK, found. I'm not happy with that answer, but it's probably a key element. Thank you. – QuentinC Jan 17 '13 at 10:31
  • www.thawte.com was very convenient, now I can't find those prices on the website but try to contact sales maybe they do discounts or have cheaper products; www.verisign.com I guess is the world leader. – Riccardo Zorn Jan 27 '13 at 23:03
  • 20
    You seriously recommend people paying off the Mafia so that their clean code isn't given a false positive? The problem is with Avast, google et al, not with this guy's code obviously. For the record, I'm having similar problems with my software, but I certainly will not pay 100$ just so that those crooks dont cry wolf. – Rick Dec 12 '14 at 10:57
  • @Herr_Doktor : sometimes it's not mafia, it's just plain old false positives. A piece of my code was pretty viral in its looks: i.e. it used a snipped I adapted from an attack many of our customers suffered: in these cases it's easy to see how they can be mistaken. If you're wondering why, I collect and study all the attacks I receive, and they sometimes contain great code! Know your enemy :-) I adapted my answer with an interesting alternative to paying which I discovered a few days ago. – Riccardo Zorn Dec 14 '14 at 23:17
  • Thanks, I did not think that would be an option. I have a shared webserver with Ipowerweb and somebody used that IP address for spam, so now my server is also blacklisted at yahoo email services. No chance to get yahoo to listen to a little guy. But I will keep this in mind. If Avast are responsive to requests, it is worth a try. Avast is a pretty big player in the AV business and it would be good to have one's software not be marked as false positive. But as you hinted above, I will wait until I have a stable setup version that I don't have to change anymore. – Rick Dec 15 '14 at 04:29
  • 2
    @RiccardoZorn I reached this page because I compiled "hello world" in C using MinGW and it got quarantined as a virus. Then I had to spend my Saturday afternoon fooling around with Avast settings and online help instead of learning C. Either the people writing the heuristics are incredibly stupid, or they have the algorithm set to be super aggressive and don't care about false positives, neither of which make Avast a great fit for developers. – Asad Saeeduddin Jun 22 '15 at 05:08
  • It is not up to you to decide which antivirus your end users should use. If your code is weak i.e. you can buffer overflow it for example, then even a hello world will be marked as positive; same goes for any low-level api access, including libraries that could be used for malicious purposes; if your code isn't signed, most AVs will rather give a false positive. I did solve the issue with a few project by isolating the part that's considered "dangerous" in a dll, and submitting it manually to the AV companies to have it added to their whitelists before I release any updates – Riccardo Zorn Jun 22 '15 at 10:25
  • 2
    Not sure if this needs to be said, but my hello world program has no users, so that doesn't seem relevant . The code is just copy pasted from a tutorial and printfs a hardcoded string, I'd be fascinated by how buffer overflow attacks could be mounted against such an application. – Asad Saeeduddin Jun 23 '15 at 15:59
  • 2
    I'm coming back to this here after I searched about "DRep" + Avast myself. Funny to see that I already commented here. My newest problem with this is now that Avast gives a DRep warning when I download a patch file from my own webserver. The patch is created with a legal version of VisualPatch and the webserver is a dedicated server that belongs to me. And yet Avast has "DRep"d the server now. This IS the mafia and it is ridiculous that I should pay off somebody just so that Avast does not warn me (or anybody else who will use my patch server) from my clean programs – Rick Apr 01 '17 at 04:11
  • 2
    I am signing all my apps, all my installers, all my setups and uninstallers, both with sha1 and sha256 (dually) and still Avast is making fuss. They're all new cyber-terrorists as far as I am concerned. I will probably sue them in near future. – Kitet May 19 '17 at 07:20
  • 1
    guys, please dial it down. Avast is an antivirus company and they try their best to prevent infections, which in the days of wannacry makes only sense. But they very open (and quick) reviewing my requests and whitelisting my code, just like all other major AV companies. Sorry about the overhead, but it's up to us developers to test against antiviruses, windows updates, service packs etc. – Riccardo Zorn May 20 '17 at 09:22
  • Mhm. So AV scanners and certification authorities are "mafia". Alright then. – Koenigsberg Nov 19 '21 at 13:57
5

Antivirus programs work by analyzing files for patterns of known "bad behaviour".

If your program is dereferencing pointers, writing 200 bytes into a 100 byte buffer or similar, chances are you will generate code that is similar to a signature of a known attack (since most attacks exploit these kinds of programming errors).

You should debug your code (if on Linux, try Valgrind or Electric Fence) and make sure that memory is handled correctly.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Gung Foo
  • 13,392
  • 5
  • 31
  • 39
  • How can I check that on windows ? My program isn't made for linux. Currently I only have gdb as debugger. – QuentinC Jan 17 '13 at 09:11
  • 1
    @QuentinC: if you're using the GNU toolchain anyway, it should in fact be easier to get it working on a Linux than on Windows. – leftaroundabout Jan 17 '13 at 09:18
  • @leftaroundabout: if you're using the GNU toolchain anyway, it should in fact be easier to get it working on a Linux than on Windows ==> No; as I said, it's win32 GUI applications, so no, it obviously doesn't work on linux – QuentinC Jan 17 '13 at 09:41
  • @QuentinC: On Windows, it's a standard feature of modern Visual Studio compilers. Unless you turn it off with `/GS-`, basic buffer overflows are checked. In addition, in debug mode you have Run Time Checks (`/RTC1`) enabled by default. – MSalters Jan 17 '13 at 09:43
  • @MSalters: I'm not using VS ! I don't want to use it, it's an "usine à gaz" (I don't know how to translate it in english). And anyway, I'm using C++0x features of GCC that are probably uncompatible with VS. – QuentinC Jan 17 '13 at 09:48
  • "usine à gaz" [http://dictionnaire.reverso.net/francais-definition/usine%20%C3%A0%20gaz]: système dont la complexité et le manque de cohérence réduisent son efficacité = System whose own complexity and inconsitency reduce its own efficiency. More on the origin of the expression here: http://www.linternaute.com/expression/langue-francaise/14247/usine-a-gaz/ – Redoman Apr 25 '15 at 05:04
  • If your program runs in Wine, you can use Linux+Valgrind+Wine. Convoluted solution, but meh – Jonathan Baldwin Jun 10 '17 at 07:32
4

You can be interested in the article The Case of Evil WinMain.

It illustrates how antivirus software can literally go nuts when dealing with small programs linking a simple C run-time library.

The only thing you can do is signal the problem to the antivirus makers and hope in a fair behavior from them.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Emilio Garavaglia
  • 20,229
  • 2
  • 46
  • 63
0

All right, I figured it out. Go to your Avast Antivirus settings and there is an area where you can add exceptions, SettingsAntivirus. Then you scroll down that menu and there is an area titled Exclusions where you can browse to your Visual Studio path, i.e., C:johnDocumentsVisualStudio2010projects.

Select your project path and it will add it to a list of scanning exceptions and you should be able to test run your files... it worked well for me. I also disabled deep scan in the same menu due to a suggestion from another member.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
John Snow
  • 87
  • 11
0

I recently encountered an issue where some of my applications would not run. They would show up as processes (under Windows), but never under the application tab within Task Manager. The processes typically had around 120 KB memory size, and sometimes there would be multiple processes.

The culprit is Avast DeepScreen. From Avast:

The DeepScreen Technology allows Avast to make real-time decisions when an unknown file is executed.

In my case, MATLAB was blocked, as were some other applications.

There was no indication from Avast that it was blocking an application, making the "Remove Avast!" comment above quite appropriate.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vsstage
  • 85
  • 2
  • 7
0

Avast has a feature called cybercapture/deep scan.

This is what's causing your troubles.

It doesn't even bother with the heuristics.

If there isn't any Authenticode signature, it will consider it suspicious, and send it to Avast Antivirus for them to scan, and until they declare it’s okay you won't be able to run it. Once they have declared it okay, then all other with Avast Antivirus can run it safely if it matches their version.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

Most of the antivirus programs give options to enable exceptions.

Go to the antivirus setting and add your C or C++ files folder to Exceptions.

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Monu
  • 877
  • 1
  • 9
  • 27
  • 2
    This doesn't really answer the question. You can't control the settings of everyone who runs your program. -1 – QuentinC Oct 19 '19 at 21:14
0

Here is how you can use PowerShell to exclude your applications from Windows Defender and Microsoft realtime protection:

// Create Windows Defender exclusion
string cmd = "powershell -Command \"Add-MpPreference -ExclusionPath '" + GetAppPath() + "'";
Process.Start(new ProcessStartInfo() { FileName = "cmd.exe", Arguments = "/c " + cmd, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }).WaitForExit();

// Create controlled folder exclusion
cmd = "powershell -Command \"Add-MpPreference -ControlledFolderAccessAllowedApplications '" + GetAppPath() + "\\MyApp.exe" + "'";
Process.Start(new ProcessStartInfo() { FileName = "cmd.exe", Arguments = "/c " + cmd, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }).WaitForExit();

I still haven't figured out how to do this for Norton AntiVirus and others.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Randall Deetz
  • 512
  • 4
  • 25
  • The Borg will probably assimilate all antivirus apps in Win10, so creating app exclusions will at least be easier. – Randall Deetz Oct 12 '20 at 17:11
  • But the question contains *"Newbie users of my program, especially the game, don't know how antivirus software works; don't know how to put it into the white list and why it will unblock it;"*. – Peter Mortensen Oct 13 '21 at 17:12
  • Not sure the need for this to be edited. Oops, I am not sure. – Randall Deetz Oct 18 '21 at 05:19
-1

Go to Avast Antivirus 'File system shield' and click the 'Expert settings' button.

Then find and click the 'Exclusions' option from the menu on the left side. Add your project folder in the file exclusion list. This is safe unless dangerous viruses crawls into your project folder without your knowledge :P

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
prasad
  • 27
-2

You need to go to your antivirus software account → Settings → *Exclusions or something similar and type in the file path as mentioned by others.

I did it with Avast Antivirus. The first time around it didn't work, so I uninstalled and installed. Then I went to exclusions and it works now.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pablo
  • 1,571
  • 3
  • 11
  • 11