- ClickOnce Security Overview
- Internet Explorer Security Settings Affecting ClickOnce
- Configuring ClickOnce Security Permissions
- Understanding and Managing Publisher Certificates
- Signing Application Updates
- User Prompting
- Trusted Applications' User Security Policies
- Trusted Publishers' Permission Elevation
- Adding Restricted Code Sections
- Securing the Application Based on User Roles
- Securing Access to ClickOnce Application Files on the Server
- Where Are We?
Trusted Publishers' Permission Elevation
The problem with the default security model for an enterprise environment is that it puts the trust decision of whether to elevate permissions or not into the users' hands. If an application needs elevated permissions, it prompts the users, and if they click the Install button, the application can elevate its permissions all the way to full trust if it wants to, effectively removing the runtime protections that ClickOnce is capable of providing.
This is often not what the IT administrators for the enterprise want—they want to have explicit control over the machines that they are responsible for. Many users do not have the experience to discern a true high-risk scenario from one that is acceptable. From an IT administrator's perspective, an application should not run on a user's desktop unless the administrator has configured it to do so, either directly or implicitly through a trust relationship with the publisher of the application.
There is also a downside to the default prompting model from the users' perspective as well. If they are going to be launching various applications from a known and trusted publisher, why should they be repeatedly prompted when those applications launch the first time? It would be good to let end users establish a trust relationship with a publisher as well to avoid unnecessary prompting.
ClickOnce supports giving the administrators more explicit control and avoiding unnecessary prompting through a model known as trusted publishers. A trusted publisher is a publisher whose certificate has been installed in the Trusted Publishers certificate store on a client machine. This can be done manually using the techniques discussed early in the chapter in the section Understanding and Managing Publisher Certificates, or it can be done automatically through something like Microsoft Systems Management Server or group policy.
If an application is deployed through ClickOnce to the client machine and that application's manifest has been signed by a trusted publisher's certificate, then the runtime can use that to automatically elevate the permissions for the application rather than prompting the user. As a result, the prompting model is actually even more complex than the different levels of prompting discussed in the User Prompting section.
When the ClickOnce runtime determines that a user prompt is required to elevate permissions, it will also check to determine if it is allowed to prompt the user. The settings that drive this decision are based on the zone that the application is being launched from. For each launch zone (My Computer, Local Intranet, Internet, Trusted Sites, Restricted Sites), there is a default setting that says when the runtime is allowed to prompt the user. This setting can take on one of the following values.
- Enabled—The runtime can prompt users if needed to elevate the permissions for the application. However, if the application's publisher is a trusted publisher, then the application will automatically elevate its permissions and users will not be prompted to install the application (i.e., it will be a true ClickOnce application). This is the default value for the My Computer, Local Intranet, Trusted Sites, and Internet zones.
- Authenticode Required—The runtime can prompt users if needed to elevate the application's permissions only if the publisher certificate for the application has a trust chain back to a Trusted Root Certification Authority. If the publisher is unknown, the application will be disabled. If the publisher is a trusted publisher, users will not be prompted to install the application and the permissions will be automatically elevated.
- Disabled—The application can only run if signed by a trusted publisher, in which case the permissions will automatically elevate. With this setting, users will never be prompted and only applications from trusted publishers will be allowed to launch through ClickOnce. This is the default value for the Restricted Sites zone.
If you want to change the default prompting behavior for a given zone, you will have to add a registry key with values set for the zones for which you want to change the defaults. You will need to create a TrustManager key under the HKLM\Software\Microsoft\.NETFramework\Security key, and another key under that named PromptingLevel. Once you have created those keys, you add named string values under the PromptingLevel key for each zone that you want to modify. The name of the key should match the zone name: MyComputer, LocalIntranet, Internet, TrustedSites, or RestrictedSites. The value for the string value should be set to one of the three levels discussed earlier: Enabled, Authenticode Required, or Disabled.
Using these registry settings, you can achieve a much more secure configuration for client machines in an enterprise environment. If you add the named values just described and set them all to Disabled, it means that the only ClickOnce applications that are allowed to run on users' machines are those that are signed by publisher certificates that have been installed in the Trusted Publishers store on those machines. In other words, the only ClickOnce applications that get to run are those for which the administrator established a trust relationship on the client machine with the publisher of the application. When that is the case, the application will download, automatically elevate its permissions to the level needed, and execute. Any application not coming from a trusted publisher will not be allowed to launch through ClickOnce. Figure 6.30 depicts this configuration in the registry.
Figure 6.30 User Prompting Registry Settings