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.

384 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sConfiguration ManagementDatabase connection strings are the main configuration management concern for dataaccess code. Carefully consider where these strings are stored <strong>and</strong> how they aresecured, particularly if they include credentials. To improve your encryptionmanagement security:● Use Windows authentication.●●Secure your connection strings.Secure UDL files with restricted ACLs.Use Window AuthenticationWhen you use Windows authentication, the credentials are managed for you <strong>and</strong> thecredentials are not transmitted over the network. You also avoid embedding usernames <strong>and</strong> passwords in connection strings.Secure Your Connection StringsIf you need to use SQL authentication, then your connection contains the user name<strong>and</strong> password. If an attacker exploits a source code disclosure vulnerability on the<strong>Web</strong> server or manages to log on to the server, the attacker can retrieve the connectionstrings. Similarly, anyone with a legitimate login to the server can view them. Secureconnection strings using encryption.Encrypt the Connection StringEncrypt connection strings by using DPAPI. With DPAPI encryption, you avoidencryption key management issues because the encryption key is managed by theplatform <strong>and</strong> is tied to either a specific computer or a Windows user account. To useDPAPI, you must call the Win32 DPAPI functions through P/Invoke.For details on how to build a managed wrapper class, see “How To: Create a DPAPILibrary” in the “How To” section of “Microsoft patterns & practices Volume I, BuildingSecure 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/secnetlpMSDN.asp.Store Encrypted Connection Strings SecurelyThe encrypted connection string can be placed in the registry or in the <strong>Web</strong>.config orMachine.config file. If you use a key beneath HKEY_LOCAL_MACHINE, apply thefollowing ACL to the key:Administrators: Full ControlProcess Account: Read

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

Saved successfully!

Ooh no, something went wrong!