When a control is in design view, the designer component processes property changes and renders markup in the design host (for example, Visual Studio). At design time, the designer component of a control runs with the same level of trust as its design host. Designer components can potentially access databases, make calls to Web sites on a remote server, create and write files to the developer's computer, send e-mail messages, and execute code in other assemblies.
The information in this section describes best practices that will help you improve the security of the control designer features.
In addition to following coding and configuration best practices to help improve the security of an application, make sure that you continually keep the application server up to date with the latest security updates for Microsoft Windows and Internet Information Services (IIS). You should also make sure that you have the latest releases of any commercial custom-control packages that you have installed on your computer.
You can find more detailed information about best practices for writing secure code and for securing applications in the book "Writing Secure Code" by Michael Howard and David LeBlanc. For additional guidance, see the Microsoft Patterns and Practices [ http://go.microsoft.com/fwlink/?linkid=37129 ] Web site and Guidelines and Best Practices [ http://msdn.microsoft.com/en-us/library/ms184412.aspx ] .
Security Issues for Custom Control Users
You should be aware that custom controls from unknown sources might contain designers that expose sensitive data from your computer to the Web, or that run malicious code at design time. You cannot use code access configuration to limit access for control designers, because they must always run in the design host with full trust. For more information about trust levels, see ASP.NET Trust Levels and Policy Files [ http://msdn.microsoft.com/en-us/library/wyts434y.aspx ] . For more information about Code Access Security, see Introduction to Code Access Security [ http://msdn.microsoft.com/en-us/library/c5tk9z76.aspx ] .
Security Issues for Custom Control Developers
Using configuration attributes for classes and members to limit permissions to the minimum level required for the control's functionality is not a sufficient security measure for designer components, because they must run in the design host with full trust.
If possible, do not use live data from a database to display example structures for previews of data controls, such as the GridView [ http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx ] control. This can expose potentially sensitive data from the database. Instead, use example data structures to build data for previews.
Security Issues for Design Host Developers
If you develop a design host (such as Visual Studio), you should check HTML markup, text, and other data returned from the designer for security risks before you display it. In addition, limit the size of HTML markup strings and designer regions to manageable dimensions. For more information about HTML validation, see Validating User Input in ASP.NET Web Pages [ http://msdn.microsoft.com/en-us/library/7kh55542.aspx ]