
Guidelines for Developers of Custom Server Controls
As a developer of custom controls, you should follow general best practices for security in ASP.NET application pages and controls and in the .NET Framework. In many cases, the users of your custom server controls might not be aware of all the implementation details or security implications. You should plan for this by following established security conventions and clearly calling out all permissions needed for you components to function. You can start your investigation of general security issues and resolutions for Web applications with Securing ASP.NET Web Sites, the .NET Framework Developer's Guide Key Security Concepts, and with the security topics at the Patterns and Practices Web site.
After you design and implement your custom Web server controls, you must decide how to deliver your components to users. Two common methods of delivery are as an assembly or as a community component. If you deliver your components as an assembly, you should sign your assembly (also called strong-name signing). Signing gives your assembly a unique identity that other software can use to identify and explicitly refer to it. There are also other benefits, as detailed in Programming with Assemblies.
If you deliver your components as a community component with an automated installation procedure, then you should sign your components cryptographically. Signing helps verify that the data originates from a specific party by creating a digital signature that is unique to that party. One way to create community components for use with Visual Studio 2005 is to use the Visual Studio Content Installer and create .vsi files which can be signed. For more information, see How to: Package Community Components to Use the Visual Studio Content Installer.
Some security guidelines to consider when you develop custom server control components are given below. This list is not intended to be comprehensive, but to provide a starting point for investigation:
Provide instructions with your custom server controls about how to use them, and expectations of resources and permissions that they need to function correctly.
Digitally sign your components. If you package your custom control as an assembly, sign the assembly with a strong name. For more information, see Creating and Using Strong-Named Assemblies. If you use an automated installer such as Visual Studio Content Installer, you should still sign your components. For more information, see How to: Package Community Components to Use the Visual Studio Content Installer.
Follow best practices for exception management in your code. For more information, see Chapter 10 on the Patterns and Practices Web site, for example.
If you intend page developers to add your custom controls to the visual designer's toolbox, drag them onto the design surface, and access their properties and events in the property browser, you should consider design-time security in addition to run-time security. For more information, see Securing Custom Control Designer Components.
Understand the top threats to Web application pages and controls, including code injection, information disclosure, session hijacking, identity spoofing, parameter manipulation, and network eavesdropping. To this end, complete a threat-modeling analysis of your components before deployment. For more information, see the Threat Modeling Web Applications topic at the Patterns and Practices Web site.