2004-04-14
Understanding the threatIn the 1960's, it required the brilliance of Frank Abagnale Jr. (of "Catch Me If You Can" fame) to deceptively build a bank balance of colossal magnitude. Today, all one needs is a prying teenager with access to the Internet - a hair raising reality!Consider the following analogy:
Scenario One:
Scenario Two: Scenario two describes a successful impersonation attack that goes undetected by the security guards (firewall). The proliferation of e-commerce and the anonymity provided by the Internet have shifted the focus of such attacks from the real world to cyber space. The consequences of such an impersonation attack against a web application (known as a cyber-impersonation attack) range from personal information disclosure and identity theft to financial fraud resulting in the embezzlement of funds. The lack of ability for conventional firewalls to recognize such attacks and their enormously derogatory impact on business make them of special interest to "black hats" and thus, of special concern for developers and web security administrators. In this article I will discuss common flaws in web application design that facilitate cyber-impersonation attacks and tested countermeasures to protect against them. However, in order to better understand cyber-impersonation attacks it is imperative to gain an adequate understanding of session management techniques (as will become clear through the rest of the article). Session ManagementSession management encompasses the techniques employed by web applications to transparently authorize a user for every HTTP request without having the user repeatedly login. The onus of session management must be borne by the application itself due to the stateless nature of the underlying HTTP protocol. Session management entails the application sending the client (in most cases, a web browser) a session token after successful authentication. In most cases, this token is passed via the Set-Cookie directive of HTTP and is stored on the client. The session token must then be sent by the client along with every HTTP request to the server to identify itself to the web-based application. The application can then determine whether the client is authorized to access the page being requested.Session management mechanisms can be broadly classified into client-side and server-side mechanisms. This classification is based on the contents of the session token passed between the client and the application. Client-side session managementIn this form of session management, the session token contains the best part of the data necessary to perform user authorization. As the token and in effect a bulk of the authorization information is stored on the client, this technique of session management is often referred to as client-side session management and the token is commonly referred to as a cookie. It is the accurate manipulation of this cookie that may lead the application into believing that the user is someone else - a successful cyber impersonation attack. This concept can be understood more clearly from the following over-simplified example.User (Simple) Sam after successful authentication to xyzbank.com receives the following set of cookies (only cookie names and values are shown): admin=false;account=101 User (Evil) Edward after successful authentication to xyzbank.com receives the following set of cookies (only cookie names and values are shown): admin=false;account=120 The role of each cookie is fairly evident. The admin cookie indicates to the application whether the user should be granted administrative rights. The account cookie probably specifies the actual account the particular user is allowed to access. If Edward were trying to impersonate Sam, he would probably attempt to brute-force Sam's account cookie. This would entail trying all the possible values for that cookie which in this case presents a maximum of 1000 possibilities (namely, 000-999). Edward (or his script) would be successful on his 102nd attempt when the cookie presented by him to the application would be: admin=false;account=101 The above is an example of an impersonation attack with horizontal privilege escalation (i.e. the attacker impersonated another user at the same privilege level). Edward could have also attempted a vertical privilege escalation attack by modifying the value of the admin cookie to true. This may "trick" the application into believing the Edward is an administrator and granting him administrative access to the banking application. The opportunities for a user like Edward with vile intent are then limitless! Server-side session managementThe fundamental difference between this form of session management and client-side session management is that in this case the bulk of the authorization information is stored on a back-end database (server-side) and the session token passed between the client and the application acts as a mere index into that database. This type of session token is often referred to as a session id. Consider the following example.User (Simple) Sam after successful authentication to xyzbank.com receives the following session id: sessionid=1234 User (Evil) Edward after successful authentication to xyzbank.com receives the following session id: sessionid=1235 These session ids can be thought of as a row number in the authorization database at the back-end that may be structured as follows:
If Edward's intent again is to impersonate Sam then he must successfully modify his session id to reflect that of Sam's which in this case involves changing his session id value from1235 to 1234. He may also be able to impersonate an administrative user Joe by guessing his session id (i.e. 1232). Thus, simply storing the authorization data on the back-end does not safeguard the application against impersonation attacks. CountermeasuresWhat design and implementation changes would have sufficiently mitigated these attacks?The basic principles of securing an application against impersonation attacks are the same whether it employs client- or server-side session management. The following are some salient countermeasures.
It is important to remember, that one can never completely secure an application and must incorporate multiple layers of security in its design to protect against such attacks. These may include:
ConclusionWe've seen some basic client-side and server-side session management approaches used by many web applications -- and how easy it is to cyber-impersonate another user when more sophisticated techniques are not used. If some of the websites you frequent make use of cookies that offer such information, you should be wary of providing any personal or financial information about yourself as the session could be easily hijacked.It should go without saying that most financial institutions make use of significant countermeasures that make cyber-impersonation much more difficult. Some of the possible countermeasures have been discussed in the second half of this article.
More information on penetration testing for web applications, including session management and the use of cookies, can be found in the three part series on penetration testing for web applications, found in the Pen-Test archives on SecurityFocus.
|
||||||||||||||||||||||||||||||||||||
|
About the author
View more articles by Rohyt Belani on SecurityFocus.
|
