11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

326 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sFor more information about using the ASP.NET process account for remote databaseaccess, see the “Data Access” section in Chapter 19, “Securing Your ASP.NET<strong>Application</strong> <strong>and</strong> <strong>Web</strong> Services.”If you use impersonation, the issues <strong>and</strong> considerations that apply to <strong>Web</strong>applications also apply to <strong>Web</strong> services. For more information, see the“Impersonation” sections in Chapter 10, “Building Secure ASP.NET <strong>Web</strong> Pages <strong>and</strong>Controls” <strong>and</strong> Chapter 19, “Securing Your ASP.NET <strong>Application</strong> <strong>and</strong> <strong>Web</strong> Services.”Code Access <strong>Security</strong>Consider the trust level defined by security policy in your target deploymentenvironment. Your <strong>Web</strong> service’s trust level, defined by its elementconfiguration, affects the types of resources that it can access <strong>and</strong> the other privilegedoperations it can perform.Also, if you call a <strong>Web</strong> service from an ASP.NET <strong>Web</strong> application, the <strong>Web</strong>application’s trust level determines the range of <strong>Web</strong> services it can call. For example,a <strong>Web</strong> application configured for Medium trust, by default, can only call <strong>Web</strong> serviceson the local computer.For more information about calling <strong>Web</strong> services from Medium <strong>and</strong> other partialtrust <strong>Web</strong> applications, see Chapter 9, “Using Code Access <strong>Security</strong> with ASP.NET.”Input ValidationLike any application that accepts input data, <strong>Web</strong> services must validate the data thatis passed to them to enforce business rules <strong>and</strong> to prevent potential security issues.<strong>Web</strong> methods marked with the <strong>Web</strong>Method attribute are the <strong>Web</strong> service entrypoints. <strong>Web</strong> methods can accept strongly typed input parameters or loosely typedparameters that are often passed as string data. This is usually determined by therange <strong>and</strong> type of consumers for which the <strong>Web</strong> service is designed.Strongly Typed ParametersIf you use strongly typed parameters that are described by the .NET Framework typesystem, for example integers, doubles, dates, or other custom object types such asAddress or Employee, the auto-generated XML Schema Definition (XSD) schemacontains a typed description of the data. Consumers can use this typed description toconstruct appropriately formatted XML within the SOAP requests that are sent to<strong>Web</strong> methods. ASP.NET then uses the System.Xml.Serialization.XmlSerializer classto deserialize the incoming SOAP message into common language runtime (CLR)objects. The following example shows a <strong>Web</strong> method that accepts strongly typedinput consisting of built-in data types.[<strong>Web</strong>Method]public void CreateEmployee(string name, int age, decimal salary) {...}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!