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.

308 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sFor more information about using IPSec to encrypt all of the data transmittedbetween two computers, see “How To: Use IPSec to Provide Secure CommunicationBetween Two Servers” in the “How To” section of “Microsoft patterns & practicesVolume I, Building Secure ASP.NET <strong>Application</strong>s: Authentication, Authorization, <strong>and</strong>Secure Communication” at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT00.asp.Auditing <strong>and</strong> LoggingAuditing <strong>and</strong> logging should be performed across the tiers of your application toavoid potential repudiation threats where users deny performing certain transactionsor key operations.Audit User TransactionsIf your <strong>Web</strong> application or <strong>Web</strong> service is configured for impersonation, the identityof the original caller automatically flows to an Enterprise Services application <strong>and</strong> isavailable using <strong>Security</strong>CallContext.OriginalCaller. This is useful for auditing in themiddle tier. The following code shows how to access this information:[ComponentAccessControl]public class YourServicedComponent : ServicedComponent{public void ShowCallers(){<strong>Security</strong>Callers callers = <strong>Security</strong>CallContext.CurrentCall.Callers;foreach(<strong>Security</strong>Identity id in callers){LogEvent(id.AccountName);}}private void LogEvent(string message){try{if (!EventLog.SourceExists(appName)){EventLog.CreateEventSource(appName, eventLog);}EventLog.WriteEntry(appName, message, EventLogEntryType.Information );}catch (<strong>Security</strong>Exception secex){throw new <strong>Security</strong>Exception("Event source does not exist <strong>and</strong> cannot be created.", secex);}}}

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

Saved successfully!

Ooh no, something went wrong!