The way pam_usb performed authentication was inspired by smartcards: a private key was stored inside the device and the public part of the key inside the computer. The problem is that, unlike smartcards, the content of a USB device is readable meaning that the private key could be stolen by anyone borrowing your flash drive. Sure, the device is also identified by its manufacturer attributes (serial number and alike), but I'm pretty much sure those informations can be forged.
Knowing that the content of the USB device is unreliable (as it can be stolen), I came up with a different approach for authenticating a device called One Time Pads authentication. Basically, a pad is just a bunch of random bytes stored on both the USB device and the computer. Every time you authenticate, those pads are compared. If they match, access is granted and the pads are regenerated, otherwise access is denied.
This means that even if someone manages to fake your device's manufacturer attributes and to steal your pads, as soon as you authenticate the pads will be regenerated, making the one they have stolen invalid.It's like having a very long random generated one time password, except the fact you don't have to remember such password.
Let's see one time pads in action:
- First, just as our attacker, we start by stealing our own pad:
scox@helium ~ $ cp /media/disk/.pamusb/root.helium.pad /tmp
- Then we authenticate. As you can see, the pads are verified, then updated:
scox@helium ~ $ su
* pam_usb vSVN
* Authentication request for user "root" (su)
* Device "sandisk" is connected (good).
* Performing one time pad verification...
* Verification match, updating one time pads...
* Access granted.
- Now we are the attacker. We start by putting the stolen pad back into a device (assuming the device has the same serial number as ours) and try to authenticate:
scox@helium ~ $ cp /tmp/root.helium.pad /media/disk/.pamusb/
scox@helium ~ $ su
* pam_usb vSVN
* Authentication request for user "root" (su)
* Device "sandisk" is connected (good).
* Performing one time pad verification...
* Pad checking failed !
* Access denied.
Password:
It may not be the safest authentication ever, but it's cheap (everyone has a USB flash drive nowadays), pretty much secure for common usage and avoids the hassle of remembering and typing passwords.I'll be releasing pam_usb 0.4.0 which contains one time pads authentication in the next few days, so stay tuned.