|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Security Warning Dialog Box (MSBuild Project File)
In Visual Studio 2005 and later versions, you can customize an MSBuild project file to redefine the build process. Portions of the build process that are defined in the project file are executed at design-time immediately after a project is loaded in the integrated development environment (IDE). The Security Warning dialog box detects customized project files that could present security risks and lets you choose how the IDE should open the project.
There are several reasons why a project file is determined to be a potential security risk. These reasons are:
The project file contains one or more non-standard Import elements.
The project file overrides one or more potentially unsafe targets. For more information on targets, see MSBuild Targets.
The project file overrides one or more potentially unsafe properties. For more information on properties, see MSBuild Properties.
The project file defines one or more potentially unsafe items. For more information on items, see MSBuild Items.
The project file contains one or more UsingTask elements.
Project items are located in a potentially unsafe location.
Non-standard Import Elements
A list of standard .targets files is stored in the registry at HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\MSBuild\SafeImports\. If a project file imports a .targets file that is not stored in the registry, it is determined to be a potential security risk.
Potentially Dangerous Targets
The IDE runs several targets while loading a project. If one of these targets has been overridden in a custom project file, it is recognized as a potential security risk. The targets that the IDE runs while loading a project include the following:
Potentially Dangerous Properties
The following list explains the basic types of potentially dangerous properties:
Properties used in the DependsOn attribute of potentially dangerous targets.
Properties used in the Project attributes of Import elements used in safe .targets files.
Properties used by potentially dangerous targets or their tasks.
Properties that begin with an underscore (_).
There are also special properties used by the IDE to manage potentially dangerous targets, items, and properties. These properties cannot be overridden in a project file. The special properties are the following:
Potentially Dangerous Items
Certain items used by imported .targets files cannot be overridden in a project file. If one or more of these items are overridden, the project is considered a potential security risk.
A custom task can run potentially unsafe code. Therefore, all project files that contain one or more UsingTask elements are considered a potential security risk.
Project Items in Potentially Dangerous Locations
Some items in otherwise safe .targets files use user-defined project properties set their paths. To prevent an item from overwriting an important file, project files that contain item paths that evaluate to one of the following locations or any subdirectories of these locations are considered to be potential security risks unless they are also located in or below the solution file or project file directory:
The root directory of any drive.
The Windows directory, for example, C:\Windows\.
The Program Files directory, for example, C:\Program Files\.