System Overlord

A blog about security engineering, research, and general hacking.

GnuPG: The What and the Why (For Me, Anyway)

I'm a big advocate of GnuPG, the Free implementation of the OpenPGP standard.  I've even recently begun to use a smart card for storing my keys.  I've also answered some questions about why I do this, so I thought I'd write about it here.  Put simply: the Bill of Rights is important to me.  My privacy is important to me.  Security is important to me.  OpenPGP can help me protect the things that are important to me.


SSH across a Layer 7 Filter

Every once in a while, I find myself in a situation behind some sort of device that filters a lot of traffic.  Most often, it's on my laptop at some facility (e.g., coffee shop) that only allows HTTP/HTTPS out.  For a while, I just listened for SSH traffic on port 443 (HTTPS) to connect through port-based firewalls.  However, a few times now I've seen a connection reset immediately after the SSH handshake started (during the protocol&cipher negotation).  Looking at them through WireShark made it obvious it wasn't a server or client problem, but some intermediate device sending a RST.

At first, I just throught I would use Dag Wieers's method for tunneling SSH over HTTPS with Apache/mod_proxy.  Unfortunately, Apache bug 29744 causes CONNECT over HTTPS to fail.  I also didn't really want to add another application to my system just to do that via proxytunnel.

My method, I will note, does NOT allow you to run both an HTTPS server and allow these connections on the same port.  What it does do is prevent passive sniffers (including Layer 7 devices) from seeing the SSH session initialization.  It still uses SSH for authentication, and I don't believe it poses any special security risks.  You'll need a dedicated IP/port combination to run this on, and port 443 will have the easiest time getting out of the networks discussed at the beginning.

Yes, the double-encryption is unnecessary overhead, but it gives you the power of SSH while making the network see nothing more than a simple SSL connection.

So, let's get it done! First off, install stunnel4 on your server. My configuration looks something like this:

cert = /etc/ssl/somecert.pem
sslVersion = SSLv3
chroot = /var/lib/stunnel4/
setuid = stunnel4
setgid = stunnel4
pid = /stunnel4.pid
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1

[ssh]
# This address and port cannot be used for anything except this connection
accept = 203.0.113.2:443
connect = 127.0.0.1:22

On your client, you'll just need the standard openssl application.  OpenSSL is installed on (nearly ?) every Linux distribution by default, so no extra client application needed here. You'll find it easiest to set up a ~/.ssh/config file. In my config, I have a stanza like:

Host server.https
	Hostname 203.0.113.2
	Port 443
	ProxyCommand openssl s_client -connect %h:%p -quiet 2>/dev/null
	User username

Doing an "ssh server.https" should connect to the server via the SSL tunnel.


Happy Valentines Day

This post is dedicated to my wife, Ann.  Happy Valentine's Day, and I love you very much.


What happens when your credit card is out of your sight?

We've all done it, and it seems so normal: hand a credit card to a server at a restaurant to pay the bill.  It's an everyday activity, occurring millions of times a day around the world.  However, this comes with risks, as the media shows us:

With devices like Portable Mini 400 Magnetic Magstripe Data Card Reader, it's a wonder that more credit cards aren't stolen in that fashion.  (I guess we're just protected by either a sense of right or the risk of being caught.)  While the $230 pricetag might seem a little high at first, consider the number of credit cards a single waiter might handle in a night.  Even placing a relatively small transaction on each of those cards, a single night would be enough to make up the price of the reader.

Magnetic stripe payment technology became widely available in 1975.  While it has served us well for over 35 years, it's time to move to newer technology to protect our financial transactions.  Skimmers, these handheld recording devices, and other relatively accessible pieces of technology have rendered the magstripe obsolete.  Now is a good time, as 4 researchers at the University of Cambridge have shown significant weaknesses[PDF] in the Chip and PIN system widely deployed in Europe.  With the proliferation of cell phones, especially smartphones, maybe the time is now for Mobile payment to become a major part of the electronic payment industry.  Alternatively, new smart card implementations might extend the life of plastic just a little longer.


apc.stat=0 and Updating Software

When you're running APC on PHP and you have apc.stat=0, it's sometimes easy to forget that when you update software (WordPress) the code running on your server remains unchanged until you flush the APC cache. So, when you go to update WordPress to 3.0.5, you should flush your APC cache after running the update.  If you don't, you'll be very confused when WordPress repeatedly tells you to upgrade to the version you just installed!

This is mostly a note to myself, but I hope it helps others as well.  And if you're wondering what apc.stat does, read on!

apc.stat determines if APC should perform a stat() call on the file to see if it has changed since it was cached.  From the PHP documentation:

Be careful changing this setting. This defaults to on, forcing APC to stat (check) the script on each request to determine if it has been modified. If it has been modified it will recompile and cache the new version. If this setting is off, APC will not check, which usually means that to force APC to recheck files, the web server will have to be restarted or the cache will have to be manually cleared. Note that FastCGI web server configurations may not clear the cache on restart. On a production server where the script files rarely change, a significant performance boost can be achieved by disabled stats.

For included/required files this option applies as well, but note that for relative path includes (any path that doesn't start with / on Unix) APC has to check in order to uniquely identify the file. If you use absolute path includes APC can skip the stat and use that absolute path as the unique identifier for the file.