TechRepublic : A ZDNet Tech Community

Network Administrator

Host: Selena Frye
Contact

HTTPS: Surf jacking makes it vulnerable

Cookies and redirection seem to be this year’s “attack vector du jour.” At DefCon, Mike Perry gave a rather disconcerting talk about surf jacking and how it can be used to capture SSL session cookies. Michael Kassner would like to explain how surf jacking compromises HTTPS security.
——————————————————————————————————————-

The infamous cookie causes yet more grief

Michael KassnerIn reality, it’s not the cookie that causes the problems; they are just an easy way to subvert HTTP and now HTTPS connections. There are two major categories, persistent cookies and session cookies. It’s important that we know the difference between the two when discussing how surf jacking works:

  • Persistent cookies are so named because they have a time-to-live that lasts longer than the current Web-browsing session. The first- and third-party cookies I discussed in my article about Behavioral Targeting and Deep Packet Inspection would be considered persistent cookies. Persistent cookies have very little to do with the actual Internet connection.
  • Session cookies only last the length of a Web-browsing session. More importantly, they carry information that validates the Web browser to the Web server.

To help explain, let’s look at the life of a session cookie in the following example:

  1. Using my Web browser, I log on to https://www.mybankxy.com.
  2. The mybankxy.com Web server authenticates my credentials and places a small text file on my computer, called a session cookie. The session cookie contains pertinent user log-on and security information.
  3. After the portal Web page opens, I click on a link for the Web page with my savings information.
  4. My Web browser sends the Web page query and my session cookie back to the mybankxy.com web server.
  5. The session cookie allows the Web server to reverify who I am. If everything is in order, the Web server then sends the Web page I asked for. Without the session cookie, I’d have to log in each time a new Web page was served up.
  6. After I complete my transactions, I log off the Web site https://www. mybankxy.com. The session cookie then invalidates itself and is deleted.

So, session cookies are useful — browsing the Web without them would get annoying real fast. Another function of session cookies is to remember actions that take place on a Web page. This is especially important if session information may be needed on a different Web page on the same Web server. A prime example of this would be a Web site that uses shopping carts; without session cookies the items purchased wouldn’t be remembered when the Web browser asked for the check-out Web page.

301 Moved Permanently

Now, I’d like to take a look at HTTP redirection. In that same article about Behavioral Targeting and Deep Packet Inspection, I talked about redirection being a key component to getting illegitimate cookies installed on a computer. As you will see in the following example, surf jacking also uses redirection, but a slightly different version of it called the “301 Moved Permanently” HTTP error. As the name suggests, the 301 redirection is considered permanent. The code also contains the URL of the missing or renamed page as well as the URL of the new page.

Surf jacking

First a little history, almost a year ago Robert Graham introduced “Side Jacking” at Black Hat 2007. It was such an interesting concept that I covered it in the article “Can Your Wireless Network Be Sidejacked?” Side jacking is a clever way of stealing HTTP session cookies, allowing the attacker to actually hijack a HTTP session without knowing any log-on credentials. That was a year ago, and now there are proof-of-concept attack tools to do the same thing with SSL connections, which is scary. However, knowledge is power, so let’s take a look at how surf jacking works by following the steps of an attack:

  1. I log in to my online bank at https://www.mybankxy.com. I need to move some money to my debit card as I’m buying something online.
  2. Once again the mybankxy.com Web server authenticates me and places a small text file on my computer, called a session cookie.
  3. I forgot the amount I needed, so I open a new browser window and go to http://www.commercexy.com.
  4. Just my luck there’s an attacker sniffing traffic on the same Wi-Fi hotspot. So the attacker already knows that I have an active HTTPS (encrypted) session to www.mybankxy.com and that I just opened a HTTP (in the clear) session to www.commercexy.com. It’s a perfect opportunity to run the surf jacking attack.
  5. The attacker sends back a “301 Moved Permanently” in response to the Web page query I sent to www.commercexy.com.
  6. The redirection now occurs as the 301 response contains the header http://www.mybankxy.com. This is telling my Web browser it needs to go to http://www.mybankxy.com to find the http://www.commercexy.com Web page I was looking for. Notice that the response is using HTTP and not HTTPS.
  7. My Web browser now starts a new and unsecured connection by sending a query to http://mybankxy.com, and since my first HTTPS session to www.mybankxy.com is still open, the session cookie is valid. Therefore, this second query contains that same session cookie.
  8. Since the attacker is sniffing all my traffic via the open Wi-Fi hotspot, the session cookie is captured. Done deal.
  9. In order to give the appearance that nothing happened, the attacker then sends another “301 Moved Permanently” finally sending my browser to the Web site http://www.commercexy.com.

That’s the attack. Granted, there are certain conditions required to pull the attack off, but it’s entirely possible. I wouldn’t want an attacker going to https://mybankxy.com and using the captured session cookie to change my log-on credentials or even worse. For more details on the attack, please go to the “Enablesecurity.com” Web site and watch the demonstration. It shows how surf jacking can be used against a vulnerable Gmail account.

Prevention consists of two parts

The immediate solution to surf jacking is easy, just never open a HTTP session if you have an active HTTPS session. The long-term solution is more complicated and involves Web site developers. Sandro Gauci of Enablesecurity mentions how the attack can be mitigated, along with some potential rollout issues:

“Cookies can have a flag called “secure,” which when present causes the browser cookie to be sent only through encrypted channels. When the web browser is redirected to a clear text channel (HTTP rather than HTTPS), such cookies are not included in the HTTP request. This behavior solves the problem described and can be easily implemented on web services that separate services that need encryption from those that do not. One such service is E-banking, which is normally segregated on a web site such as https://secure.bank.com/.

However there are cases where setting the Cookie secure flag is not an easy option. A web service such as Google shares a session and credentials across various domains and switches between HTTP and HTTPS depending on the service. In this case, the solution is not as easy as setting the Cookie to “secure” because that would not scale well with the rest of the infrastructure. Google appears to be have mitigated this for Gmail by providing the “use only HTTPS” option - but other Google services such as Google Docs remain vulnerable to attack.”

Final thoughts

Surf jacking as an attack vector is serious. Hopefully, this article will be a reminder to always use good Web-surfing practices, especially now making sure to only have one Web-browser session open if it’s a HTTPS connection. I realize that surf jacking requires an attacker to be in a position to capture traffic, but theoretically that can take place anywhere along the traffic’s path. I just wouldn’t want to take a chance on having personal information stolen or worse yet trying to figure out why my bank accounts are empty.

——————————————————————————————————————-
Michael Kassner has been involved with wireless communications for 40 plus years, starting with amateur radio (K0PBX) and now as a network field engineer for Orange Business Services and an independent wireless consultant with MKassner Net. Current certifications include Cisco ESTQ Field Engineer, CWNA, and CWSP.

Michael KassnerMichael Kassner has been involved with communications for 40 plus years, starting with amateur radio (K0PBX) and now as a systems/network administrator for an international corporation and consultant with MKassner Net. Read his full bio and profile.

Print/View all Posts Comments on this blog

The real reason for "Always Use HTTPS" setting Michael Kassner | 08/20/08
I've got to hand it to you, Michael seanferd | 08/20/08
multiple sessions pgit | 08/20/08
Sure did Michael Kassner | 08/20/08
Clarification of new browser lopsl | 08/20/08
B for sure Michael Kassner | 08/21/08
How would this effect if The 'G-Man.' | 08/29/08
Nope Michael Kassner | 08/29/08
RE: HTTPS: Surf jacking makes it vulnerable aatramps@... | 08/20/08
It's not Michael Kassner | 08/20/08
Thanks Michael! Arcturus909 | 08/20/08
My pleasure Michael Kassner | 08/20/08
everybody is an idiot, one way or other pgit | 08/20/08
It does work Michael Kassner | 08/21/08
Sessions and browsers techrepublic@... | 08/20/08
Question for you Michael Kassner | 08/20/08
A couple of questions brad@... | 08/20/08
Answers Michael Kassner | 08/20/08
new window pgit | 08/20/08
There is a simple solution OldGuru | 08/20/08
Doesn't apply here Cactus Pete | 08/20/08
It depends on what you mean by "everything" OldGuru | 08/20/08
I need your help Michael Kassner | 08/20/08
Dear Michael ... OldGuru | 08/20/08
Next question Michael Kassner | 08/20/08
Nothing changes for shopping cart OldGuru | 08/20/08
IP access security Cactus Pete | 08/20/08
RE: IP access security OldGuru | 08/20/08
You hadn't mentioned the specifics Cactus Pete | 08/20/08
IP Address is not reliable SilentTygur | 08/20/08
RE: IP Address is not reliable OldGuru | 08/20/08
Your solution Michael Kassner | 08/20/08
Not exactly OldGuru | 08/20/08
My exact sentiments Michael Kassner | 08/20/08
None taken OldGuru | 08/20/08
In addition to the IP address stan@... | 08/20/08
It does improve considerably on security OldGuru | 08/20/08
Thats only part of the data exchanged during login stan@... | 08/20/08
a possible method chris@... | 08/25/08
Not an expert Michael Kassner | 08/26/08
client defined data sandro@... | 08/26/08
brilliant pgit | 08/20/08
RE: brilliant OldGuru | 08/22/08
the simple solution sandro@... | 08/21/08
Thanks Sandro Michael Kassner | 08/22/08
I wasn't aware that ... OldGuru | 08/22/08
secure flag sandro@... | 08/23/08
Thanks Sandro Michael Kassner | 08/24/08
an even more simple solution martdaw | 08/27/08
Not sure Michael Kassner | 08/28/08
RE: HTTPS: Surf jacking makes it vulnerable scarville@... | 08/20/08
Very Interesting Michael Kassner | 08/20/08
SSLRequireSSL in a nutshell scarville@... | 08/20/08
SSLRequireSSL sandro@... | 08/21/08
SSLRequireSSL for scarville@... | 08/22/08
Proactively setting the secure flag sandro@... | 08/23/08
RE: HTTPS: Surf jacking makes it vulnerable ederkley | 08/20/08
That's correct Michael Kassner | 08/20/08
Umm...why would the .govs be past this? ederkley | 08/20/08
Oh, wow Michael Kassner | 08/20/08
SSL VPNs d_g_l_s@... | 08/21/08
Log on Michael Kassner | 08/22/08
or pgit | 08/20/08
Few corporate systems are past it right now scarville@... | 08/21/08
As I see it Michael Kassner | 08/21/08
right sandro@... | 08/21/08
You have to surface sometime scarville@... | 08/22/08
RE: HTTPS: Surf jacking makes it vulnerable Jacdeb6009@... | 08/21/08
Thank you as well Michael Kassner | 08/22/08
RE: HTTPS: Surf jacking makes it vulnerable mailstop29-x@... | 08/21/08
No, not at all Michael Kassner | 08/22/08
A Result! grax | 08/25/08
My pleasure Michael Kassner | 08/25/08
Force HTTPS on browser? ederkley | 08/25/08
Not sure Michael Kassner | 08/26/08
bind it to the browser identifier Neon Samurai | 08/26/08
Buggy? (slightly O.T.) grax | 08/26/08
Only brief experience with it (nt) ederkley | 08/26/08
Only brief experience with it (nt) !! ederkley | 08/26/08
Brief experience with it ederkley | 08/26/08
File association? seanferd | 08/28/08
Interesting thought Michael Kassner | 08/29/08
Limited usefulness seanferd | 08/29/08
Interesting process Michael Kassner | 08/30/08
Yes, I saw that. seanferd | 08/30/08
I don't know all the details Michael Kassner | 08/31/08
I can understand the problem now seanferd | 08/31/08
Aha! Another FF extension seanferd | 09/01/08
Think so, Michael Kassner | 09/02/08
If opening a different browser does start a new session seanferd | 09/02/08
IE Tab uses the IE engine GreyTech | 08/29/08
Firefox the same? Michael Kassner | 08/29/08
Asked the expert Michael Kassner | 08/29/08
The key is opening an IE tab in FF GreyTech | 08/31/08
Oops, sorry Michael Kassner | 08/31/08
Next article about SSL certificates Michael Kassner | 08/26/08
New information Michael Kassner | 08/29/08
Thanks :) seanferd | 08/29/08
Developer responsibility for secure flag lopsl | 08/31/08
client setting the secure flag sandro@... | 09/01/08
Add-on setting the secure flag: NoScript seanferd | 09/12/08
Thanks Sean Michael Kassner | 09/13/08
Not yet. seanferd | 09/13/08
There is Michael Kassner | 09/13/08
You may find this off-topic article interesting seanferd | 09/13/08
It never stops Michael Kassner | 09/13/08
It certainly seems that way seanferd | 09/14/08
Any test sites to try this on? lopsl | 09/14/08
I'm having issues Michael Kassner | 09/15/08
I don't know what it is seanferd | 09/15/08
Thanks Sean Michael Kassner | 09/15/08
Article about EV SSL certificates Michael Kassner | 09/05/08
What about Google Chrome? travisn000@... | 09/10/08

What do you think?

White Papers, Webcasts, and Downloads

Recent Entries

TR on Twitter

Archives

TechRepublic Blogs



500 Things Every Technology Professional Needs to Know
Did you know Microsoft's RegClean does not work with XP but you can use shareware to clean your registry? Did you know most wireless access points don't have encryption enabled by default? Did you know there are 500 tidbits of information contained in TechRepublic's 500 Things Every Technology Professional Needs to Know that will help you become a successful IT professional.
Buy Now
Quick Reference: Linux Commands
Reduce stress and speed up resolutions with the easiest command references right at your fingertips. You'll receive a PDF file covering Linux, packed with the most common commands you'll need and use daily.
Buy Now

SmartPlanet

Click Here