Skip to main content
nikos101
Inspiring
May 8, 2009
Answered

Can ms sql MDF file's contain virus's?

  • May 8, 2009
  • 5 replies
  • 6011 views

HI,

can  ms sql MDF file's contain virus's?

If so how can you check/clean before putting it on your server?

This topic has been closed for replies.
Correct answer BKBK

nikos101 wrote:

can  ms sql MDF file's contain virus's?

Yes.

If so how can you check/clean before putting it on your server?

Install any antivirus software. For example, ClamWin is free, and there is a free version of AVG. Download the latest antivirus definitions for the software.

Scan the MDF files. Viruses usually corrupt the MDF file. So, I wouldn't attempt to restore an infected file to the server, even after it has been cleaned. There are tools available to check the integrity of MDF files, and even to repair them. Search the web.

There are two things you shouldn't do. Neither do a virus scan on an MDF file of a currently running MS SQL instance, nor configure the auto-protect function of your antivirus program to include MS SQL's MDF files.  This is because the antivirus program and MS SQL might contend for the lock on these files. For more on this, see Microsoft's "Guidelines for choosing antivirus software to run on the computers that are running SQL Server"

5 replies

Participating Frequently
May 12, 2010

MDF files as such cannot contain virus. But data which is stored in the tables can contain virus in the form of encrypted javascript or iframe both referencing download of malware on the clients pc accessing the data. It is the result of SQL Injection attacks. Apart from that mdf file cannot contain virus.

Regards

Robert Sharon


BKBK
Community Expert
May 12, 2010
MDF files as such cannot contain virus.

Any binary can contain a virus.

BKBK
BKBKCorrect answer
Community Expert
April 18, 2010

nikos101 wrote:

can  ms sql MDF file's contain virus's?

Yes.

If so how can you check/clean before putting it on your server?

Install any antivirus software. For example, ClamWin is free, and there is a free version of AVG. Download the latest antivirus definitions for the software.

Scan the MDF files. Viruses usually corrupt the MDF file. So, I wouldn't attempt to restore an infected file to the server, even after it has been cleaned. There are tools available to check the integrity of MDF files, and even to repair them. Search the web.

There are two things you shouldn't do. Neither do a virus scan on an MDF file of a currently running MS SQL instance, nor configure the auto-protect function of your antivirus program to include MS SQL's MDF files.  This is because the antivirus program and MS SQL might contend for the lock on these files. For more on this, see Microsoft's "Guidelines for choosing antivirus software to run on the computers that are running SQL Server"

Inspiring
April 18, 2010

In theory one could store a virus-laden file in your DB, in which case it'd end up in your MDF file.  However this would not been the MDF becomes "contagious", because it's not an executable file.  One would need to read the file from the DB, write it to disk (at which point your machine's virus scanner should pick it up anyhow), and then you'd need to execute it.

I'd say the risk of this is very very low.  However virus-scanning the MDF file is an easy and nil-effort thing to do, so why not simply scan the file and make sure?

--

Adam

nikos101
nikos101Author
Inspiring
May 12, 2009

Cheers people, I'm on SQL server.

ilssac
Inspiring
May 8, 2009

Do you perchance mean "MS ACCESS MDF Files"?  As far as I am aware, MS SQL does not use "MDF" files.

Anyway as to viruses, Microsoft Access supports Visual Basic modules and viruses can be written in Visual Basic, so I presume Yes, a MDF file can contain a virus.

How you clean it.... Don't use MS Access for something it is not designed for, even Microsoft recommends not to use Access for Internet applications.

Other then that, I can only suggest asking your question on a Access support channel will probably provide better answers.

May 8, 2009

An .mdf file is what SQL Server uses to store the primary date file. .ldf is the transaction log file. Personally I've never heard of a virus being in an .mdf file but running a virus scanner on them couldn't hurt.