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.

Chapter 12: Building Secure <strong>Web</strong> Services 341The consumer code that h<strong>and</strong>les potential SoapExceptions follows:try{EmployeeService service = new EmployeeService();Service.GiveBonus(empID,percentage);}catch (System.<strong>Web</strong>.Services.Protocols.SoapException se){// Extract custom message from se.Detail.InnerTextConsole.WriteLine("Server threw a soap exception" + se.Detail.InnerText );}<strong>Application</strong> Level Error H<strong>and</strong>ling in Global.asaxASP.NET <strong>Web</strong> applications commonly h<strong>and</strong>le application level exceptions that areallowed to propagate beyond a method boundary in the <strong>Application</strong>_Error eventh<strong>and</strong>ler in Global.asax. This feature is not available to <strong>Web</strong> services, because the<strong>Web</strong> service’s HttpH<strong>and</strong>ler captures the exception before it reaches other h<strong>and</strong>lers.If you need application level exception h<strong>and</strong>ling, create a custom SOAPextension to h<strong>and</strong>le it. For more information, see MSDN article, “Alteringthe SOAP Message using SOAP Extensions” in the “Building <strong>Application</strong>s”section of the .NET Framework SDK at http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d&DisplayLang=en.Auditing <strong>and</strong> LoggingWith a <strong>Web</strong> service, you can audit <strong>and</strong> log activity details <strong>and</strong> transactions either byusing platform-level features or by using custom code in your <strong>Web</strong> methodimplementations.You can develop code that uses the System.Diagnostics.EventLog class to log actionsto the Windows event log. The permission requirements <strong>and</strong> techniques for using thisclass from a <strong>Web</strong> service are the same as for a <strong>Web</strong> application. For more information,see the “Auditing <strong>and</strong> Logging” section in Chapter 10, “Building Secure ASP.NETPages <strong>and</strong> Controls.”Proxy ConsiderationsIf you use WSDL to automatically generate a proxy class to communicate with a <strong>Web</strong>service, you should verify the generated code <strong>and</strong> service endpoints to ensure thatyou communicate with the desired <strong>Web</strong> service <strong>and</strong> not a spoofed service. If theWSDL files on a remote server are inadequately secured, it is possible for a malicioususer to tamper with the files <strong>and</strong> change endpoint addresses, which can impact theproxy code that you generate.

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

Saved successfully!

Ooh no, something went wrong!