Yubikeys in Qubes

471 views
Skip to first unread message

Micah Lee

unread,
Dec 1, 2016, 6:54:55 PM12/1/16
to qubes...@googlegroups.com
I just wrote a quick blog post about using Yubikeys in Qubes.
Specifically, I wanted to share a script that will use qvm-usb to attach
your Yubikey to your gpgvm no matter what USB port you plug it into.

https://micahflee.com/2016/12/qubes-tip-making-yubikey-openpgp-smart-cards-slightly-more-usable/

Marek Marczykowski-Górecki

unread,
Dec 1, 2016, 7:37:39 PM12/1/16
to Micah Lee, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Thanks! That's interesting. I'd add two things:

The tool run by qvm-usb does support alternative device identification
- - using product and vendor ID. Also to specify which device to attach.
This isn't exposed by qvm-usb tool, because it may be ambiguous, but may
be useful here. See README for more details:
https://github.com/QubesOS/qubes-app-linux-usb-proxy
I acknowledge that your solution is better in some aspect: it exists and
works :)

Is communication with YubiKey encrypted, or at least somehow
authenticated? Otherwise malicious USB VM could easily perform some kind
of man in the middle attack and for example sign document you really
didn't want to sign. Or decrypt arbitrary data. It's possible even when
physical confirmation (button) is required - by simply waiting until you
perform *some* operation.
This is general problem with USB devices, which are hard to solve with
the current USB infrastructure (USB VM can do anything with any device
connected to it). Without some fundamental USB rework - probably at
hardware layer, I think the only alternative is protecting the data at
individual device protocol level (like you do with encrypted USB sticks
for example).

- --
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJYQMJNAAoJENuP0xzK19csL6UIAJqJSD49PwzMOJBoYVHIWsuM
sraQDLT8gkArL7P6vWmCZhd/U6ZMurcXlcrFvjW9bUWm7siOmJn5NpU5DG0ve5pS
I83BSkymhGMynXzZCHfW0Sf9hJdOgBtnnpqSTPTfsAXuR8JV3OV6/GbslvcbIOqU
JofhflbhqvD9tPI8q7smG6RyRUGH8KXDI8HVgjewlPfHqUNpXF/aZpWLfIhQBesU
VPjmgSmOz8ioi9JwlFzJrLkPbp75xx23E5/sl5Bd6BRm2tG+6lZtfbLFH7nk17ci
QbjekfytI5/eTKb542OL9UPlUF/6m0Qj5jasrxy4CUbmKC1LEPIQrNPH4kyA06s=
=hZPo
-----END PGP SIGNATURE-----

Chris Laprise

unread,
Dec 1, 2016, 8:14:57 PM12/1/16
to Marek Marczykowski-Górecki, Micah Lee, qubes...@googlegroups.com
What is an acceptable / secure way to obtain a Yubikey fob?

Chris

vegard_p...@fastmail.fm

unread,
Dec 2, 2016, 4:57:48 AM12/2/16
to qubes-users, mi...@micahflee.com
fredag 2. desember 2016 00.54.55 UTC+1 skrev Micah Lee følgende:
> I just wrote a quick blog post about using Yubikeys in Qubes.
> Specifically, I wanted to share a script that will use qvm-usb to attach
> your Yubikey to your gpgvm no matter what USB port you plug it into.

Thank you very much for this, Micah, it great to see usability scripts for Qubes popping up!

That said, I tested this and it turns out one needs to have a USB Qube set up (aka USB-VM, sys-usb).
I followed the receipe here: https://www.qubes-os.org/doc/usb/ .

My problem now is that I have a single PS/2 port, and have to switch between using either a PS/2 mouse or a PS/2 keyboard, by plugging and unplugging the connector.

Is there a simple way to completely disable the USB-Qube?
The command: "qubesctl top.disable qvm.sys-usb" in dom0 doesn't do much.
And rebooting the Qubes OS causes system hang; it does not boot anymore.

Currently I have taken out my SSD-disk and mounted it on a different machine, by:
---
su -
cryptsetup luksOpen /dev/sdb2 sdb2_crypt
lvchange -a y qubes_dom0
mount /dev/qubes_dom0/root /mnt/qubes_rescue
---

Grzesiek Chodzicki

unread,
Dec 2, 2016, 11:19:29 AM12/2/16
to qubes-users, mi...@micahflee.com
You can use mouse attached to the usb-vm which has usb input proxy installed to avoid switching devices around.

vegard_p...@fastmail.fm

unread,
Dec 2, 2016, 12:04:08 PM12/2/16
to qubes-users, mi...@micahflee.com
fredag 2. desember 2016 17.19.29 UTC+1 skrev Grzesiek Chodzicki følgende:
> W dniu piątek, 2 grudnia 2016 10:57:48 UTC+1 użytkownik
> You can use mouse attached to the usb-vm which has usb input proxy installed to avoid switching devices around.

Thank you very much Mr. Chodzicki, that was enough to push me in the right direction and hunt down the instructions here: https://github.com/QubesOS/qubes-app-linux-input-proxy

I worked my way through it from the section "Manual usage", starting at "Alternatively you can allow USB VM to initiate the connection whenever you attach your device. For that you need to ..."

Works like a charm, now I even have two mice attached!

Micah Lee

unread,
Dec 2, 2016, 2:08:54 PM12/2/16
to Chris Laprise, Marek Marczykowski-Górecki, qubes...@googlegroups.com
On 12/01/2016 05:14 PM, Chris Laprise wrote:
> What is an acceptable / secure way to obtain a Yubikey fob?

Unfortunately it's kind of hard to find Yubikeys in retail stores. You
might check here to see if you can find one close to you:
https://www.yubico.com/store/resellers/

Otherwise, you kind of have to order them online. It might make sense to
have one person do a single bulk order and pay for the fastest shipping
(to reduce the window for interdiction), and then distribute them to in
person to friends who want them. But of course it's not perfect.

Micah Lee

unread,
Dec 2, 2016, 2:15:32 PM12/2/16
to Marek Marczykowski-Górecki, qubes...@googlegroups.com
On 12/01/2016 04:37 PM, Marek Marczykowski-Górecki wrote:
> The tool run by qvm-usb does support alternative device identification
> - using product and vendor ID. Also to specify which device to attach.
> This isn't exposed by qvm-usb tool, because it may be ambiguous, but may
> be useful here. See README for more details:
> https://github.com/QubesOS/qubes-app-linux-usb-proxy
> I acknowledge that your solution is better in some aspect: it exists and
> works :)

It seems, from my brief testing, that all Yubikeys of the same version
have the same product and vendor ids. That still might be preferable to
grepping for "Yubikey" though.

> Is communication with YubiKey encrypted, or at least somehow
> authenticated? Otherwise malicious USB VM could easily perform some kind
> of man in the middle attack and for example sign document you really
> didn't want to sign. Or decrypt arbitrary data. It's possible even when
> physical confirmation (button) is required - by simply waiting until you
> perform *some* operation.

It is authenticated, but unfortunately I don't think in a secure way.
When you use any OpenPGP smart card you have to set a PIN to use it, and
you have to authenticate with the smart card using the PIN. In the case
of Yubikeys, you type the PIN using the gpg pinentry program (some smart
card readers have physical keypads to type the PIN, so software
keyloggers on the computer can't steal the PIN). But I'm pretty sure
that the PIN you type in, in plaintext, gets sent to the Yubikey, so
your usbvm could probably log the PIN the very first time you use your
smart card, and then use it as much as it wants after that without you
knowing.

Also, I'm pretty sure none of the communication is encrypted. To decrypt
a message on a smart card, you send the ciphertext (and a PIN, if it
isn't cached) to the smart card, and it decrypts it responds with the
plaintext. So likely, the usbvm could spy on the plaintext of decrypted
messages.

Unfortunately Yubikeys don't support pressing the physical button for
secret key operations. Those are preserved for 2FA and static passwords.

> This is general problem with USB devices, which are hard to solve with
> the current USB infrastructure (USB VM can do anything with any device
> connected to it). Without some fundamental USB rework - probably at
> hardware layer, I think the only alternative is protecting the data at
> individual device protocol level (like you do with encrypted USB sticks
> for example).

Sad, but reality.

Leeteqxv

unread,
Dec 2, 2016, 9:50:54 PM12/2/16
to Micah Lee, qubes...@googlegroups.com
Is it not possible to configure this to having the Yubikey require the
person to press the key button manually/physically?
If not, such a limitation would lie in the software rather than in the
Yubikey, I assume, since the Yubikey support Challenge-Response and such
already? If possible, it is definetely preferable to work around
potential PIN theft and subsequent hidden (mis)use by requiring a
manual/physical action.

Andrew David Wong

unread,
Dec 3, 2016, 4:20:23 AM12/3/16
to Leeteqxv, Micah Lee, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
As Marek explained above, requiring a manual/physical button press doesn't
solve the problem:

"Is communication with YubiKey encrypted, or at least somehow
authenticated? Otherwise malicious USB VM could easily perform some kind
of man in the middle attack and for example sign document you really
didn't want to sign. Or decrypt arbitrary data. It's possible even when
physical confirmation (button) is required - by simply waiting until you
perform *some* operation."

- --
Andrew David Wong (Axon)
Community Manager, Qubes OS
https://www.qubes-os.org
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJYQo5OAAoJENtN07w5UDAwADMQALNqWqC2Z+BVz8Zfd0gKG2an
U36zDNGJUM7ymj92AZqJw7gKQMHk46V4e3CPAQ1fCuuWG538nQzrhdkgMT5b242l
Anc14DdfHpHC58ZhtHL8BFPS89ApuiqgEW0QMxqp751rIry53s9ox+eO/MpVlCrE
X0RU7WKabBNP/lIxDtC9mf3yAtyhA9d4iHwyuRM+oARPe6MYxJJjKgz4HBYoRqOu
SFDfs+rZ577fJSr6kvn/vNBtaXeWCldPXnIoCToTWoihO5F8qr3uLvMVWFj+wF3Q
lnMv8W5192zDTcsEZGWWVPDAQ/VBF4LoEOBsUJyPYITOFong85fPYN0cGK1QOesH
DWPxfTcTfIKLLnDnpPnkvRJGiT9ovilWyb9MK01KxLaQ2Ix1dsgrGvdDXntWHleg
jGp4P/KT8U11omYJVDleWUv+1LSspHVVBPrbwn05WyPi4qN0uWphlFU2KoQtvDLs
cCjV8uNpdDh6xKndTyrJibvcTNSigr5tvYpOySuMt/iO7LPGhDdOZ9zMY9KSo1cE
p2Q5TdO1a6otB30+vphkn53XQlrXsvtOKIF1if2u7B5R1PyOxjKpz/7QN61913o3
roLxaSSYEF/6DWi289JayVsYutbXbxlnhzgqg8ac3ibmdgRNlSoT1EP4jmMPtReH
LMj8MpxMuBq4I12wlr+R
=2myJ
-----END PGP SIGNATURE-----

Andrew David Wong

unread,
Dec 3, 2016, 4:24:57 AM12/3/16
to vegard_p...@fastmail.fm, qubes-users, mi...@micahflee.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 2016-12-02 01:57, vegard_p...@fastmail.fm wrote:
> fredag 2. desember 2016 00.54.55 UTC+1 skrev Micah Lee følgende:
>> I just wrote a quick blog post about using Yubikeys in Qubes.
>> Specifically, I wanted to share a script that will use qvm-usb to attach
>> your Yubikey to your gpgvm no matter what USB port you plug it into.
>
> Thank you very much for this, Micah, it great to see usability scripts for Qubes popping up!
>
> That said, I tested this and it turns out one needs to have a USB Qube set up (aka USB-VM, sys-usb).
> I followed the receipe here: https://www.qubes-os.org/doc/usb/ .
>
> My problem now is that I have a single PS/2 port, and have to switch between using either a PS/2 mouse or a PS/2 keyboard, by plugging and unplugging the connector.
>

If your PS/2 port supports it, you can buy an inexpensive splitter cable that will allow you to
attach a PS/2 keyboard and a PS/2 mouse simultaneously.

> Is there a simple way to completely disable the USB-Qube?
> The command: "qubesctl top.disable qvm.sys-usb" in dom0 doesn't do much.
> And rebooting the Qubes OS causes system hang; it does not boot anymore.
>

You can simply turn off autostart in the VM's settings, and don't start it.
Or you can just delete the VM. You may also need to unhide USB controllers from dom0.
I.e., reverse this procedure:

https://www.qubes-os.org/doc/usb/#hide-all-usb-controllers-from-dom0

- --
Andrew David Wong (Axon)
Community Manager, Qubes OS
https://www.qubes-os.org
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJYQo9gAAoJENtN07w5UDAwQ3UQAI7QqamQW171SJATCPnqOYxC
orSincIN2dIpqx/gxtAN94QxxsOY932UZc35lIYYxt+5knk7IQueaVHPs0W9S+Bf
ziSPbhe6RKDCbYdVt2Ii2/2heWXqo3kadXDPAW4iqulepccbg5MCo8spl3KKEs45
c7xysbxznSajSs0qqD0ZNZ6u+VftoLgs00e3UGI9+p8RaD1YL0yg2OTDrkvKfI6d
OI9JZq1aH5+QJI310P8Fv+PHphPRtqbtS7nrAUm+v7vzU7bN533BpKBLi7wrB2kS
TOvIRbRisL29TxgiicLpewnd22PiohebZK5lUK8MGHScF1qSy8z2ufzCkb5VnGww
ikLwFUTF9ggLXJoIJHe4DpvQdCbFaSv5M2v5nnxKvr3zDkyqnpn10FZfedI80rSH
9cULPkWAJbiDTzcPExbpVKGrriWGgYf6ZfBaI9632NDGvUn6X0sbgIAq4uc0TWkA
Lvfvpzu7pyPpWW4BQxD+cJ+IineP1gg63zjq40fMDlC5Kl2MFlGG1HNtRuaDBySM
mTd6/R6zuVdGz14IXfNRPue8gf8xlnUPLylYaAVQBknIFFDnN0TahTcIUi9/rM0R
/h0BP91KaEcMugt/aupia2m28VIcyaBkzSgEzMFqlQT8iTLXBPyhrPV7Vwr527Kl
cpxOotUnJHyviDsyz3Wu
=0sFQ
-----END PGP SIGNATURE-----

Micah Lee

unread,
Dec 3, 2016, 2:24:33 PM12/3/16
to qubes...@googlegroups.com
On 12/02/2016 06:50 PM, Leeteqxv wrote:
> Is it not possible to configure this to having the Yubikey require the
> person to press the key button manually/physically?
> If not, such a limitation would lie in the software rather than in the
> Yubikey, I assume, since the Yubikey support Challenge-Response and such
> already? If possible, it is definetely preferable to work around
> potential PIN theft and subsequent hidden (mis)use by requiring a
> manual/physical action.

The problem here is that products that can be used as OpenPGP smart
cards, like the Yubikey, can't just make arbitrary features like
challenge-response for secret key operations. They need to implement the
OpenPGP specification so that all software that works with them (GnuPG,
OpenKeychain, others) can implement the same spec, and everything can just.

The spec currently supports requiring a PIN to do secret key operations,
with rate limiting that makes too many invalid PIN guesses locks the
card. In order to support challenge-response as well I think the OpenPGP
smart card spec would need to get updated, which is a much longer
process that just writing some new software.

Marek Marczykowski-Górecki

unread,
Dec 3, 2016, 2:46:54 PM12/3/16
to Micah Lee, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Some kind of OTP probably could be framed into PIN. Anyway, this does
not solve much bigger problem, that is no protection of the data itself
- - USB VM can intercept the communication and replace/capture what you
want to sign/decrypt.
If there is some protocol to use smartcard over the network, such
protocol probably handle this problem. Not sure if it's possible to use
it here, especially when limited to what Yubikey firmware supports...

- --
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJYQyEoAAoJENuP0xzK19csNroH/1QEeJN2MwHbBTo+g3JlNsNZ
MXs22kmz41evg7lKwwoAuA8/XihRppv0EBPUyEMMi1JmlGgd4Phlafok3rFmILnd
cRG3NsV6Wv69/9aSbxfId6NEEjO5toKdt4DLhR5nVwVamFOCqgVGLxchGzRMMN8E
JrhJ1mxn3w12AufFvtMF7jKXNIiY3REf6kVBjqUcsJmwnW1Tt4WJ+KS8IShCEaJm
i7IfWggxlzKgo4rMXdK22m7G9uvncG6TAMZuonHu92pzuLDoU40iPdpEUmQJyKtF
pibJExdgXHkJicl3j5kwHV0JOyNzgCQkId4fhsVxvexYeuvh9nRaUKwZN+wiAsw=
=Nu+O
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages