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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 12: Building Secure <strong>Web</strong> Services 331Table 12.1 XSD Schema Element Examples (continued)DescriptionExampleConstraining input to values defined by anenumerated typeFor more information, see Microsoft Knowledge Base articles:●●307379, “How To: Validate an XML Document by Using DTD, XDR, or XSDin Visual C# .NET.”318504, “How To: Validate XML Fragments Against an XML Schema inVisual C#.NET.”SQL InjectionSQL injection allows an attacker to execute arbitrary comm<strong>and</strong>s in the database usingthe <strong>Web</strong> service’s database login. SQL injection is a potential issue for <strong>Web</strong> services ifthe services use input data to construct SQL queries. If your <strong>Web</strong> methods access thedatabase, they should do so using SQL parameters <strong>and</strong> ideally, parameterized storedprocedures. SQL parameters validate the input for type <strong>and</strong> length, <strong>and</strong> they ensurethat the input is treated as literal text <strong>and</strong> not executable code. For more informationabout this <strong>and</strong> other SQL injection countermeasures, see the “Input Validation”section in Chapter 14, “Building Secure Data Access.”Cross-Site ScriptingWith cross-site scripting (XSS), an attacker exploits your application to executemalicious script at the client. If you call a <strong>Web</strong> service from a <strong>Web</strong> application <strong>and</strong>send the output from the <strong>Web</strong> service back to the client in an HTML data stream,XSS is a potential issue. In this scenario, you should encode the output receivedfrom the <strong>Web</strong> service in the <strong>Web</strong> application before returning it to the client. This isparticularly important if you do not own the <strong>Web</strong> service <strong>and</strong> it falls outside the <strong>Web</strong>application’s trust boundary. For more information about XSS countermeasures, seethe “Input Validation” section in Chapter 10, “Building Secure ASP.NET Pages <strong>and</strong>Controls.”

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

Saved successfully!

Ooh no, something went wrong!