Home > Articles > Security > Network Security

ClickOnce Security

This chapter is from the book

Configuring ClickOnce Security Permissions

The permissions a ClickOnce application requires to run are determined by its application manifest. These permissions are populated by Visual Studio when you publish your application based on the project properties. You can configure these security permissions on the project properties editor's Security tab. You can also modify them to a certain degree after you have published from Visual Studio using the Mage SDK tools. I'll cover both approaches in this section.

Regardless of which tool you use, you have two choices at the top level—you can request full trust or partial trust. Full trust means that you do not want your application constrained by CAS in any way at runtime on the client. This corresponds to the unrestricted permission set in CAS. When you select this setting, your application code and any code it calls will not be restricted in any way based on CAS. Keep in mind that CAS is separate and distinct from user-based security. So depending on the users' rights, they may still be prevented from doing certain things, either by role-based security code in your application or by the operating system if they try to access something on the system through your application that they do not have Windows access control privileges to use. But as far as ClickOnce and CAS are concerned, if the application has full trust, it can do whatever it likes.

When you choose partial trust, you have to specifically select a set of permissions that you want to include in the requested permissions for the application. You can base this on one of the predefined zone-based permission sets, such as Local Intranet or Internet, or you can use a custom set of permissions to request the specific permissions that correspond to the operations and resources your application uses by design. The latter is a better approach from a security vulnerability perspective.

Whether you use Visual Studio or Mage, what you end up with is a specification inside your application manifest file that says to the runtime, "My application needs these permissions to run."

Configuring ClickOnce Security Permissions with Visual Studio

Figure 6.1 showed the Security tab of the project properties editor. This is where you configure the set of permissions that are placed in your application manifest at the time that you publish your application. Checking the Enable ClickOnce Security Settings checkbox makes the rest of the options available. This box will be checked automatically the first time you publish your application from Visual Studio.

Enabling ClickOnce security settings also affects the way your application runs in the debugger. Once enabled, each time you run your application, the selected security settings will be applied to the debug executable process, so your debug runtime environment will have the same security restrictions as your target environment. For example, if you select Local Intranet as the target zone for partial trust and make no modifications to the permissions list below the partial-trust selection, and then run a debug session and your code tries to do file I/O, you will get an exception in the debugger because the process will run with only the permissions for the Local Intranet zone. This is extremely helpful in debugging and fixing problems that would otherwise only occur in the deployed environment.

If you select partial trust, you can then select the target zone as Local Intranet, Internet, or Custom. Selecting either Local Intranet or Internet selects the permissions in the ClickOnce Security Permissions table to match the target zone. Once those permissions are selected, you can then customize the settings to something different than the defaults for that zone as needed, using the zone permissions as a starting point for a custom set of permissions. Remember that ClickOnce ignores any custom security policy code groups, so setting fine custom permissions through the ClickOnce partial trust settings are the only way to explicitly grant specific permissions in a partial-trust scenario.

So, for example, if you were going to deploy an application to the local Intranet, but the application needed to call a Web service on your network other than the one where the application is being deployed from, you would do the following.

  1. Check the Enable ClickOnce Security Settings checkbox in the project properties editor's Security tab (see Figure 6.4).
    Figure 6.4

    Figure 6.4 Adding Permissions to a Selected Zone

  2. Select This is a partial trust application.
  3. Select Local Intranet in the drop-down list labeled Zone your application will be installed from.
  4. Scroll down in the grid of permissions required by the application to find the WebPermission type.
  5. In the Setting column drop-down list, select Include.

After doing this, your application will request all of the permissions in the Local Intranet zone as well as the WebPermission permission with unrestricted access to the Web.

As mentioned, most permission types have a number of additional options that you can set to customize exactly what options in that permission type you need. WebPermission includes the ability to set a list of URLs that you will let your application either call out to or be called on. Unfortunately, the permissions editor in the Security tab for ClickOnce does not allow you to access all the options for all of the displayed permission types. WebPermission is an example. You can see in Figure 6.4 that the Properties button below the grid is disabled. If there are configurable properties for a selected permission type, this button will be enabled and will take you to a dialog that lets you edit the finer-grained options for that permission type. Figure 6.5 shows an example of one of these dialogs for the SecurityPermission type.

Figure 6.5

Figure 6.5 Options in the Permissions Settings Dialog

There are some permission types that are not shown in the grid at all. The only way to add these permission types is to either select full trust for the application (see Figure 6.4) or use the Mage tool to configure the permission type based on its XML declaration. See the next section for more information on how to do that.

If you do not want to run your debug sessions in the ClickOnce security zone selected, you can disable this capability by doing the following (see Figure 6.4).

  1. Open the project properties editor for your application.
  2. Select the Security tab.
  3. Check the Enable ClickOnce Security Settings checkbox if it is not already checked.
  4. Select This is a partial trust application if it is not already selected.
  5. Click on the Advanced button at the bottom of the Security tab. This brings up the Advanced Security Settings dialog shown in Figure 6.6.
    Figure 6.6

    Figure 6.6 Advanced Security Settings Dialog

  6. Uncheck the box labeled Debug this application with the selected permission set.

Notice that you also have the options in the Advanced Security Settings Dialog to do the following.

  • Grant the application access to its site of origin (selected by default)
  • Debug the application as if it were downloaded from a different URL

Granting the application access to its site of origin lets you expose a Web service from the same site that the application is launched from that the application calls for back-end services. You can also use this to download additional files on demand. By doing this, you do not need to ask for WebPermission specifically to make those calls. Debugging the application as if it were downloaded from a different URL lets you test and see what will happen with different security zones based on the URL—without needing to understand the exact logic that the runtime is using to evaluate the URL and match it against the location-based security zones.

The settings that you select in the Security tab are saved as part of your Visual Studio project file and will be used each time you publish your application from ClickOnce. The appropriate entries in the application manifest will be created when you publish.

Calculating Permissions with Visual Studio

At the bottom of the project properties editor's Security tab, there is a Calculate Permissions button (see Figure 6.4). If you click this button, Visual Studio will do a static analysis of your code, and every assembly that your code calls out to, in an attempt to determine what permissions your application will require to run. After you run the permissions calculator, it will configure the individual security permissions required for your application to include the permissions that it determined your application needs.

Using the permissions calculator is only appropriate if you plan to deploy your application under partial trust and are not sure what permissions your application requires based on its design. The thing to be aware of with the permissions calculator is that it makes a conservative estimate of what permissions your application will require. Based on my experience trying to use this tool, it always overestimates the permissions required by your application. In fact, it often grossly overestimates the permissions required.

As a result of this overestimation, you will be better off keeping track of what permissions your application needs based on its design and configuring only those permissions. Then test the application rigorously, running under the debugger with ClickOnce security enabled, to ensure you did not miss any required permissions.

If you use the permissions calculator to set the required permissions for your application, your application manifest will likely state that many more permissions are required than really are. This means you are removing some of the protections that running under partial trust brings you. However, running with a set of permissions determined by the permissions calculator under partial trust will still offer more protection to the client machine than running under full trust. So if you are unsure what permissions you need and don't want to jump the security requirements all the way to full trust as a result, go ahead and use the permissions calculator.

Configuring ClickOnce Security Permissions with Mage

It should be a fairly rare thing that you would change the permissions your application requests after you have published from Visual Studio. After all, the permissions required are determined by the code that executes, not based on administrative whims. However, if you find that you need to modify the set of permissions that your application requests without publishing a new version from Visual Studio, you have some ability to do so with the Mage tools.

Using the command line mage.exe tool, you can only set the security to one of the predefined zone levels of Internet, LocalIntranet, or FullTrust. You do this by running mage with a command line switch of –TrustLevel (or –tr for short). Because you are editing the manifest by doing this, you will also need to re-sign the manifest with a certificate. You do this with other command line options. The following example shows how to set the security zone to full trust and re-sign the manifest.

mage.exe -Update MyApp.exe.manifest -TrustLevel FullTrust -CertFile
MyCert.pfx -Password SomeSecretPwd

You can use the Mage UI tool, mageui.exe, to edit the permission settings in a dialog-based user interface. Start mageui.exe from a Visual Studio command prompt and open the application manifest that you want to edit. Select the Permissions Required category in the list on the left and you will see the view shown in Figure 6.7.

You can drop down the list of permission set types on the right in Figure 6.7 to select one of the predefined zones, including Internet, Local Intranet, and Full Trust. When you select one of these values, the Details pane below it will display the XML PermissionSet element that will be placed in the application manifest. Under this element, there will be individual IPermission elements for each permission you require, except in the case of Full Trust, which just sets the permission set to unrestricted. You can also select a value of Custom in the permission set type list to manually enter whatever settings you would like. This requires that you understand the full schema of the PermissionSet element and its child elements to determine what to put into the Details box. This schema is beyond the scope of this book to describe in detail, but follows a common convention with the way permission sets are defined for security configuration files. Consult the MSDN Library documentation for more information on manually creating XML permission set entries.

Figure 6.7

Figure 6.7 Setting Permissions with Mage UI

Note that using the Custom permission set type and figuring out the right XML elements and attributes to add is the only way to go beyond the permission sets and options that are exposed to you in Visual Studio. You could also write a custom tool to set these through the APIs exposed in the Microsoft.Build.Tasks.Deployment namespace, but that is not a trivial task either.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020