0572 AzureSecurityNotes
0572 AzureSecurityNotes
0572 AzureSecurityNotes
Lessons Learned from Exploring Microsoft Azure and the Cloud Security Space
Acknowledgments
Thanks to the following external contributors and reviewers: Adam Grocholski; Andy Eunson; Bill Collette; Christopher Seary; Jason Taylor; John Daniels; Juval Lowy; Kevin Lam; Long Le; Michael Smith; Michael Stiefel; Michele Leroux Bustamante; Norman Headlam; Rockford Lhotka; Rudolph Araujo; Sarang Kulkarni; Steven Nagy; Terrance Snyder; Will Clevenger Thanks to the following Microsoft contributors and reviewers: Akshay Aggarwal; Alik Levin; Andreas Fuchsberger; Babur Butter; Bharat Shyam; Dave Brankin; Danny Cohen; Diego Dagum; Don Willits; Eugenio Pace; Gabriel Morgan; Jeff Mueller; John Steer; Julian Gonzalez; Mark Curphey; Mohit Srivastava; Pat Filoteo; Rahul Verma; Raul Rojas; Scott Densmore; Sesha Mani; Serena Yeoh; Sriram Krishnan; Stefan Schackow; Steve Marx; Stuart Kwan; Terri Schmidt; Tobin Titus; Varun Sharma; Vidya Vrat Agarwal; Vikram Bhambri; Yale Li
Overview
These notes summarize how we took a look at securing Web applications, web services, and data in the cloud. We basically started by mapping out common application scenarios. We then figured out a way to group threats and attacks into a set of common categories. These categories make it easy for us to analyze and inspect the various parts of an application and engineering decisions. Then we focused on finding common principles, patterns, and practices, while working with customers, field, product teams, and industry experts.
Security Frame. There are many ways to chunk up and think about security. For example, you might use C.I.A., where C is confidentiality, I is integrity, and A represent availability. Another approach is to focus on the three As: Authentication, Access control, and Auditing. Weve found it especially useful to use the following categories to organize and share application security principles, patterns, anti-patterns, and practices: Auditing and Logging, Authentication, Authorization, Communication, Configuration Management, Cryptography, Exception Management, Sensitive Data, Session Management, and Validation. People, process, and technology. Another way to look at security is through the people, process, and technology viewpoints. You can also use each of these views when you look at security for your network, host, and application. Application, Infrastructure, and Business. This is another helpful lens for looking at security. You can look at the principles, patterns, and practices for the application, the infrastructure, or the business. This leads to application security patterns, infrastructure security patterns, and business security patterns and practices.
At the end of the day, whats important is using the lens that helps you the most, and avoid using the wrong tool for the job, or using a one-size fits all solution. Instead, chunk up the problem, while keeping a holistic view.
By using a security frame, focusing on threats and countermeasures, and visual scenarios, we have an effective backdrop for analyzing, evaluating, and talking about cloud security challenges.
This means identifying the bad things that can happen, and what your defenses, security controls, or countermeasures are. By building a knowledgebase of threats, attacks, vulnerabilities, and countermeasures, we can dramatically improve our ability to share security know-how.
Scenario
Solution
Authorization
Communication
Security Frame
A Security Frame acts as a simple lens. It helps organize and share security knowledge in a set of actionable buckets. Here is an explanation of the key buckets used in these notes:
Category Auditing and Logging Authentication Authorization Communication Configuration Management Cryptography Exception Management Sensitive Data Notes How security-related events are recorded, monitored, and audited. The process of proving identity, typically through credentials, such as a user name and password How your application provides access controls for roles, resources and operations. How data is transmitted over the wire. Transport security versus message encryption is covered here. How your application handles configuration and administration of your applications from a security perspective. How your application enforces confidentiality and integrity. How you handle applications errors and exceptions. How your application handles any data that must be protected either in
memory, over the network, or in persistent stores A session refers to a series of related interactions between a user and your application. How your application filters, scrubs, or rejects input before additional processing, or how it sanitizes output.
The key to the buckets is that they are actionable. Another key is that developers can relate to them. This makes it easier to share security knowledge between security experts and developers in a pragmatic way.
Firewall
Firewall
Apps
Apps
Database
Host
Host
Host
Figure 1. Securing the Network, Host and Application On-premise Using this visual model concept and the revised security frame for cloud applications we can use the same approach to evaluate cloud applications. In Figure 2 below, we modify the visual
model by hosting both the application and data layers in the managed infrastructure, which in this case is the cloud. With a managed infrastructure we can remove checks from our list because they are items handled by the managed infrastructure. For example, a Windows Azure application will not have permissions to create user accounts, or elevate privileges. This alleviates the need to manage accounts at the host level.
Securing the Application
Auditing and Logging Authentication Authorization Communication Configuration Management Application Layer Cryptography Exception Management Sensitive Data Session Management Validation Database Layer
Firewall
Apps
Data
Managed Infrastructure
Cloud Host
Figure 2. Securing the Network, Host and Application in the Cloud The above diagram represents the canonical case architecture. To evaluate other architectures such as ones involving federated identity or hybrid on-premise and cloud implementations, you can use the same approach. Represent your architecture with a base diagram, and overlay the frame on it. Once the frame is overlaid, you can evaluate each item for applicability and quickly scope out categories not needing attention.
Overview
It is important to think like an attacker when designing and implementing an application. Putting yourself in the attackers mindset will make you more effective at designing mitigations for vulnerabilities and coding defensively. This section is a reference of the security frame, and its pieces pinned against the cloud as a platform. We also present threats, vulnerabilities and countermeasures against the cloud organized by hot spot such that you can see how they relate to each other in each category.
Authorization
Cryptography
Exception Management
Sensitive Data
authentication against varying identity stores. Authorization in Windows Azure is how your application provides access controls for roles, resources and operations. Authorization strategies might involve standard mechanisms, utilize claims and potentially support a federated model. Communication encompasses how data is transmitted over the wire. Transport security, message encryption, and point to point communication are covered here. Configuration management refers to how your application handles configuration and administration of your applications from a security perspective. Examples include: Who does your application run as? Which databases does it connect to? How is your application administered? How are these settings secured? Cryptography in Windows Azure refers to how your application enforces confidentiality and integrity. Examples include: How are you keeping secrets (confidentiality)? How are you tamper-proofing your data or libraries (integrity)? How are you providing seeds for random values that must be cryptographically strong? Certificates and cert management are in this domain as well. Validation refers to how your application filters, scrubs, or rejects input before additional processing, or how it sanitizes output. It's about constraining input through entry points and encoding output through exit points. Message validation refers to how you verify the message payload against schema, as well as message size, content and character sets. Examples include: How do you know that the input your application receives is valid and safe? Do you trust data from sources such as databases and file shares? Exception management refers to how you handle applications errors and exceptions. Examples include: When your application fails, what does your application do? Does it support graceful failover to other application instances in the cloud? How much information do you reveal? Do you return friendly error information to end users? Do you pass valuable exception information back to the caller? Sensitive data refers to how your application handles any data that must be protected either in memory, over the network, or in persistent stores. Examples include: How does your application handle sensitive data? How is sensitive data shared between application instances?
Configuration Management
Cryptography
Exception Management
Repudiation. An attacker denies performing an operation, exploits an application without trace, or covers his or her tracks. Network eavesdropping. An attacker steals identity and/or credentials off the network by reading network traffic not intended for them. Brute force attacks. An attacker guesses identity and/or credentials through the use of brute force. Dictionary attacks. An attacker guesses identity and/or credentials through the use of common terms in a dictionary designed for that purpose. Cookie replay attacks. An attacker gains access to an authenticated session through the reuse of a stolen cookie containing session information. Credential theft. An attacker gains access to credentials through data theft; for instance, phishing or social engineering. Elevation of privilege. An attacker enters a system as a lower-level user, but is able to obtain higher-level access. Disclosure of confidential data. An attacker accesses confidential information because of authorization failure on a resource or operation. Data tampering. An attacker modifies sensitive data because of authorization failure on a resource or operation. Luring attacks. An attacker lures a higher-privileged user into taking an action on their behalf. This is not an authorization failure but rather a failure of the system to properly inform the user. Token stealing. An attacker steals the credentials or token of another user in order to gain authorization to resources or operations they would not otherwise be able to access. Failure to encrypt messages. An attacker is able to read message content off the network because it is not encrypted. Theft of encryption keys. An attacker is able to decrypt sensitive data because he or she has the keys. Man-in-the-middle attack. An attacker can read and then modify messages between the client and the service. Session replay. An attacker steals messages off the network and replays them in order to steal a user's session. Data tampering. An attacker modifies the data in a message in order to attack the client or the service Unauthorized access to configuration stores. An attacker gains access to configuration files and is able to modify binding settings, etc. Retrieval of clear text configuration secrets. An attacker gains access to configuration files and is able to retrieve sensitive information such as database connection strings. Encryption cracking. Breaking an encryption algorithm and gaining access to the encrypted data. Loss of decryption keys. Obtaining decryption keys and using them to access protected data. Information disclosure. Sensitive system or application details are revealed through exception information. Denial of service. An attacker uses error conditions to stop your service or place it in an unrecoverable error state.
Sensitive Data
Elevation of privilege. Your service encounters an error and fails to an insecure state; for instance, failing to revert impersonation. Canonicalization attacks. Canonicalization attacks can occur anytime validation is performed on a different form of the input than that which is used for later processing. For instance, a validation check may be performed on an encoded string, which is later decoded and used as a file path or URL. Cross-site scripting. Cross-site scripting can occur if you fail to encode user input before echoing back to a client that will render it as HTML. SQL injection. Failure to validate input can result in SQL injection if the input is used to construct a SQL statement, or if it will modify the construction of a SQL statement in some way. Cross-Site Request Forgery: CSRF attacks involve forged transactions submitted to a site on behalf of another party. XPath injection. XPath injection can result if the input sent to the Web service is used to influence or construct an XPath statement. The input can also introduce unintended results if the XPath statement is used by the Web service as part of some larger operation, such as applying an XQuery or an XSLT transformation to an XML document. XML bomb. XML bomb attacks occur when specific, small XML messages are parsed by a service resulting in data that feeds on itself and grows exponentially. An attacker sends an XML bomb with the intent of overwhelming a Web services XML parser and resulting in a denial of service attack. Memory dumping. An attacker is able to read sensitive data out of memory or from local files. Network eavesdropping. An attacker sniffs unencrypted sensitive data off the network. Configuration file sniffing. An attacker steals sensitive information, such as connection strings, out of configuration files.
Vulnerabilities
Category Auditing and Logging Items Failing to audit failed logons. Failing to secure log files. Storing sensitive information in log files. Failing to audit across application tiers. Failure to throttle log files. Using weak passwords. Storing clear text credentials in configuration files. Passing clear text credentials over the network. Permitting prolonged session lifetime. Mixing personalization with authentication. Using weak authentication mechanisms (e.g., using basic authentication over
Authentication
Authorization
Configuration Management
Communication
Cryptography
Exception Management
Sensitive Data
an untrusted network). Relying on a single gatekeeper (e.g., relying on client-side validation only). Failing to lock down system resources against application identities. Failing to limit database access to specified stored procedures. Using inadequate separation of privileges. Connection pooling. Permitting overprivileged accounts. Using insecure custom administration interfaces. Failing to secure configuration files on the server. Storing sensitive information in the clear text. Having too many administrators. Using overprivileged process accounts and service accounts. Not encrypting messages. Using custom cryptography. Distributing keys insecurely. Managing or storing keys insecurely. Failure to use a mechanism to detect message replays. Not using either message or transport security. Using custom cryptography Failing to secure encryption keys Using the wrong algorithm or a key size that is too small Using the same key for a prolonged period of time Distributing keys in an insecure manner Failure to use structured exception handling (try/catch). Revealing too much information to the client. Failure to specify fault contracts with the client. Failure to use a global exception handler. Using non-validated input used to generate SQL queries. Relying only on client-side validation. Using input file names, URLs, or usernames for security decisions. Using application-only filters for malicious input. Looking for known bad patterns of input. Trusting data read from databases, file shares, and other network resources. Failing to validate input from all sources including cookies, headers, parameters, databases, and network resources. Storing secrets when you do not need to. Storing secrets in code. Storing secrets in clear text in files, registry, or configuration. Passing sensitive data in clear text over networks.
Countermeasures
Category Items
Authentication
Authorization
Configuration Management
Communication
Cryptography
Exception Management
Sensitive Data
Validation
Identify malicious behavior. Know your baseline (know what good traffic looks like). Use application instrumentation to expose behavior that can be monitored. Throttle logging. Strip sensitive data before logging. Use strong password policies. Do not store credentials in an insecure manner. Use authentication mechanisms that do not require clear text credentials to be passed over the network. Encrypt communication channels to secure authentication tokens. Use Secure HTTP (HTTPS) only with forms authentication cookies. Separate anonymous from authenticated pages. Using cryptographic random number generators to generate session IDs. Use least-privileged accounts. Tie authentication to authorization on the same tier. Consider granularity of access. Enforce separation of privileges. Use multiple gatekeepers. Secure system resources against system identities. Using insecure custom administration interfaces. Failing to secure configuration files on the server. Storing sensitive information in the clear text. Having too many administrators. Using overprivileged process accounts and service accounts. Use message security or transport security to encrypt your messages. Use proven platform-provided cryptography. Periodically change your keys. Use any platform-provided replay detection features. Consider creating custom code if the platform does not provide a detection mechanism. Turn on message or transport security. Do not develop and use proprietary algorithms (XOR is not encryption. Use established cryptography such as RSA) Avoid key management. Use the RNGCryptoServiceProvider method to generate random numbers Periodically change your keys Use structured exception handling (by using try/catch blocks). Catch and wrap exceptions only if the operation adds value/information. Do not reveal sensitive system or application information. Implement a global exception handler. Do not log private data such as passwords. Do not store secrets in software. Encrypt sensitive data over the network. Secure the channel. Encrypt sensitive data in configuration files. Do not trust client input.
Validate input: length, range, format, and type. Validate XML streams. Constrain, reject, and sanitize input. Encode output. Restrict the size, length, and depth of parsed XML messages.
10. Data tampering. An attacker violates the integrity of data by modifying it in local memory, in a data-store, or on the network. Modification of this data could provide the attacker with access to a service through a number of the different methods listed in this document. 11. Denial of service. Denial of service (DoS) is the process of making a system or application unavailable. For example, a DoS attack might be accomplished by bombarding a server with requests to consume all available system resources, or by passing the server malformed input data that can crash an application process. 12. Dictionary attack. Use of a list of likely access methods (usernames, passwords, coding methods) to try and gain access to a system. This approach is more focused and intelligent than the brute force attack method, so as to increase the likelihood of success in a shorter amount of time. 13. Disclosure of sensitive/confidential data. Sensitive data is exposed in some unintended way to users who do not have the proper privileges to see it. This can often be done through parameterized error messages, where an attacker will force an error and the program will pass sensitive information up through the layers of the program without filtering it. This can be personally identifiable information (i.e., personal data) or system data. 14. Elevation of privilege. A user with limited privileges assumes the identity of a privileged user to gain privileged access to an application. For example, an attacker with limited privileges might elevate his or her privilege level to compromise and take control of a highly privileged and trusted process or account. More information about this attack in the context of Windows Azure can be found in the Security Best Practices for Developing Windows Azure Applications at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=0ff0c25fdc54-4f56-aae7-481e67504df6 15. Encryption. The process of taking sensitive data and changing it in such a way that it is unrecognizable to anyone but those who know how to decode it. Different encryption methods have different strengths based on how easy it is for an attacker to obtain the original information through whatever methods are available. 16. Information disclosure. Unwanted exposure of private data. For example, a user views the contents of a table or file that he or she is not authorized to open, or monitors data passed in plaintext over a network. Some examples of information disclosure vulnerabilities include the use of hidden form fields, comments embedded in Web pages that contain database connection strings and connection details, and weak exception handling that can lead to internal system-level details being revealed to the client. Any of this information can be very useful to the attacker. 17. Luring attacks. An attacker lures a higher-privileged user into taking an action on his or her behalf. This is not an authorization failure but rather a failure of the system to properly inform the user. 18. Man-in-the-middle attacks. A person intercepts both the client and server communications and then acts as an intermediary between the two without each ever knowing. This gives the middle man the ability to read and potentially modify messages from either party in order to implement another type of attack listed here.
19. Network eavesdropping. Listening to network packets and reassembling the messages being sent back and forth between one or more parties on the network. While not an attack itself, network eavesdropping can easily intercept information for use in specific attacks listed in this document. 20. Open Redirects. Attacker provides a URL to a malicious site when allowed to input a URL used in a redirect. This allows the attacker to direct users to sites that perform phishing attacks or other malicious actions. 21. Password cracking. If the attacker cannot establish an anonymous connection with the server, he or she will try to establish an authenticated connection. For this, the attacker must know a valid username and password combination. If you use default account names, you are giving the attacker a head start. Then the attacker only has to crack the accounts password. The use of blank or weak passwords makes the attackers job even easier. 22. Repudiation. The ability of users (legitimate or otherwise) to deny that they performed specific actions or transactions. Without adequate auditing, repudiation attacks are difficult to prove. 23. Session hijacking. Also known as man-in-the-middle attacks, session hijacking deceives a server or a client into accepting the upstream host as the actual legitimate host. Instead, the upstream host is an attackers host that is manipulating the network so the attackers host appears to be the desired destination. 24. Session replay. An attacker steals messages off of the network and replays them in order to steal a users session. 25. Session fixation. An attacker sets (fixates) another persons session identifier artificially. The attacker must know that a particular Web service accepts any session ID that is set externally; for example, the attacker sets up a URL such as http://unsecurewebservice.com/?sessionID=1234567. The attacker then sends this URL to a valid user, who clicks on it. At this point, a valid session with the ID 1234567 is created on the server. Because the attacker determines this ID, he or she can now hijack the session, which has been authenticated using the valid users credentials. 26. Spoofing. An attempt to gain access to a system by using a false identity. This can be accomplished by using stolen user credentials or a false IP address. After the attacker successfully gains access as a legitimate user or host, elevation of privileges or abuse using authorization can begin. 27. SQL injection. Failure to validate input in cases where the input is used to construct a SQL statement or will modify the construction of a SQL statement in some way. If the attacker can influence the creation of a SQL statement, he or she can gain access to the database with privileges otherwise unavailable and use this in order to steal or modify information or destroy data. 28. Throttling. The process of limiting resource usage to keep a particular process from bogging down and/or crashing a system. Relevant as a countermeasure in DoS attacks, where an attacker attempts to crash the system by overloading it with input.
Countermeasures Explained
1. Assume all input is malicious. Assuming all input is malicious means designing your application to validate all input. User input should never be accepted without being filtered and/or sanitized. 2. Audit and log activity through all of the application tiers. Log business critical and security sensitive events. This will help you track security issues down and make sense of security problems. Skilled attackers attempt to cover their tracks, so youll want to protect your logs. 3. Avoid storing secrets. Design around storing secrets. If necessary, sometimes they can be avoided by storing them after using a one-way hash algorithm. 4. Avoid storing sensitive data in the Web space. Anything exposed to the public Internet is considered web space. Sensitive data stored in a location that might be compromised by any member of the public places it at much higher risk. 5. Back up and regularly analyze log files. Some attacks can occur over time. Regular analysis of logs will allow you to recognize with sufficient time to address them. Performing regular backups lowers the risk of an attacker covering his tracks by deleting logging of his activities. 6. Be able to disable accounts. The ability to reactively defend an attack by shutting out a user should be supported through the ability to disable an account. 7. Be careful with canonicalization issues. Predictable naming of file resources is convenient for programming, but is also very convenient for malicious parties to attack. Application logic should not be exposed to users in this manner. Instead, you use file names derived from the original names or fed through a one-way hashing algorithm. 8. Catch exceptions. Unhandled exceptions are at risk of passing too much information to the client. Handle exceptions when possible. 9. Centralize your input and data validation. Input and data validation should be performed using a common set of code such as a validation library. 10. Consider a centralized exception management framework. Exception handling frameworks are available publically and provide an established and tested means for handling exceptions. 11. Consider authorization granularity. Every object needs to have an authorization control that authorizes access based on the identity of the authenticated party requesting access. Fine grained authorization will control access to each resource, while coarse grained authorization will control access to groups of resources or functional areas of the application. 12. Consider identity flow. Auditing should be traceable back to the authenticated party. Take note of identity transitions imposed by design decisions like impersonation. 13. Constrain input. Limit user input to expected ranges and formats. 14. Constrain, reject, and sanitize your input. Constrain, reject and sanitize should be primary techniques in handling input data. 15. Cycle your keys periodically. Expiring encryption keys lowers the risk of stolen keys.
16. Disable anonymous access and authenticate every principle. When possible, require all interactions to occur as an authenticated party as opposed to an anonymous one. This will help facilitate more effective auditing. 17. Do not develop your own cryptography. Custom cryptography is not difficult for experts to crack. Established cryptography is preferred because it is known to be safe. 18. Do not leak information to the client. Exception data can potentially contain sensitive data or information exposing program logic. Provide clients only with the error data they need for the UI. 19. Do not log private data such as passwords. Log files are an attack vector for malicious parties. Limit the risk of their being compromised by not logging sensitive data in the log. 20. Do not pass sensitive data using the HTTP-GET protocol. Data passed using HTTP GET is appended to the querystring. When users share links by copying and pasting them from the browser address bar, sensitive data may also be inadvertently passed. Pass sensitive data in the body of a POST to avoid this. 21. Do not rely on client-side validation. Any code delivered to a client is at risk of being compromised. Because of this, it should always be assumed that input validation on the client might have been bypassed. 22. Do not send passwords over the wire in plaintext. Authentication information communicated over the wire should always be encrypted. This may mean encrypting the values, or encrypting the entire channel with SSL. 23. Do not store credentials in plaintext. Credentials are sometimes stored in application configuration files, repositories, or sent over email. Always encrypt credentials before storing them. 24. Do not store database connections, passwords, or keys in plaintext. Configuration secrets should always be stored in encrypted form, external to the code. 25. Do not store passwords in user stores. In the event that the user store is compromised, an attack should never be able to access passwords. A derivative of a password should be stored instead. A common approach to this is to encrypt a version of the password using a one-way hash with a SALT. Upon authentication, the encrypted password can be regenerated with the SALT and the result can be compared to the original encrypted password. 26. Do not store secrets in code. Secrets such as configuration settings are convenient to store in code, but are more likely to be stolen. Instead, store them in a secure location such as a secret store. 27. Do not store sensitive data in persistent cookies. Persistent cookies are stored client-side and provide attackers with ample opportunity to steal sensitive data, be it through encryption cracking or any other means. 28. Do not trust fields that the client can manipulate (query strings, form fields, cookies, or HTTP headers). All information sent from a client should always be assumed to be malicious. All information from a client should always be validated and sanitized before it is used. 29. Do not trust HTTP header information. Http header manipulation is a threat that can be mitigated by building application logic that assumes HTTP headers are compromised and validates the HTTP headers before using them.
30. Encrypt communication channels to protect authentication tokens. Authentication tokens are often the target of eavesdropping, theft or replay type attacks. To reduce the risk in these types of attacks, it is useful to encrypt the channel the tokens are communicated over. Typically this means protecting a login page with SSL encryption. 31. Encrypt sensitive cookie state. Sensitive data contained within cookies should always be encrypted. 32. Encrypt the contents of the authentication cookies. In the case where cookies are compromised, they should not contain clear-text session data. Encrypt sensitive data within the session cookie. 33. Encrypt the data or secure the communication channel. Sensitive data should only be passed in encrypted form. This can be accomplished by encrypting the individual items that are sent over the wire, or encrypting the entire channel as with SSL. 34. Enforce separation of privileges. Avoid building generic roles with privileges to perform a wide range of actions. Roles should be designed for specific tasks and provided the minimum privileges required for those tasks. 35. Enforce unique transactions. Identify each transaction from a client uniquely to help prevent replay and forgery attacks. 36. Identify malicious behavior. Monitoring site interactions that fall outside of normal usage patterns, you can quickly identify malicious behavior. This is closely related to Know what good traffic looks like. 37. Keep unencrypted data close to the algorithm. Use decrypted data as soon as it is decrypted, and then dispose of it promptly. Unencrypted data should not be held in memory in code. 38. Know what good traffic looks like. Active auditing and logging of a site will allow you know recognize what regular traffic and usage patterns are. This is a required step in order to be able to identify malicious behavior. 39. Limit session lifetime. Longer session lifetimes provide greater opportunity for Cross-Site Scripting or Cross-Site Request Forgery attacks to add activity onto an old session. 40. Log detailed error messages. Highly detailed error message logging can provide clues to attempted attacks. 41. Log key events. Profile your application and note key or sensitive operations and/or events, and log these events during application operation. 42. Maintain separate administration privileges. Consider granularity of authorization in the administrative interfaces as well. Avoid combining administrator roles with distinctly different roles such as development, test or deployment. 43. Make sure that users do not bypass your checks. Bypassing checks can be accomplished by canonicalization attacks, or bypassing client-side validation. Application design should avoid exposing application logic, and segregating application logic into flow that can be interrupted. For example, an ASPX page that performs only validations and then redirects. Instead, validation routines should be tightly bound to the data they are validating. 44. Pass Forms authentication cookies only over HTTPS connections. Cookies are at risk of theft and replay type attacks. Encrypting them with SSL helps reduce the risk of these types of attacks.
45. Protect authentication cookies. Cookies can be manipulated with Cross-Site Scripting attacks, encrypt sensitive data in cookies, and use browser features such as the HttpOnly cookie attribute. 46. Provide strong access controls on sensitive data stores. Access to secret stores should but authorized. Protect the secret store as you would other secure resources by requiring authentication and authorization as appropriate. 47. Reject known bad input. Rejecting known bad input involves screening input for values that are known to be problematic or malicious. NOTE: Rejecting should never be the primary means of screening bad input, it should always be used in conjunction with input sanitization. 48. Require strong passwords. Enforce password complexity requirement by requiring long passwords with a combination of upper case, lower case, numeric and special (for example punctuation) characters. This helps mitigate the threat posed by dictionary attacks. If possible, also enforce automatic password expiry. 49. Restrict user access to system-level resources. Users should not be touching system resources directly. This should be accomplished through an intermediary such as the application. System resources should be restricted to application access. 50. Retrieve sensitive data on demand. Sensitive data stored in application memory provides attackers another location they can attempt to access the data. Often this data is used in unencrypted form also. To minimize risk of sensitive data theft, sensitive data should be used immediately and then cleared from memory. 51. Sanitize input. Sanitizing input is the opposite of rejecting bad input. Sanitizing input is the process of filtering input data to only accept values that are known to be safe. Alternatively, input can be rendered innocuous by converting it to safe output through output encoding methods. 52. Secure access to log files. Log files should only be accessible to administrators, auditors, or administrative interfaces. An attacker with access to the logs might be able to glean sensitive data or program logic from logs. 53. Secure the communication channel for remote administration. Eavesdropping and replay attacks can target administration interfaces as well. If using a web based administration interface, use SSL. 54. Secure your configuration store. The configuration store should require authenticated access and should store sensitive settings or information in an encrypted format. 55. Secure your encryption keys. Encryption keys should be treated as secrets or sensitive data. They should be secured in a secret store or key repository. 56. Separate public and restricted areas. Applications that contain public front-ends as well as content that requires authentication to access should be partitioned in the same manner. Public facing pages should be hosted in a separate file structure, directory or domain from private content. 57. Store keys in a restricted location. Protect keys with authorization policies. 58. Support password expiration periods. User passwords and account credentials are commonly compromised. Expiration policies help mitigate attacks from stolen accounts, or disgruntled employees who have been terminated.
59. Use account lockout policies for end-user accounts. Account login attempts should have a cap on failed attempts. After the cap is exceeded the account should prevent further login attempts. Lockout helps prevent dictionary and brute force attacks. 60. Use application instrumentation to expose behavior that can be monitored: Application transactions that are more likely to be targeted by malicious interactions should be logged or monitored. Examples of this might be adding logging code to an exception handler, or logging individual API calls. By providing a means to watch these transactions you have a higher likelihood of being able to identify malicious behavior quickly. 61. Use authentication mechanisms that do not require clear text credentials to be passed over the network: A variety of authentication approaches exist for use with web based applications some involve the use of tokens while others will pass user credentials (user name/id and password) over the wire. When possible, it is safer to use an authentication mechanism that does not pass the credentials. If credentials must be passed, it is preferable to encrypt them, and/or send them over an encrypted channel such as SSL. 62. Use least privileged accounts. The privileges granted to the authenticated party should be the minimum required to perform all required tasks. Be careful of using existing roles that have permissions beyond what is required. 63. Use least privileged process and service accounts. Allocate accounts specifically for process and service accounts. Lock down the privileges of these accounts separately from other accounts. 64. Use multiple gatekeepers. Passing the authentication system should not provide a golden ticket to any/all functionality. System and/or application resources should have restricted levels of access depending on the authenticated party. Some design patterns might also enforce multiple authentications, sometimes distributed through application tiers. 65. Use SSL to protect session authentication cookies. Session authentication cookies contain data that can be used in a number of different attacks such as replay, Cross-Site Scripting or Cross-Site Request Forgery. Protecting these cookies helps mitigate these risks. 66. Use strong authentication and authorization on administration interfaces. Always require authenticated access to administrative interfaces. When applicable, also enforce separation of privileges within the administrative interfaces. 67. Use structured exception handling. A structured approach to exception handling lowers the risk of unexpected exceptions from going unhandled. 68. Use the correct algorithm and correct key length. Different encryption algorithms are preferred for varying data types and scenarios. 69. Use tried and tested platform features. Many cryptographic features are available through the .NET Framework. These are proven features and should be used in favor of custom methods. 70. Validate all values sent from the client. Similar to not relying on client-side validation, any input from a client should always be assumed to have been tampered with. This input should always be validated before it is used. This encompasses user input, cookie values, HTTP headers, and anything else that is sent over the wires from the client. 71. Validate data for type, length, format, and range. Data validation should encompass these primary tenets. Validate for data type, string lengths, string or numeric formats, and numeric ranges.
SDL Considerations
For more information on preferred encryption algorithms and key lengths, see the Security Development Lifecycle at http://www.microsoft.com/security/sdl/.
Azure Storage and SQL Azure -- Some of the things to think about in Windows Azure regarding data include deciding where to host your data, what will be used to host the data, and what the means of access to that data will be. You can use on-premise data and expose it as a service to your Windows Azure application. Data hosting in the cloud can be done primarily through Windows Azure Storage or SQL Azure. Data exposed to other applications or services should be exposed as a service (Data as a Service), but data consumed only by your application has the option of being accessed without a service interface. Deployment -- Deploying the Windows Azure can potentially mean deploying across multiple data centers that are physically separate. This will influence application design patterns, deployment, as well as communication between application pieces. Be aware of your application boundaries, and use resources within the same data center when possible, and communication options such as internal endpoints when applicable.
Consider your storage options: Windows Azure Storage, SQL Azure, Azure Drives
Windows Azure Storage and SQL Azure are the 2 primary storage options for Windows Azure applications. Azure drives offer another option for persisting information, by writing to the VM's virtual drive, and persisting the drive state to Azure Drives. SQL Azure offers relational data storage and a host for existing TSQL logic. Windows Azure storage offers a lower cost per megabyte stored.
VMs
HTTP / HTTPs
Load Balancer
Storage
Deployment Considerations
Windows Azure
Web Role 80 Web Role Web Role Services Layer Service Interfaces Web Role 80 Web Role Web Role Presentation Layer ASP.NET UI
Worker Role Worker Role Worker Role Business Layer Data Layer
SQL Azure SQL Azure SQL Azure or or or Azure Storage Azure Storage Azure Storage
Figure 2. Single data center deployment application architecture Locations for SQL Azure and Windows Azure Storage can be specified when establishing the services. It is beneficial to specify the same data center for your application as you use for your data. Keep these things in mind when securing your Windows Azure application, and remember that it is significantly easier to eavesdrop on traffic on the public Internet than it would be to compromise security within an Azure data center and sniff traffic inside the data center.
against that storage location. Also be aware that access to Windows Azure storage will be via the RESTful interfaces and should therefore be secured over SSL. For more information about auditing and logging, see the Security Best Practices for Developing Windows Azure Applications at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=0ff0c25f-dc544f56-aae7-481e67504df6 .
Authentication
Authentication involves verifying the identity of parties accessing your application or services. In Windows Azure, standard username and password credential based systems are possible, as well as claims based identity frameworks that are well suited for cloud implementations. The following practices improve your application's authentication: Do not send passwords over the wire in plaintext. Do not store passwords in user stores. Separate public and restricted areas. Use established password policies.
Be aware of using email to distribute passwords or as part of your password reset procedures. Instead of passing the user credentials in email, consider an alternate approach allowing users to use alternate means to identify themselves (such as secrets) in the UI and reset the password.
Authorization
Authorization covers the control over accessing resources within your application. In Windows Azure these resources also include controlling access to Windows Azure Storage, SQL Azure and WCF services. Traditional Role Based Authorization Control (RBAC) and claims based systems are covered here. The following practices improve your application's authorization: Use multiple gatekeepers. Consider authorization granularity. Restrict user access to system-level resources. Use RESTful interfaces carefully Separate public and restricted areas.
Communication
Communication encompasses how data is transmitted over the wire. This includes encrypting the entire channel for applications with SSL, but also security web services with transport or message based security. Certificate and key management for SSL are also topics covered here. The following practices improve your application's communication security: Windows Azure Storage should not use container names based on user input. Protect sensitive data over the wire. Periodically change your keys. Optimize communication security over performance. Check for accidental information disclosure.
Windows Azure Storage should not use container names based on user input.
Windows Azure Storage is accessed using RESTful interfaces. This can place data at risk of injection attacks if the attacker is able to affect the URI being called during data operations. Because of this, it is recommended avoid using user input for Windows Azure Storage names when possible. In the event that user input is needed, be sure to sanitize the user input by encoding it before using it. For more information on this, see Security Best Practices for Developing Windows Azure Applications at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=0ff0c25f-dc544f56-aae7-481e67504df6 .
Configuration Management
Configuration management involves the securing of both application configuration as well as administration interfaces. In Windows Azure this includes the Windows Azure Portal and issues surrounding configuration and configuration stores. The following practices improve your application's configuration management: Maintain separate administration privileges. Use separate storage accounts. Dont test with production data. Encrypt sensitive data in configuration files. Protect your administration interfaces.
Cryptography
Cryptography in Windows Azure exposes some differences from on-premise solutions. Security restrictions imposed by the Windows Azure trust policies will require alternate approaches to handling of secure stores and encryption. The following practices improve your application's cryptographic processes: Dont roll your own cryptography. Protect your encryption keys. Dont use encrypted values as index columns or partition keys. Use the correct algorithm and correct key length. Maintain different keys for different environments.
Exception Management
Exception management encompasses the handling of errors and exceptions in your application. Practices in this area are largely the same as for on-premise solutions. The following practices improve your application's exception handling: Catch exceptions, and fail gracefully. Log detailed error messages. Do not leak information to the client. Determine exception strategy at your boundaries.
For more information on how to validate for length, range, format, and type, see the help file contained in the Web Client Guidance project at http://webclientguidance.codeplex.com/releases/view/46436 .
For more information on how to implement this can be found in the How to: Perform Input and Data Validation chapter in http://webclientguidance.codeplex.com/releases/view/46436.
Sanitize output.
Input can host harmful script or other components. Encode any output that is derived from input, as this will render it harmless. Use an established encoding library like the Anti-Cross Site Scripting Library at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=051ee83c-5ccf48ed-8463-02f56a6bfc09. Specifics on this and other encoding practices can be found in Input and Data Validation in the Web Client Guidance project at http://webclientguidance.codeplex.com/releases/view/46436.
Additional Considerations
The following are some additional considerations: Assume all input, and/or untrusted data is malicious. Validate all values sent from client. Make sure that users do not bypass your checks
Sensitive Data
Personal data and High Business Impact (HBI) data must be protected in your application. This includes sensitive data in persistent storage, as well as data in memory and passed over the network. In Windows Azure additional communication channels exist that should be handled when considering sensitive data. The following practices improve your application's handling of sensitive data: Encrypt the data or secure the communication channel. Do not store secrets if you can avoid it. Do not store secrets in code. Do not store database connections, passwords, or keys in plaintext. Do not pass sensitive data using the HTTP-GET protocol.
Windows Azure application and ensure exceptions are handled at these boundaries. Avoid storing secrets. Establish an encryption strategy for secret stores.
Additional Considerations
Disaster Recovery
When building your application, define and assess your needs for disaster recovery. It is important to know that the Windows Azure SLA requires at least 2 instances of a web or worker role to be active in order for the SLA to be in effect. This will ensure that your application remains functional and that the data is continuously available. However, the SLA does not cover scenarios in which the data is inadvertently corrupted due to errors in application code, or applications that fail due to mistakes made in deployment such as deploying the wrong version of code or buggy code. You disaster recovery plans should include processes for failover in the event of code errors, or data errors not covered by the SLA.
Additional Resources
patterns & practices Improving Web Application Security Threats and Countermeasures http://msdn.microsoft.com/en-us/library/ff649874.aspx patterns & practices Security Guidance for Applications - http://msdn.microsoft.com/enus/library/ff650760.aspx patterns & practices Web Client Guidance http://webclientguidance.codeplex.com/releases/view/46436 Security Best Practices for Developing Windows Azure Applications at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=0ff0c25fdc54-4f56-aae7-481e67504df6 . Security Development Lifecycle - http://www.microsoft.com/security/sdl/
Overview
Here we present each scenario and some distinguishing characteristics to help you align your situation to a particular solution. We also call out explicit benefits of the scenarios and considerations to be aware of.
Existing guidance is widely available. SQL providers ship with the .NET Framework and have been extensively tested. A large amount of product documentation and samples exist for SQL providers. User data stored in SQL Azure can be relational which makes it more flexible for use in other functions beyond authentication. There is no cost per transaction.
You can leverage existing Active Directory user stores through Active Directory Federation Services (ADFS v2). This is an implementation of Single Sign-On. Uses security tokens instead of credentials, which is more secure because credentials are not passed over the network. Building around claims allows you to separate authentication logic from application logic.
Windows Azure Storage provides only 1 index per table, which limits the querying capability into the user store. At the time of this writing, the provider is a sample, and has not been rigorously tested like established providers like SqlMembershipProvider. Membership will pass credentials over wire when authenticating. They should be protected during communication by using SSL. If you update your authentication code, you will need to re-deploy the application. Membership will pass credentials over wire when authenticating. They should be protected during communication by using SSL. Building a new user store will cause additional work for administrators when adding users to the system. This can be a bigger problem in large corporate environments due to the large number of systems that are managed. SQL Azure has database size limitations, which may force partitioning of user data across multiple databases. If you update your authentication code, you will need to re-deploy the application. Corporate user store exposed to public Internet. Management of trust relationships between applications and Secure Token Services such as ADFS are a manual process. Corporate IT policies may require re-establishing trust relationships which would be manual.
Tokens issued by ADFS can be used to access REST services protect by AppFabric Access Control. You can leverage existing Active Directory user stores through Active Directory Federation Services (ADFS v2). This is an implementation of Single Sign-On. This is an implementation of federated identity. Uses security tokens instead of credentials, which is more secure because credentials are not passed over the network. Building around claims allows you to separate authentication logic from application logic.
Corporate user store exposed to public Internet. Management of trust relationships between applications and Secure Token Services such as ADFS are a manual process. Corporate IT policies may require re-establishing trust relationships which would be manual.
Overview
This is a set of web application scenarios presented visually. We give you a baseline scenario to easily map to your application, and then present a solution overlay. We summarize the solution parts and overall approach.
Key Scenarios
ASP.NET Forms Authentication to Azure Tables ASP.NET Forms Authentication to SQL Azure ASP.NET to AD with Claims ASP.NET to AD with Claims (Federated Partner)
Client Browser
ASP.NET App
Data
Solution
Azure Environment SSL Client Browser Web Role ASP.NET App
Private key access controlled
Authorization
Communication
Client Browser
ASP.NET App
SQL Azure
Solution
Azure Environment SSL Client Browser Web Role ASP.NET App
Secure TDS Pipe
SQL Azure
Authorization
Communication
Azure Environment
ASP.Net App
AD
Solution
Trust Relationship
SQL
AD User Store
Role Store
Authorization
Communication
Scenario
On-Premises
Azure Environment
Client Browser
ASP.Net App
AD
Solution
On-Premises SSL Web Role Client Browser SAML Token AD Identity Provider (ADFS2 STS) Partner Identity Provider (STS) Trust Relationships ASP.Net App WIF App Data Encrypted TDS Pipe Web Role Role Store Federation Provider (STS) WIF User Store SQL Azure Azure Environment
Authentication
Authorization
Communication
Authenticate client browser against Active Directory. Obtain user credentials as claims. Use Active Directory Federation Services (ADFS) to provide claims. Authenticate users in application using claims. Corporate users obtain authentication token from Federation provider web role using a claims token provided by ADFS v2 . Store partner identities in SQL Azure. Partner clients use Federation provider web role to obtain authentication token. Establish trust relationship between ASP.NET app and Azure hosted Federation Provider Secure Token Service (STS). Establish trust relationship between ADFS and Azure Federation Provider STS. Establish trust relationship between partner Identity Providers and Azure Federation Provider STS. Authorize users against claims. Authorize in application logic. Use on-site SQL Server for additional claims beyond what AD can provide. Communicate claims using WS-* protocols. Protect claims over the wire using Security Assertion Markup Language (SAML). Protect SAML tokens with SSL.
Overview
Here we present each scenario and some distinguishing characteristics to help you align your situation to a particular solution. We also call out explicit benefits of the scenarios and considerations to be aware of.
ASP.NET authentication is independent of WCF authentication. Username authentication for WCF service allows you to flow identity from the client to the WCF service. You can audit at the user level because the user name is provided in the username authentication. Authentication logic can be updated independently of application code. Claims authorization allows for more fine grained authorization. Identity federation enables trust relationships between application and other domains or identity providers. Users log into their own domain prior to accessing the application. Can integrate with REST services because SAML claims tokens can be converted to Simple Web Tokens. Supports claims based authorization scenarios. Can integrate with Active Directory. Enables federated identity scenarios for REST-based
authorization requires authorization logic at application level. Service is authenticated when it is registered in the client. The client is authenticated when it can sign the messages using the certificate delivered during registration. If you update your authentication code, you will need to re-deploy the service. If you wish to flow original caller identity, it must be done with custom code. Uses one-way authentication of the service. If you update your authentication code, you will need to re-deploy the service.
Trust relationships are a manual process. This will require more management overhead. Application logic to build required SAML token to flow context is more complex. There are special considerations for deploying WIFenabled services and for implementing identity federation at the ASP.NET application.
Active Directory support is achieved by converting SAML claims to SWT with AppFabric Access Control. This is the primary authentication story for Microsoft REST based services. Other approaches would
services. Supports identity providers such as ADFS or others that can issue SAML tokens.
be custom code. Requires the use of AppFabric Access Control which is a separate cost to a base Windows Azure subscription.
You will authenticate and authorize within the REST service using claims. You may have the need to leverage claims in SAML tokens.
Overview
This is a set of visual scenarios for cloud hosted web services. We give you a baseline scenario to easily map to your application, and then present a solution overlay. We summarize the solution parts and overall approach.
Key Scenarios
The following application scenarios represent a set of common application implementations on the Windows Azure platform involving web based services. ASP.NET to WCF ASP.NET On-Site to WCF on Windows Azure ASP.NET to WCF with Claims REST Service with AppFabric Access Control
ASP.NET to WCF
Scenario
Azure Environment
ASP.NET App
WCF Service
Solution
Azure Environment Web Role ASP.NET App SSL Web Role WCF (Web Service)
Proxy
Service Auth
Authorization Communication
ASP.NET App
Solution
On-premises Azure Environment Web Role ASP.NET App Proxy Web Server Message Encryption WCF (Web Service)
Username Auth
Authorization Communication
ASP.NET App
WCF Service
Solution
Identity Provider Trust relationship Trust relationship STS
Azure Environment
WCF Service
Web Role
ws2007FederationHttpBinding
Authorization Communication
Scenario
Azure Environment
App Client
REST Service
Solution
Azure Environment AppFabric ACS SWT (Simple Web Token) Trust Relationship
Authorization Communication
Overview
Here we present each scenario and some distinguishing characteristics to help you align your situation to a particular solution. We also call out explicit benefits of the scenarios and considerations to be aware of.
Existing SQL Server logic is almost a direct port to SQL Azure. SQL Providers from ASP.NET have been extensively tested Data is relational. Many existing SQL tools can be used. Can be used as a migration step for moving an application to cloud. Scenario is based around setting up Data as a Service (DaaS).
table. Authentication and authorization should be implemented in application code because of only 1 data connection to Azure Storage. SQL Azure has fixed database size increments. Large amounts of data may require data partitioning. SQL Connection should be protected by encrypting the TDS connection.
Can be used as a migration step for moving an application to cloud. Exposes Data as a Service (Daas), which can lower the amount of code changes needed if data is moved to the cloud.
On-site ASP.NET application may need to be deal with latency when receiving cloud data. Connections to WCF occur as service identity so authorization logic must be implemented in the application. To flow user identity through to WCF service, custom code is needed. Management of SQL credentials (password expiration, changes, etc) are a manual process. Windows Azure ASP.NET application may need to be deal with latency when handling data hosted on-site. Connections to WCF occur as service identity so authorization logic must be implemented in the application. To flow user identity through to WCF service, custom code is needed.
Your data only needs to be accessed on 1 or 2 keys. The data will not have a service interface for its front-end.
Overview
This is a set of visual scenarios for cloud hosted applications involving data storage. We give you a baseline scenario to easily map to your application, and then present a solution overlay. We summarize the solution parts and overall approach.
Key Scenarios
ASP.NET to Azure Storage ASP.NET to SQL Azure ASP.NET On-Site to Data on Azure through WCF ASP.NET on Windows Azure to SQL Server On-Site
Browser
ASP.Net App
Azure Storage
Solution
Azure Environment
Shared Key Encrypted Connection ASP.Net App
Azure Storage
Forms Authentication
Authorization Communication
Browser
ASP.Net App
SQL Azure
Solution
Azure Environment
App Data Alice Bob Browser Carol Doug Forms Authentication SQL Users SQL Roles ASP.Net App Encrypted TDS Pipe
SQL Azure
Authorization Communication
Scenario
On-Site Azure Environment
ASP.NET App
Service
SQL Azure
Solution
On-Site
Alice Bob Carol Doug Proxy Service Auth Secure TDS pipe ASP.NET App SSL WCF Service
Azure Environment
SQL Azure
Web Server
Web Role
Authorization Communication
Scenario
On-Premises Azure Environment
SQL
WCF Service
ASP.NET App
Solution
On-Site
Service Bus SQL Server WCF Service ASP.NET App
1433 443
Azure Environment
Alice Bob Carol Doug
Web Server
Web Role
Authorization Communication
The table below briefly outlines some important distinctions with some specific implementation details as well. Change General Impact Because of dynamic IPs, use DNS names instead of IP addresses Design for stateless and loosely coupled systems, services, and data Scope cookies to sub-domains, otherwise they will be shared across all Azure applications Cookie encryption should be compatible with web farms, change default cookie encryption to RsaEncryptionCookieTransform Management Windows Azure management portal is restricted by Live ID. Control for portal distribution and management of Live IDs will be required. Windows Azure portal provides Deployment APIs which provide alternate means of interfacing with the portal than the Web UI. Access is controlled by certificate authentication. Certificates are managed through the portal and must be rolled into the deployment process. Certificate management processes will need to be defined. Web Role Exposes HTTP(S) endpoints to the Internet. Can expose other TCP ports to the Internet. Port 80, 443 traffic is controlled by IIS. Worker Role Typically similar to Windows services, intended to run as background work processes. Can expose TCP ports called Input Endpoints to the Internet. Windows Access is controlled by a symmetric key. Access keys Key management Azure Storage mechanism needed Windows Azure Storage access ultimately resolve to REST calls to Azure storage.
Due to REST interfaces, data is transferred using HTTP or HTTPS as transport. BLOB storage has an alternate access key called Shared Access Signatures that grant temporary access to the BLOB. Windows Azure VM drives are hosted in Azure BLOB storage called Windows Azure Drives. Data can be accessed directly via RESTful interfaces, and may require data centric AuthN/AuthZ strategies to secure data. Throttling will happen if too many requests are made in a short time period. Deploy your application to the same data center as your Windows Azure storage for better performance. Blobs, Entities, and Messages have different ways to locate and access them. Blob partition keys are ContainerNam + BlobName. Enttity partition keys are TableName + PartitionKey. Message partition keys are QueueName. See Windows Azure Storage Abstractions and their Scalability Targets http://blogs.msdn.com/b/windowsazurestorage/archive/2010/05/10/win dows-azure-storage-abstractions-and-their-scalability-targets.aspx SQL Azure SQL Azure provides SQL authentication only, no integrated security. Application designs requiring granular authorization will need user provisioning interfaces. SQL Azure can restrict access by IP address via the SQL Azure firewall. Beware of connectivity issues if the client IP is dynamic as in the cases of DHCP and proxies. Lack of user management (provisioning) integration with ADFS SQL Azure firewall can permit service connections. This allows IPs inside of the Azure domain to connect. To avoid injection, avoid building connection strings using string concatenation, use SqlConnectionStringBuilder class instead. SQL Azure connections can be encrypted by using Encrypt=true connection property. This forces authentication over SSL. Use Persist Security Info=false. Setting Persist Security Info to true or yes allows security-sensitive information, including the user ID and password, to be obtained from a connection after it has been opened. Throttling will happen if too many requests are made in a short time period. Queries can time out if they take too long to execute. AppFabric Access Control provides claims mapping. It can convert SAML tokens to SWT Access Control tokens. Configuration is through management portal. Live IDs providing access should be managed. Tokens are signing by a shared key. Service cannot prove to a third party that a token was signed by AC and not by the service itself. Therefore you cannot achieve non-repudiation with AC issues tokens
Token signing keys should be rolled over occasionally, requiring a rollover process. AppFabric Provides 3 forms of authentication; Shared Secret authentication, SAML Service Bus authentication, SWT (Simple Web Token) authentication Service Bus based services are inherently discoverable. To allow access only through specific URIs, set DiscoverType.Private on the ServiceRegistrySettings endpoint behavior. Runtime 2 Windows Azure specific levels; Full Trust, and Windows Azure partial trust Security (Code Full Trust is default Access Many permissions are blocked in Windows Azure, some key restrictions Security) include: Registry, Event Log, and Reflection. Full list can be found at: http://msdn.microsoft.com/en-us/library/dd573355.aspx
Deployment Considerations
Check Description The design identifies operations that can be performed outside of the current data center. The design groups application pieces in a single deployment package when they must be hosted in the same data center. The application uses internal endpoints for tightly bound Inter-Process Communications. The application uses Windows Azure Storage queues for loosely bound IPC. Application data is hosted in the same data center as the application components. The IT policies define distinct roles for parties associated with application development, design, deployment, testing and management. The policies restrict roles from operations that exceed their defined responsibilities. Windows Azure Portal Live IDs are not distributed to parties who do not perform application administration. Deployment certificates are installed in the Windows Azure Portal for deployment roles, and only distributed to parties responsible for application deployment.
the application. All information to be logged in event logs or audits is processed using sanitization logic. The design identifies the storage, security, and analysis of the application log files.
Authentication
Check Description Passwords are either encrypted or converted to a token before communication. The design identifies secure storage of credentials that are accepted from users. The design partitions the Web site into public and restricted areas using separate folders. The design specifies criteria for a strong password, and enforces the password requirements with code and policies. The design specifies criteria for a strong passphrases, and enforces the passphrase requirements. The design establishes policies for account management. The design specifies a mechanism for locking bad accounts out. The application supports the disabling of an account, account lockout, and expiration. Password history (with salt) is stored in the user store for verification.
Authorization
Check Description The application has additional security checks implemented after the initial authentication process. The role design offers sufficient separation of privileges (the design considers authorization granularity). Data creation, updating and deletion procedures exposed via RESTful interfaces are authorized when possible. Data creation, updating and deletion procedures exposed via RESTful interfaces use HTTP POST requests, not HTTP GET.
Communication
Check Description Names used for Windows Azure Storage containers are not created directly from user provided data, but first sanitized or hashed. Information communicated over the wires is either encrypted or protected in transport with an encrypted protocol such as SSL.
Application management policies include procedures for managing encryption keys, including expiration and rotation. Application management policies include procedures for managing Windows Azure Storage access keys, including expiration and rotation. The application design specifies performance considerations for security decision points such as encryption strategies. Outbound data is filtered for confidential information.
Configuration Management
Check Description Administrator privileges are separated based on roles (for example, developer or system administrator). Protected data that is segregated is accessed using a different access key than unprotected data. Configuration secrets are not held in plain text in configuration files. Production data sources are not used for test environments, data connections specify test data sources. Test data is manufactured, not a copy of live data. Administration interfaces are protected with strong authentication and authorization logic.
Cryptography
Check Description Platform-level cryptography is used and it has no custom implementations. Encryption keys are stored in a secure form or location, they are not stored in cleartext, and key pair installation files are not left on the VM drive. Windows Azure Storage partition keys use values that are not hashed or encrypted. SQL Azure index columns use values that are not hashed or encrypted. One-way hashes use SHA encryption with a key length of 256-bit or larger. Symmetric encryption uses AES encryption with a key length of 256-bit larger. Asymmetric encryption and decryption uses RSA encryption with 2048-bit or larger keys. Encryption keys used in the production environment are different from keys used in non-production environments such as test. Encryption keys used in the production environment have been issued from a Certificate Authority and are not self-signed certificates.
Exception Management
Check Description The design outlines a standardized approach to structured exception handling across the application. Application errors are logged to the error log. Application exception handling minimizes the information disclosure in case of an exception. The design clearly defines which piece is responsible for handling exceptions at application boundaries like service calls or IPC.
Sensitive Data
Check Description The design identifies protection mechanisms for sensitive data that is sent over the network. Secrets are not stored unless necessary. (Alternate methods have been explored at design time.) Secrets are not stored in code. Database connections, passwords, keys, or other secrets are not stored in plain text. Sensitive data is not transmitted with the GET protocol.
Overview
With an a visual understanding of the application scenarios, we now overlay threats, vulnerabilities and countermeasures on top of a canonical example of a scenario to call out specific points of attack and defense. Visually overlaying these components helps us understand the impact on our application designs.
Scenario
Azure Environment SSL Client Browser Web Role ASP.NET App
Private key access controlled
Threats / Attacks
Cookie replay Cookie manipulation HTTP header manipulation Parameter manipulation
Windows Azure
Session hijacking Credential theft F i r e Http w a l l
Windows Azure
Data tampering F i r e w a l l
Web Role
ASP.NET App Forms AuthN Roles AuthZ
Client Browser
Azure Storage
Man-in-the-middle
Vulnerabilities
Long-life encryption keys Secrets in code Clear-text credentials F i r e w a l l Custom cryptography Unsecure key distribution Unsecured encryption keys
Windows Azure
Web Role
ASP.NET App Forms AuthN Roles AuthZ
Windows Azure
F i r e w a l l
Client Browser
Http
Azure Storage
Weak passwords
Unauthenticated REST
Clear-text secrets
Unencrypted REST
Countermeasures
Windows Azure
Web Role
F i r e Http w a l l ASP.NET App Forms AuthN Roles AuthZ SSL Consider granularity of access Avoid exposing sensitive info to web space
Windows Azure
Authenticate and authorize session store access F i r e w a l l
Client Browser
Azure Storage
Overview
With an a visual understanding of the application scenarios, we now overlay the threats, vulnerabilities and countermeasures on top of a canonical example of a scenario to call out specific points of attack and defense. Visually overlaying these components helps us understand the impact on our application designs.
Scenario
Windows Azure
Web Service Service Interface Business SQL Azure
Data Access
Threats / Attacks
Replay attack Eavesdropping / Tampering
Windows Azure
Web Service Service Interface
Denial of Service
Business
Data Access
Dictionary attack
Vulnerabilities
Insecure channel Revealing sensitive data
Windows Azure
Web Service Service Interface
Failure to validate messages Insecure configuration stores Insecure channel Failure to audit SQL Azure
Data Access
Countermeasures
Windows Azure
Web Service Service Interface
Exception Management
Parameterized queries
Encryption
Authentication
Authorization
Sensitive Data
Session Management
Vulnerabilities
Category Auditing and Logging Authentication Vulnerabilities Failing to audit failed logons. Failing to audit across application tiers. Azure Blobs - Secure Access Signature distribution over HTTP. Azure Blobs expired or bad Secure Access Signatures not revoked. Azure Blobs - Secure Access Signature lifetime too long. Storing clear text credentials in configuration files. Passing clear text credentials over the network. Using weak passwords. Permitting over-privileged accounts. Permitting prolonged session lifetime. Mixing personalization with authentication. Relying on a single gatekeeper. Failing to limit database access to specified stored procedures. Using inadequate separation of privileges. Using insecure configuration stores. Storing clear text configuration data. Using insecure administration interfaces. Having too many administrators. Using custom cryptography. Failing to secure encryption keys. Using the wrong algorithm or a key size that is too small. Using the same key for a prolonged period of time. Distributing keys in an insecure manner. Failing to use structured exception handling. Revealing too much information to the client. Insecure file upload to Windows Azure Storage BLOBs. Using non-validated input in the Hypertext Markup Language (HTML) output stream. Failure to uniquely identify transactions. Failing to validate input from all sources including cookies, query string parameters, HTTP headers, databases, and network resources. Using non-validated input used to generate SQL queries. Relying on client-side validation. Using input file names, URLs, or user names for security
Authorization
Configuration Management
Cryptography
Sensitive Data
Session Management
decisions. Using application-only filters for malicious input. Looking for known bad patterns of input. Trusting data read from databases, file shares, and other network resources. Storing secrets in code. Storing secrets in clear text. Storing secrets when you do not need to. Passing sensitive data in clear text over networks. Having insecure session state stores. Permitting prolonged session lifetime. Passing session identifiers over unencrypted channels. Placing session identifiers in query strings.
Countermeasures
Category Auditing and Logging Countermeasures Identify malicious behavior. Know your baseline (know what good traffic looks like). Use application instrumentation to expose behavior that can be monitored. Encrypt communication channels to secure authentication tokens. Use HTTPS only with forms authentication cookies. Use authentication mechanisms that do not require clear text credentials to be passed over the network. Do not store credentials. Use strong password policies. Separate anonymous from authenticated pages. Use multiple gatekeepers. Consider granularity of access. Enforce separation of privileges. Use least privilege accounts. Do not store credentials in clear text. Avoid storing sensitive information in the Web space. Use only local administration. Use strong authentication and authorization on administrative interfaces. Do not develop and use proprietary algorithms (XOR is not encryption. Use established cryptography such as RSA) Avoid key management.
Authentication
Authorization
Configuration Management
Cryptography
Exception Management
Sensitive Data
Session Management
Use the RNGCryptoServiceProvider method to generate random numbers. Periodically change your keys. Do not log private data such as passwords. Do not reveal sensitive system or application information. Use structured exception handling (by using try/catch blocks). Catch and wrap exceptions only if the operation adds value/information. Do not trust input. Validate input: length, range, format, and type. Constrain, reject, and sanitize input. Encode output. Uniquely identify transactions. Do not store secrets in software. Encrypt sensitive data over the network. Secure the channel. Secure the channel to the session store. Authenticate and authorize access to the session store. Partition site by anonymous, identified, and authenticated users. Reduce session timeouts. Avoid storing sensitive data in session stores.
Cheat Sheet - Web Service (SOAP) Security Threats and Countermeasures at a Glance
Category Auditing and Logging Threats/Attacks Authentication Repudiation. An attacker denies performing an operation, exploits an application without trace, or covers his or her tracks. Denial of service (DoS). An attacker overwhelms logs with excessive entries or very large log entries. Disclosure of confidential information. An attacker gathers sensitive information from log files. Network eavesdropping. An attacker steals identity and/or credentials off the network by reading network traffic not intended for them. Brute force attacks. An attacker guesses identity and/or credentials through the use of brute force. Dictionary attacks. An attacker guesses identity and/or credentials through the use of common terms in a dictionary designed for that purpose. Cookie replay attacks. An attacker gains access to an authenticated session through the reuse of a stolen cookie containing session information. Credential theft. An attacker gains access to credentials through data theft; for instance, phishing or social engineering. Elevation of privilege. An attacker enters a system as a lower-level user, but is able to obtain higher-level access. Disclosure of confidential data. An attacker accesses confidential information because of authorization failure on a resource or operation. Data tampering. An attacker modifies sensitive data because of authorization failure on a resource or operation. Luring attacks. An attacker lures a higher-privileged user into taking an action on their behalf. This is not an authorization failure but rather a failure of the system to properly inform the user. Token stealing. An attacker steals the credentials or token of another user in order to gain authorization to resources or operations they would not otherwise be
Authorization
able to access. Configuration Management Unauthorized access to configuration stores. An attacker gains access to configuration files and is able to modify binding settings, etc. Retrieval of clear text configuration secrets. An attacker gains access to configuration files and is able to retrieve sensitive information such as database connection strings. Information disclosure. Sensitive system or application details are revealed through exception information. Denial of service. An attacker uses error conditions to stop your service or place it in an unrecoverable error state. Elevation of privilege. Your service encounters an error and fails to an insecure state; for instance, failing to revert impersonation. Elevation of privilege. An attacker is able to run in the context of a higher-privileged user. Disclosure of confidential information. An attacker gains access to data that should only be available to another user. Failure to encrypt messages. An attacker is able to read message content off the network because it is not encrypted. Theft of encryption keys. An attacker is able to decrypt sensitive data because he or she has the keys. Man-in-the-middle attack. An attacker can read and then modify messages between the client and the service. Session replay. An attacker steals messages off the network and replays them in order to steal a users session. Data tampering. An attacker modifies the data in a message in order to attack the client or the service. Canonicalization attacks. Canonicalization attacks can occur anytime validation is performed on a different form of the input than that which is used for later processing. For instance, a validation check may be performed on an encoded string, which is later decoded and used as a file path or URL.
Exception Management
Impersonation/Delegation
Message Encryption
Cross-site scripting. Cross-site scripting can occur if you fail to encode user input before echoing back to a client that will render it as HTML. SQL injection. Failure to validate input can result in SQL injection if the input is used to construct a SQL statement, or if it will modify the construction of a SQL statement in some way. XPath injection. XPath injection can result if the input sent to the Web service is used to influence or construct an XPath statement. The input can also introduce unintended results if the XPath statement is used by the Web service as part of some larger operation, such as applying an XQuery or an XSLT transformation to an XML document. XML bomb. XML bomb attacks occur when specific, small XML messages are parsed by a service resulting in data that feeds on itself and grows exponentially. An attacker sends an XML bomb with the intent of overwhelming a Web services XML parser and resulting in a denial of service attack. Memory dumping. An attacker is able to read sensitive data out of memory or from local files. Network eavesdropping. An attacker sniffs unencrypted sensitive data off the network. Configuration file sniffing. An attacker steals sensitive information, such as connection strings, out of configuration files. Session hijacking. An attacker steals the session ID of another user in order to gain access to resources or operations they would not otherwise be able to access. Session replay. An attacker steals messages off the network and replays them in order to steal a users session. Man-in-the-middle attack. An attacker can read and then modify messages between the client and the service. Inability to log out successfully. An application leaves a communication channel open rather than completely closing the connection and destroying any server objects in memory relating to the session. Cross-site request forgery. Cross-site request forgery (CSRF) is where an attacker tricks a user into performing an action on a site where the user actually
Sensitive Data
Session Management
has a legitimate authorized account. Session fixation. An attacker uses CSRF to set another persons session identifier and thus hijack the session after the attacker tricks a user into initiating it. Load balancing and session affinity. When sessions are transferred from one server to balance traffic among the various servers, an attacker can hijack the session during the handoff.
Vulnerabilities
Category Auditing and Logging Vulnerabilities Authorization Configuration Management Failing to audit failed logons. Failing to secure log files. Storing sensitive information in log files. Failing to audit across application tiers. Failure to throttle log files. Broad distribution of Azure LiveID Failure to roll-over certificates Storing clear text credentials in configuration files. Using weak passwords. Passing clear text credentials over the network. Permitting prolonged session lifetime. Mixing personalization with authentication. Using weak authentication mechanisms (e.g., using basic authentication over an untrusted network). Relying on a single gatekeeper (e.g., relying on clientside validation only). Failing to limit database access to specified stored procedures. Using inadequate separation of privileges. Connection pooling. Permitting over-privileged accounts. Using insecure custom administration interfaces. Failing to secure configuration files on the server. Storing sensitive information in the clear text. Having too many administrators. Using over-privileged process accounts and service accounts. Failure to use structured exception handling (try/catch).
Authentication
Exception Management
Revealing too much information to the client. Failure to specify fault contracts with the client. Failure to use a global exception handler. Failure to revert to a lower privilege after using impersonation. Improper use of global impersonation across the entire service. Not encrypting messages. Using custom cryptography. Distributing keys insecurely. Managing or storing keys insecurely Failure to use a mechanism to detect message replays. Not using either message or transport security. Using non-validated input used to generate SQL queries. Relying only on client-side validation. Using input file names, URLs, or usernames for security decisions. Using application-only filters for malicious input. Looking for known bad patterns of input. Trusting data read from databases, file shares, and other network resources. Failing to validate input from all sources including cookies, Simple Object Access Protocol (SOAP) headers, SOAP parameters, databases, and network resources. Storing secrets when you do not need to. Storing secrets in code. Storing secrets in clear text in files, registry, or configuration. Passing sensitive data in clear text over networks. Passing session IDs over unencrypted channels. Permitting prolonged session lifetime. Having insecure session state stores. Placing session identifiers in query strings
Sensitive Data
Session Management
Countermeasures
Category Auditing and Logging Countermeasures Identify malicious behavior.
Know your baseline (know what good traffic looks like). Use application instrumentation to expose behavior that can be monitored. Throttle logging. Strip sensitive data before logging. Use strong password policies. Do not store credentials in an insecure manner. Use authentication mechanisms that do not require clear text credentials to be passed over the network. Encrypt communication channels to secure authentication tokens. Use Secure HTTP (HTTPS) only with forms authentication cookies. Separate anonymous from authenticated pages. Using cryptographic random number generators to generate session IDs. Use least-privileged accounts. Tie authentication to authorization on the same tier. Consider granularity of access. Enforce separation of privileges. Use multiple gatekeepers. Secure system resources against system identities. Encrypt sensitive sections of configuration files. Use secure settings for various operations of Web services using configuration files. Use structured exception handling (by using try/catch blocks). Catch and wrap exceptions only if the operation adds value/information. Do not reveal sensitive system or application information. Implement a global exception handler. Do not log private data such as passwords. Use Using statement to automatically revert impersonation. Granularly impersonate only those operations that need it. Use message security or transport security to encrypt your messages. Use proven platform-provided cryptography.
Periodically change your keys. Use any platform-provided replay detection features. Consider creating custom code if the platform does not provide a detection mechanism. Turn on message or transport security. Do not trust client input. Validate input: length, range, format, and type. Validate XML streams. Constrain, reject, and sanitize input. Encode output. Restrict the size, length, and depth of parsed XML messages. Do not store secrets in software. Encrypt sensitive data over the network. Secure the channel. Encrypt sensitive data in configuration files. Partition the site by anonymous, identified, and authenticated users. Reduce session timeouts. Avoid storing sensitive data in session stores. Secure the channel to the session store. Authenticate and authorize access to the session store.
Sensitive Data
Session Management
Cheat Sheet Web Services (REST) Security Threats and Countermeasures at a Glance
Category Auditing and Logging Threats/Attacks Authentication Repudiation. An attacker denies performing an operation, exploits an application without trace, or covers his or her tracks. Denial of service (DoS). An attacker overwhelms logs with excessive entries or very large log entries. Disclosure of confidential information. An attacker gathers sensitive information from log files. Network eavesdropping. An attacker steals identity and/or credentials off the network by reading network traffic not intended for them. Brute force attacks. An attacker guesses identity and/or credentials through the use of brute force. Dictionary attacks. An attacker guesses identity and/or credentials through the use of common terms in a dictionary designed for that purpose. Cookie replay attacks. An attacker gains access to an authenticated session through the reuse of a stolen cookie containing session information. Credential theft. An attacker gains access to credentials through data theft; for instance, phishing or social engineering. Elevation of privilege. An attacker enters a system as a lower-level user, but is able to obtain higher-level access. Disclosure of confidential data. An attacker accesses confidential information because of authorization failure on a resource or operation. Data tampering. An attacker modifies sensitive data because of authorization failure on a resource or operation. Luring attacks. An attacker lures a higher-privileged user into taking an action on their behalf. This is not an authorization failure but rather a failure of the system to properly inform the user. Token stealing. An attacker steals the credentials or token of another user in order to gain authorization to resources or operations they would not otherwise be
Authorization
able to access. Configuration Management Unauthorized access to configuration stores. An attacker gains access to configuration files and is able to modify binding settings, etc. Retrieval of clear text configuration secrets. An attacker gains access to configuration files and is able to retrieve sensitive information such as database connection strings. Information disclosure. Sensitive system or application details are revealed through exception information. Denial of service. An attacker uses error conditions to stop your service or place it in an unrecoverable error state. Elevation of privilege. Your service encounters an error and fails to an insecure state; for instance, failing to revert impersonation. Elevation of privilege. An attacker is able to run in the context of a higher-privileged user. Disclosure of confidential information. An attacker gains access to data that should only be available to another user. Failure to encrypt messages. An attacker is able to read message content off the network because it is not encrypted. Theft of encryption keys. An attacker is able to decrypt sensitive data because he or she has the keys. Man-in-the-middle attack. An attacker can read and then modify messages between the client and the service. Session replay. An attacker steals messages off the network and replays them in order to steal a users session. Data tampering. An attacker modifies the data in a message in order to attack the client or the service. Canonicalization attacks. Canonicalization attacks can occur anytime validation is performed on a different form of the input than that which is used for later processing. For instance, a validation check may be performed on an encoded string, which is later decoded and used as a file path or URL.
Exception Management
Impersonation/Delegation
Message Encryption
Cross-site scripting. Cross-site scripting can occur if you fail to encode user input before echoing back to a client that will render it as HTML. SQL injection. Failure to validate input can result in SQL injection if the input is used to construct a SQL statement, or if it will modify the construction of a SQL statement in some way. XPath injection. XPath injection can result if the input sent to the Web service is used to influence or construct an XPath statement. The input can also introduce unintended results if the XPath statement is used by the Web service as part of some larger operation, such as applying an XQuery or an XSLT transformation to an XML document. XML bomb. XML bomb attacks occur when specific, small XML messages are parsed by a service resulting in data that feeds on itself and grows exponentially. An attacker sends an XML bomb with the intent of overwhelming a Web services XML parser and resulting in a denial of service attack. Memory dumping. An attacker is able to read sensitive data out of memory or from local files. Network eavesdropping. An attacker sniffs unencrypted sensitive data off the network. Configuration file sniffing. An attacker steals sensitive information, such as connection strings, out of configuration files. Session hijacking. An attacker steals the session ID of another user in order to gain access to resources or operations they would not otherwise be able to access. Session replay. An attacker steals messages off the network and replays them in order to steal a users session. Man-in-the-middle attack. An attacker can read and then modify messages between the client and the service. Inability to log out successfully. An application leaves a communication channel open rather than completely closing the connection and destroying any server objects in memory relating to the session. Cross-site request forgery. Cross-site request forgery (CSRF) is where an attacker tricks a user into performing an action on a site where the user actually
Sensitive Data
Session Management
has a legitimate authorized account. Session fixation. An attacker uses CSRF to set another persons session identifier and thus hijack the session after the attacker tricks a user into initiating it. Load balancing and session affinity. When sessions are transferred from one server to balance traffic among the various servers, an attacker can hijack the session during the handoff.
Vulnerabilities
Category Auditing and Logging Vulnerabilities Authorization Configuration Management Failing to audit failed logons. Failing to secure log files. Storing sensitive information in log files. Failing to audit across application tiers. Failure to throttle log files. Failure to implement authentication on RESTful URIs. Storing clear text credentials in configuration files.
Using weak authentication mechanisms (e.g., using basic authentication over an untrusted network).
Authentication
Using weak passwords. Passing clear text credentials over the network. Permitting prolonged session lifetime. Mixing personalization with authentication. Failure to implement authorization on RESTful URIs. Improper design of REST interfaces Relying on a single gatekeeper (e.g., relying on clientside validation only). Failing to limit database access to specified stored procedures. Using inadequate separation of privileges. Permitting over privileged accounts. Using insecure custom administration interfaces. Failing to secure configuration files on the server. Storing sensitive information in the clear text. Having too many administrators. Using overprivileged process accounts and service accounts. Failure to use structured exception handling (try/catch).
Exception Management
Impersonation/Delegation Message Encryption Message Replay Detection Message Signing Message Validation
Revealing too much information to the client. Failure to specify fault contracts with the client. Failure to use a global exception handler. Failure to revert to a lower privilege after using impersonation. Improper use of global impersonation across the entire service. Sending private or sensitive information clear-text over HTTP. Using custom cryptography. Distributing keys insecurely. Managing or storing keys insecurely Failure to use a mechanism to detect message replays. Sending private or sensitive information clear-text over HTTP Using non-validated input used to generate SQL queries. Relying only on client-side validation. Using input file names, URLs, or usernames for security decisions. Using application-only filters for malicious input. Looking for known bad patterns of input. Trusting data read from databases, file shares, and other network resources. Failing to validate input from all sources including cookies, Simple Object Access Protocol (SOAP) headers, SOAP parameters, databases, and network resources. Sending private or sensitive information clear-text over HTTP Storing secrets when you do not need to. Storing secrets in code. Storing secrets in clear text in files, registry, or configuration. Passing sensitive data in clear text over networks. Passing session IDs over unencrypted channels. Permitting prolonged session lifetime. Having insecure session state stores. Placing session identifiers in query strings
Sensitive Data
Session Management
Countermeasures
Category Auditing and Logging Countermeasures Authentication Authorization Exception Management Impersonation/Delegation Message Encryption Identify malicious behavior. Know your baseline (know what good traffic looks like). Use application instrumentation to expose behavior that can be monitored. Throttle logging. Strip sensitive data before logging. Use authentication mechanisms that do not require clear text credentials to be passed over the network. Do not store credentials in an insecure manner. Separate anonymous from authenticated pages. Use strong password policies. Use multiple gatekeepers. Tie authentication to authorization on the same tier. Consider granularity of access. Use least-privileged accounts. Enforce separation of privileges. Authenticate and authorize access to administration interfaces. Encrypt sensitive sections of configuration files. Use secure settings for various operations of Web services using configuration files. Use structured exception handling (by using try/catch blocks). Catch and wrap exceptions only if the operation adds value/information. Do not reveal sensitive system or application information. Implement a global exception handler. Do not log private data such as passwords. Use Using statement to automatically revert impersonation. Granularly impersonate only those operations that need it. Use message security or transport security to encrypt your messages. Use proven platform-provided cryptography. Periodically change your keys.
Configuration Management
Use any platform-provided replay detection features. Consider creating custom code if the platform does not provide a detection mechanism. Turn on message or transport security. Validate input: length, range, format, and type. Constrain, reject, and sanitize input. Validate XML streams. Do not trust client input. Encode output. Restrict the size, length, and depth of parsed XML messages. Do not store secrets in software. Encrypt sensitive data over the network. Secure the channel. Encrypt sensitive data in configuration files. Partition the site by anonymous, identified, and authenticated users. Reduce session timeouts. Avoid storing sensitive data in session stores. Secure the channel to the session store. Authenticate and authorize access to the session store.
Sensitive Data
Session Management
Repudiation Denial of Service (DoS) Disclosure of confidential information Azure Storage - Eavesdropping: Access to storage account endpoints (blob, table, and queue) over insecure communication channel (HTTP). Azure Blobs - Anonymous(public) access to Container/Blob. Azure Blobs - Replay attack: reuse of shared access signature. SQL Azure - Unauthorized access to SQL login credentials. SQL Azure - Brute forcing login credentials. SQL Azure - Connection re-authentication is not immediate if login password is reset. Dictionary Attacks Replay Attacks Credential Theft Network Eavesdropping Brute Force Attacks SQL Azure - Using over privileged account (Admin account similar to SA) to connect to SQL Azure. Elevation of privilege Disclosure of confidential data Data tampering Luring attacks Token stealing Unauthorized access to storage account key. Unauthorized access to Windows Azure Portal. Unauthorized access to configuration stores. Retrieval of clear text configuration secrets. Encryption cracking. Loss of decryption keys. Revealing sensitive system or application details. Denial of Service attacks SQL Azure - Man-in-the-middle attack lack of SQL Azure certificate validation) HTTP Forgery (CSRF)
Authorization
Configuration Management
Sensitive Data
Session Management
Cookie manipulation Query string manipulation HTTP header manipulation Cross-site Scripting (XSS) Buffer overflows SQL Injection Form field manipulation Accessing sensitive data in storage. Network eavesdropping Information disclosure Session hijacking Session replay Man-in-the-middle attacks
Vulnerabilities
Category Auditing and Logging Authentication Vulnerabilities Failing to audit failed logons Failing to audit across application tiers Azure Blobs Secure Access Signature distribution over HTTP. Azure Blobs - Secure Access Signature failure to revoke. Azure Blobs - Secure Access Signature failure to expire. SQL Azure lack of certificate validation. SQL Azure Failure to force re-authentication on login password reset. Storing clear text credentials in configuration files. Passing clear text credentials over the network. Using weak passwords. Permitting over-privileged accounts. Permitting prolonged session lifetime. Mixing personalization with authentication. SQL Azure - Using over privileged account (Admin account similar to SA) to connect to SQL Azure. Relying on a single gatekeeper. Failing to limit database access to specified stored procedures. Using inadequate separation of privileges. SQL Azure - Access Control: Not restricting access via SQL Azure Firewall. Azure Storage Failure to secure storage account key. Using insecure configuration stores.
Authorization
Configuration Management
Cryptography
Storing clear text configuration data. Using insecure administration interfaces. Having too many administrators. Using custom cryptography. Failing to secure encryption keys. Using the wrong algorithm or a key size that is too small. Using the same key for a prolonged period of time. Distributing keys in an insecure manner. Failing to use structured exception handling. Revealing too much information to the client. Azure Blobs - Insecure file upload to blob storage. Using non-validated input in the Hypertext Markup Language (HTML) output stream. Failure to uniquely identify transactions. Failing to validate input from all sources including cookies, query string parameters, HTTP headers, databases, and network resources. Using non-validated input used to generate SQL queries. Relying on client-side validation. Using input file names, URLs, or user names for security decisions. Using application-only filters for malicious input. Looking for known bad patterns of input. Trusting data read from databases, file shares, and other network resources. Azure Storage Communicating sensitive data over HTTP. Storing secrets in code. Storing secrets in clear text. Storing secrets when you do not need to. Passing sensitive data in clear text over networks. Having insecure session state stores. Permitting prolonged session lifetime. Passing session identifiers over unencrypted channels. Placing session identifiers in query strings.
Sensitive Data
Session Management
Countermeasures
Category Auditing and Logging Countermeasures Identify malicious behavior. Know your baseline (know what good traffic looks like).
Authentication
Authorization
Configuration Management
Cryptography
Exception Management
Sensitive Data
Session Management
Use application instrumentation to expose behavior that can be monitored. Encrypt communication channels to secure authentication tokens. Use HTTPS only with forms authentication cookies. Use authentication mechanisms that do not require clear text credentials to be passed over the network. Do not store credentials. Use strong password policies. Separate anonymous from authenticated pages. Use multiple gatekeepers. Consider granularity of access. Enforce separation of privileges. Use least privilege accounts. Do not store credentials in clear text. Avoid storing sensitive information in the Web space. Use only local administration. Use strong authentication and authorization on administrative interfaces. Do not develop and use proprietary algorithms (XOR is not encryption. Use established cryptography such as RSA) Avoid key management. Use the RNGCryptoServiceProvider method to generate random numbers. Periodically change your keys. Do not log private data such as passwords. Do not reveal sensitive system or application information. Use structured exception handling (by using try/catch blocks). Catch and wrap exceptions only if the operation adds value/information. Do not trust input. Validate input: length, range, format, and type. Constrain, reject, and sanitize input. Encode output. Uniquely identify transactions. Do not store secrets in software. Encrypt sensitive data over the network. Secure the channel. Secure the channel to the session store. Authenticate and authorize access to the session store. Partition site by anonymous, identified, and authenticated users.
How To: Use Forms Authentication with Azure Table Storage Objectives
Use the TableStorageMembershipProvider with forms authentication. Set up the Table Storage membership data store. Restrict the forms authentication cookie to HTTPS connections. Use the membership feature to enforce password complexity rules.
Summary
ASP.NET provides a membership feature that you can use with forms authentication. The membership feature provides an abstraction for the underlying data store used to maintain user credentials such as user names and passwords, and it provides an API that allows you to easily validate user credentials and manage the user data store. ASP.NET supports SQL Server and Active Directory providers, for this how to you would have to use your own providers for Azure Table Storage data store. This How To shows you how to develop a simple Web site that uses forms authentication with the Table Storage membership provider. This provider uses an underlying Table Storage Service as its user store.
Contents
Pre-Requisites Summary of Steps Step 1. Create a New Cloud Service Project. Step 2. Add References to AspProvider Project for the Azure Table Storage Provider Step 3. Add a Login Page Step 4. Create a Way for New Users to Register Step 5. Configure ASP.NET to use Forms Authentication Step 6. Configure ASP.NET to Restrict Anonymous Users Step 7. Configure ASP.NET to Use the Azure Table Storage Provider Step 8. Configure the ASP.NET Membership Provider Step 9. Add Test Code to Page_Load to Show the Forms Authentication Details Step 10. Test Registering a New User and Logging in to the Application
Pre-Requisites
1. Windows Azure SDK 2. Windows Azure Tools for Visual Studio 2008 3. Azure Samples Additional C# Samples
Summary of Steps
Here are the steps at a glance: Step 1. Create a New Cloud Service Project. Step 2. Add References to AspProvider Project for the Azure Table Storage Provider Step 3. Add a Login Page Step 4. Create a Way for New Users to Register Step 5. Configure ASP.NET to use Forms Authentication Step 6. Configure ASP.NET to Restrict Anonymous Users Step 7. Configure ASP.NET to Use the Azure Table Storage Provider Step 8. Configure the ASP.NET Membership Provider Step 9. Add Test Code to Page_Load to Show the Forms Authentication Details Step 10. Test Registering a New User and Logging in to the Application
Step 2. Add a Reference to the AspProvider Project for the Azure Table Storage Provider
We didnt see a Table Storage Membership provider for ASP.NET out of box, but there are samples available for download: 1. Unzip the WindowsAzure-AdditionalSamples.zip to some know location. You can find the Windows Azure Additional Samples on this page. (Note - if you followed my previous post, Getting Started with Windows Azure you should already have these samples.) 2. Right click on the FormsAuthSample solution and choose Add -> Existing Project 3. Browse to the location where you have extracted the samples, and select ASPProviders.proj from \\Samples\AspProviders\Lib folder. This will add the ASPProviders project to your solution.
4. Add the reference to this project to your solution. To do this, expand the WebRole1 node in the solution explorer, and right-click on References. 5. Select Add Reference 6. Select the Projects tab 7. Select AspProviders, and click Ok
Note The preceding configuration allows only authenticated users to access the application. The "?" indicates unauthenticated users and the "*" indicates all users. By denying unauthenticated users, any requests made by unauthenticated users are redirected to the login page. The loginUrl attribute of the <forms> element determines the name of the login page. The default setting of this attribute is Login.aspx.
Note: that we dont have a lot of details on the AccountSharedKey, but we saw Jim Nakashima uses this value, so its good enough for now, until we know more.
Step 9. Add Test Code to Page_Load to Show the Forms Authentication Details
1. Add a using statement to Default.aspx.cs in your WebRole1 project to add a reference to System.Web.Security. 2. Add the following code to Page Load of Default.aspx.cs in WebRole1:
protected void Page_Load(object sender, EventArgs e) { Response.Write("Hello, " + Server.HtmlEncode(User.Identity.Name)); FormsIdentity id = (FormsIdentity)User.Identity; FormsAuthenticationTicket ticket = id.Ticket; // optional - but if you use this add a reference to System.Web.Security Response.Write("<p/>TicketName: " + ticket.Name ); Response.Write("<br/>Cookie Path: " + ticket.CookiePath); Response.Write("<br/>Ticket Expiration: " + ticket.Expiration.ToString()); Response.Write("<br/>Expired: " + ticket.Expired.ToString()); Response.Write("<br/>Persistent: " + ticket.IsPersistent.ToString()); Response.Write("<br/>IssueDate: " + ticket.IssueDate.ToString()); Response.Write("<br/>UserData: " + ticket.UserData);
Step 10. test registering a new user and logging in to the application
1. Run the project by using the F5 key (this runs the project in Debug mode.) 2. Create a new user. On your first visit, you need to create a new user (e.g. bob.) Note that the password rules by default are alphanumeric plus one non-alphanumeric (for example, "password!") 3. Login to the application. Sign in with your new username and password pair. The Web application should return something along the following lines: Hello, bob TicketName: bob Cookie Path: / Ticket Expiration: 3/17/2010 3:04:40 PM Expired: False Persistent: False IssueDate: 3/17/2010 2:34:40 PM UserData: Version: 2
How To: Use Forms Authentication with Local SQL Membership Objectives
Use the SqlMembershipProvider with forms authentication. Set up the aspnetdb membership data store for local development. Restrict the forms authentication cookie to HTTPS connections.
Summary
ASP.NET provides a membership feature that you can use with forms authentication. The membership feature provides an abstraction for the underlying data store used to maintain user credentials such as user names and passwords, and it provides an API that allows you to easily validate user credentials and manage the user data store. ASP.NET supports SQL Server and Active Directory providers. This How To shows you how to develop a simple Web site that uses forms authentication with the SQL membership provider.
Contents
Pre-Requisites Summary of Steps Step 1. Create a New Cloud Service Project. Step 2. Add a Login Page. Step 3. Create a Way for New Users to Register Step 4. Configure ASP.NET to use Forms Authentication Step 5. Configure ASP.NET to restrict Anonymous Users Step 6. Set up the SQL Membership Database Step 7. Add the SQL Connection String Step 8. Configure ASP.NET to Use the Azure Table Storage Provider Step 9. Add Test Code to Page_Load to Show the Forms Authentication Details Step 10. test registering a new user and logging in to the application
Pre-Requisites
1. Windows Azure Tools for Visual Studio 2008 2. Microsoft SQL Server, or SQL Express with Standard or Mixed security model
Summary of Steps
Step 1. Create a New Cloud Service Project. Step 2. Add a Login Page.
Step 3. Create a Way for New Users to Register Step 4. Configure ASP.NET to use Forms Authentication Step 5. Configure ASP.NET to restrict Anonymous Users Step 6. Set up the SQL Membership Database Step 7. Add the SQL Connection String Step 8. Configure ASP.NET to Use the Azure Table Storage Provider Step 9. Add Test Code to Page_Load to Show the Forms Authentication Details Step 10. test registering a new user and logging in to the application
Note The preceding configuration allows only authenticated users to access the application. The "?" indicates unauthenticated users and the "*" indicates all users. By denying unauthenticated users, any requests made by unauthenticated users are redirected to the login page. The loginUrl attribute of the <forms> element determines the name of the login page. The default setting of this attribute is Login.aspx.
<providers> <clear/> <add name="MySqlMembershipProvider" connectionStringName="MyLocalSQLServer" applicationName="MyAppName" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </membership>
Step 9. Add Test Code to Page_Load to Show the Forms Authentication Details
Add a using statement to Default.aspx.cs in your WebRole1 project to add a reference to System.Web.Security. Add the following code to Page Load of Default.aspx.cs in WebRole1:
protected void Page_Load(object sender, EventArgs e) { Response.Write("Hello, " + Server.HtmlEncode(User.Identity.Name) + "<br />"); }
Step 10. test registering a new user and logging in to the application
1. Run the project by using the F5 key (this runs the project in Debug mode.) 2. Create a new user. On your first visit, you need to create a new user (e.g. bob.) Note that the password rules by default are alphanumeric plus one non- alphanumeric (for example, "password!") 3. Login to the application. Sign in with your new username and password pair. 4. The Web application should return something along the following lines: Hello, waldo
How To: Enable SSL with a Self-Signed Certificate on Windows Azure Objectives
Create a self-signed certificate to be used to encrypt an SSL channel Upload a certificate to Windows Azure using the Windows Azure Management portal Enable an HTTPS endpoint on a Windows Azure web role
Summary
Enabling SSL on a Windows Azure web role involves a few easy configuration steps, and deployment of a certificate. HTTPS must be enabled on the web role as an endpoint, the certificate must be associated with that endpoint, and the certificate must also be uploaded to Windows Azure. This how to provides steps on completing these tasks and enabling SSL on a web role.
Contents
Pre-requisites Summary of Steps Step 1 - Create and Install cert Step 2 - Create VS project Step 3 - Upload the certificate to Windows Azure Management portal Step 4 - Publish the project to Windows Azure Step 5 - Test the SSL
Prerequisites
1. Windows Azure SDK 2. Windows Azure Tools for Visual Studio 2008 3.
Summary of Steps
Step 1 - Create and Install cert Step 2 - Create VS project Step 3 - Upload the certificate to Windows Azure Management portal Step 4 - Publish the project to Windows Azure Step 5 - Test the SSL
1. Open http://windows.azure.com 2. Select the Service you will deploy to, or create one if necessary 3. At the bottom of the management page, find the Certificates area, and click the "Manage" link on the right 4. Hit the "browse" button and select the PFX file created in step 1 5. Enter "password1" and confirm it in the password textboxes 6. Click "Upload"