Firesheep: black hats for the masses

The following will also be used as part of my day job.  To ITSec types, it’s likely old hat, but it may be new to some of my readers.  Some terminology in here is my-job-specific, but I did try to generalize it as much as possible.

What is it?

Firesheep is a readily-available and easily-installed add on for Firefox, a commonly-used web browser.  It allows the person using it to, within certain parameters, steal web cookies used for authorization on many common websites, mostly social networking but also, most notably, Hotmail.  This is a form of attack commonly known as sidejacking.  Note that while this document largely talks about uw-wireless, everything about that network applies equally to any open or unsecured wireless network, such as uw-guest or those commonly found in coffee shops, restaurants, and other places offering free service to customers.

Please note that discussing a tool does not condone its use.  In particular, the use of Firesheep on a campus network is a violation of the principles laid down in the Guidelines on Use of Waterloo Computing and Network Resources and, as noted by these Guidelines, is subject to discipline under the appropriate University Policy or Policies.  Use of Firesheep here, or anywhere else, may furthermore violate local laws and regulations on privacy, mischief, or wiretapping.

What does it mean?

Firesheep makes it easy for anybody who can click a mouse to be able to access these websites as if they were the person whose credentials they’ve stolen – and that person may not even be aware of the accesses.

How does it work?

The victim has to be on the same wireless access point, using the same wireless network, as the attacker.  That implies a certain physical proximity.  The wireless network must be open, and the victim must be using the network at the same time as the attacker, and must be accessing these sites (but see below, the victim may not necessarily know they were using a particular website, embedded content can cause problems).

When Firesheep is started, the attacker’s computer starts passively watching the network for authentication credentials.  When it sees such, it saves them and presents an icon for the attacker to click; this allows the attacker to easily access the website as the victim.

It should be noted that a user may inadvertently access a website.  Many websites will have badges to follow the site’s author on Twitter, or link to them on Facebook.  Sometimes the simple act of loading that website can cause your browser to send and receive authentication cookies, and therefore expose this information to the attacker.

I don’t use social networks.

Firesheep doesn’t only work on social networks, so you still may not be safe.  Web services as varied as Evernote, Cisco, eBay, Amazon, and Slicehost have had Firesheep handlers written for them.

Why doesn’t the University stop it from happening?

This attack takes advantage of two weaknesses in the way victims might access vulnerable websites.

The first weakness is that open networks are precisely as the name implies.  All clients transmit all data unencrypted using their wireless radio.  Like any radio, anybody can listen in.  This means that unless the client takes extra precautions to encrypt data, such as using TLS/SSL encryption on the data stream itself, that data is exposed for anybody within range who’s listening.  This means that many websites which do encryption properly, such as almost all banking websites, are not vulnerable to authentication theft in the way that Firesheep accomplishes it.

The second weakness is in the way the vulnerable websites perform authentication and authorization.  Without getting too technical, these sites rely on cookies, and merely having that cookie implies both that you are who you say you are, and you’re allowed to access the content you’ve requested.  Not all websites have this issue; as noted, banking websites don’t rely on this model.  Other sites such as GMail and corporate applications at the University of Waterloo don’t either, and so your credentials there are safe from this attack.

What can I do to protect myself?

The simplest thing you can do is not use open wireless networks.  These are ones which do not require a key or password to access.  uw-wireless is one such network, but many coffee shops and restaurants and other companies provide such networks for the convenience of their customers.  This also affords attackers certain conveniences.

The next-best thing is to not use sites vulnerable to Firesheep attack whilst connected to an open wireless network.  Be aware that some sites you visit may effectively force you to give up your credentials anyway, as noted under How Does It Work?

Some clients customized for use by some social networks, such as Tweetdeck, may allow these networks to be used in a manner that does not expose authorization credentials to Firesheep.  That does not necessarily mean that these clients always operate in a safe manner.

Some people have authored Firefox extensions which could potentially warn you about the use of Firesheep on your network segment.  The use of these extensions (the most commonly mentioned are FireShepherd and BlackSheep) is prohibited on University wireless networks, as they have a deleterious effect on the operation of the campus network and, not incidentally, of the remote service.

Doing pcap stuff with Ruby on a Mac

This is probably old news to anybody who’s used to Ruby on Macs, but I’m not.  I like using MacPorts when I can, so that’s where my Ruby runs from.

I went looking for pcap modules and found a bunch, but the most promising seemed to be packetfu.  It came with a caveat: “PacketFu is reported to work on OS X, assuming you can get pcaprub installed correctly.”

So the first step was to get pcaprub going.  You can get it at rubyforge, the trick is it has a README, a single C source file, and a small ruby script. It turns out the secret is to do ‘ruby extconf.rb’, which will create a Makefile for you, and you can then ‘sudo make install’.

The author of packetfu recommends sticking with sources, available here. Check them out like this: ‘svn checkout packetfu-read-only’ – I like doing this in ~/src, but your tastes may differ.  Use the pcaprub_linux directory, and again, ‘ruby extconf.rb’ followed by a make / make install.  The test script bombs out – by default it wants to use the fw0 device.  Nevertheless, I pressed on and did as suggested: ‘cd .. && sudo ruby setup.rb’ which finished with no failures.

Note that following these steps will pollute your MacPorts ruby install with files about which it knows nothing – I generally like to avoid this, but it seems like scripting languages insist on having their own packaging systems that make it not quite impossible to work with other such systems.

Then I wrote a little test script that should just count packets:


require 'packetfu'
filename = ARGV[0] || exit
count = 0
incap = PacketFu::Read.f2a(:file => filename)

incap.each do |pkt|
 p = PacketFu::Packet.parse(pkt)
 count += 1

puts "#{count} packets"

I would not recommend doing as I did and turning it loose on a 711MB pcap trace – top showed the process using 1.9GB of memory before I managed to get a responsive terminal to kill it.  It fared slightly better on a 12MB trace (a subset of the larger ones) and correctly counted 85411 packets, but still hit 265MB:

real    4m0.359s
user    3m16.012s
sys    0m1.891s

I’m a fairly-incompetent Ruby programmer, but the above seems fairly straightforward – I’m not sure I’d want to turn this parser loose on anything of any real size.  While 711MB is a pretty big trace to be parsing, 12 is pretty small.  To be fair, I had other processes running at the time, including a Windows 7 VM that was patching (unbeknownst to me) but it’s a 4GB dual core machine.  I’d been hoping to more easily pull various bits of data out of the larger file, but it looks like I’m stuck with tcpdump and tshark for now.

ETA: I had been going to post again about xtractr, but it’s not a 100% Mac/Ruby solution. It provides an interface so that I could use Mac Ruby installs to talk to an xtractr instance, but so far as I can tell, there’s no 100% Mac solution. So I’m running it on an Ubuntu box, but I won’t bother detailing how I got it going – it was pretty straightforward, although it required some work I’d already done to make gems sane on an 8.04 system.