Windows Defender Exclusions for SQL Server and IIS: What to Add and What Not To

The two articles already on the site measure what Defender costs and which rules stay safe to write. This one goes after a different question: which exclusions are worth the risk because a specific workload cannot function without them, and which popular ones quietly remove the only layer catching a compromised web shell or a restored malicious database file.

Start with the folder map, not with a list from a blog

Every exclusion set depends on where the workload actually writes. On a default IIS host that means %SystemRoot%\System32\inetsrv, the site root under C:\inetpub, ASP.NET temporary compilation folders under C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files, and the IIS compression and log directories. On SQL Server it means the data, log, backup and Backup\Log folders, plus SQLServer\MSAS*\OLAP\Log if Analysis Services runs on the same box.

Confirm the real paths before typing anything into policy. SELECT SERVERPROPERTY('InstanceDefaultDataPath') and SELECT SERVERPROPERTY('InstanceDefaultLogPath') return the live locations, and Get-WebFilePath from the WebAdministration module resolves an IIS site name to its physical directory. An exclusion pointed at a path that does not exist costs nothing and protects nothing.

The IIS set that is genuinely worth adding

Add the inetsrv directory, the ASP.NET temporary files folder, and the HTTP compression cache. Add the site root only if the application writes to disk on a hot path — uploaded images, generated PDFs, cache files dropped in App_Data. A plain MVC or Web API site that only reads its assemblies does not need the whole inetpub tree excluded, and the earlier piece on Windows VPS hosting covers why directory scope matters more than the number of entries.

The folders that should never appear in this list are the static content root of an application that accepts uploads, and any directory where compiled output lands before the app pool loads it. Excluding an upload directory hands an attacker a clean place to store a web shell; Windows will not scan the file that gets written there, and the next request will happily execute it.

SQL Server folders: where the exclusion stops being optional

A SQL data file is written in 8 KB pages, constantly, with a predictable access pattern. Real-time scanning of an MDF or LDF file adds measurable latency to every checkpoint flush and every log write, and it buys nothing — Defender cannot meaningfully inspect a binary page structure. Exclude the data and log directories, the backup directory, and the SQL Server Binn folder. The documented Microsoft guidance still stands: use the file or folder path, not the process name.

Process exclusions for sqlservr.exe are the one step people take too far. Excluding the process means every file SQL Server touches is unscanned, including any file it reads through OPENROWSET or a linked server import. If the instance ever loads a spreadsheet from an untrusted share, that is an open pipe. Folder exclusions give the same performance result with a tighter blast radius.

The exclusions people add that should be removed

Whole-drive exclusions like D:\ on a data volume show up in nearly every template. They are the fastest way to silence a CPU problem and the slowest way to find out that a restored backup contained something live. The same applies to excluding .zip, .html or .js extensions globally — a very common move after a false positive — which turns off scanning for the exact file types most web attacks use.

Extension exclusions are per-site decisions, not per-server decisions. If one application’s deploy pipeline drops a large archive on a schedule, exclude the drop folder, not the extension. Keep a written record of why each entry exists, because the audit question six months later is always “who added this and what breaks if we remove it.”

Watch what happens after you apply them

Measure before and after with the same baseline. Get-MpComputerStatus shows whether real-time protection is active, and Get-MpPreference | Select ExclusionPath, ExclusionExtension, ExclusionProcess prints exactly what is in force — useful because a group policy can add entries you never typed. For scan cost, Get-WinEvent -LogName "Microsoft-Windows-Windows Defender/Operational" -MaxEvents 50 returns the scan start and stop events with durations.

Expect most of the benefit on a database host and very little on a static IIS box. If removing a file exclusion does not change scan duration in a measurable way, put it back — an exclusion that buys nothing is pure downside.

Pair every exclusion with a compensating control

An exclusion is a gap, so the gap needs a different sensor. On IIS that means request filtering rules in applicationHost.config, file write restrictions on the app pool identity, and a scheduled full scan that does cover the excluded path during a maintenance window. On SQL Server it means a login audit and a restricted set of accounts with sysadmin, because a database host rarely gets compromised through a binary on disk.

Two registry-backed Defender settings matter here. HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths holds the live list, and HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Exclusions\Paths is where policy writes go. When the two disagree, policy wins and the local entry disappears from the effective set — a frequent cause of “my exclusion vanished after a reboot.”

Audit the list on a schedule and keep it short

Review the exclusion set every quarter, or after every major application deployment. Anything added for a migration that finished in the spring should be gone by autumn. Two questions per entry: does the workload still need it, and would removing it cause a visible problem in the next 24 hours. If the answer to the second question is no, remove it.

Keep the list under fifteen entries on a typical combined IIS and SQL host. A short list is auditable, faster to reason about during an incident, and far less likely to contain a path that was spelled correctly in 2023 and points somewhere dangerous now. If the server needs more than that, the workload layout is probably the thing to fix rather than the antivirus configuration.

The whole exercise sits on top of a stable baseline you control. On a Windows VPS where you own the admin account, you can inspect every folder, print the effective exclusion list, and change it back the moment a measurement disagrees — which is the only way to run this comparison honestly.

Leave a Comment