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.

364 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>s7. Decrypt the session encryption key using the private key of the server.AsymmetricKeyExchangeDeformatter asymDeformatter = newRSAPKCS1KeyExchangeDeformatter(_rsa);byte[] decryptedSessionKey = asymDeformatter.DecryptKeyExchange();8. Use a mechanism for mapping clients to encryption keys, for example, by using ahash table.At this point, the client <strong>and</strong> server both share an encryption key, <strong>and</strong> can encrypt <strong>and</strong>decrypt method calls. Periodically during the object lifetime, new keys can <strong>and</strong>should be created.Denial of ServiceDenial of service attacks can occur when a malicious client creates multiple objects<strong>and</strong> continues to renew the lifetime lease to consume server resources. Server-sideremote objects contain a default lease. In this state, a client can continue to renew thelease forever. However, you can implement the ILease interface on the server <strong>and</strong>explicitly control sponsors <strong>and</strong> renewals. To do this, overrideInitializeLifetimeService on your MarshalByRefObject object. The remotinginfrastructure calls this method when the object is created. The lease can also be setprogrammatically by using the element.Exception ManagementMake sure you do not return full exception details to the caller. If you use anASP.NET host, make sure ASP.NET is configured so that generic error messages arereturned to the client, as shown below.Use mode=“on” or mode=“remoteOnly”. Do not use mode=“off” on productionservers.

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

Saved successfully!

Ooh no, something went wrong!