Today we’d like to announce the Qubes U2F Proxy. It is a secure proxy intended to make use of U2F two-factor authentication devices with web browsers without exposing the browser to the full USB stack, not unlike the USB keyboard and mouse proxies we’ve already implemented in Qubes.
What is U2F?
U2F, which stands for “Universal 2nd Factor”, is a framework for authentication using hardware devices (U2F tokens) as “second factors”, i.e. what you have as opposed to what you know, like a passphrase. This additional control provides good protection in cases in which the passphrase is stolen (e.g. by phishing or keylogging). While passphrase compromise may not be obvious to the user, a physical device that cannot be duplicated must be stolen to be used outside of the owner’s control. Nonetheless, it is important to note at the outset that U2F cannot guarantee security when the host system is compromised (e.g. a malware-infected operating system under an adversary’s control).
The U2F specification defines protocols for multiple layers from USB to the browser API, and the whole stack is intended to be used with web applications (most commonly websites) in browsers. In most cases, tokens are USB dongles. The protocol is very simple, allowing the devices to store very little state inside (so the tokens may be reasonably cheap) while simultaneously authenticating a virtually unlimited number of services (so each person needs only one token, not one token per application). The user interface is usually limited to a single LED and a button that is pressed to confirm each transaction, so the devices themselves are also easy to use.
Currently, the most common form of two-step authentication consists of a numeric code that the user manually types into a web application. These codes are typically generated by an app on the user’s smartphone or sent via SMS. By now, it is well-known that this form of two-step authentication is vulnerable to phishing and man-in-the-middle attacks due to the fact that the application requesting the two-step authentication code is typically not itself authenticated by the user. (In other words, users can accidentally give their codes to attackers because they do not always know who is really requesting the code.) In the U2F model, by contrast, the browser ensures that the token receives valid information about the web application requesting authentication, so the token knows which application it is authenticating (for details, see here). Nonetheless, some attacks are still possible even with U2F (more on this below).
Our take on U2F
In a conventional setup, web browsers and the USB stack (to which the U2F token is connected) are all running in the same monolithic OS. Since the U2F model assumes that the browser is trustworthy, any browser in the OS is able to access any key stored on the U2F token. The user has no way to know which keys have been accessed by which browsers for which services. If any of the browsers are compromised, it should be assumed that all of the token’s keys have been compromised. (This problem can be mitigated, however, if the U2F device has a special display to show the user what’s being authenticated.) Moreover, since the USB stack is in the same monolithic OS, the system is vulnerable to attacks like BadUSB.
In Qubes OS, by contrast, it is possible to securely compartmentalise the browser in one qube and the USB stack in another so that they are always kept separate from each other. The Qubes U2F Proxy then allows the token connected to the USB stack in one qube to communicate with the browser in a separate qube. We operate under the assumption that the USB stack is untrusted from the point of view of the browser and also that the browser is not to be trusted blindly by the token. Therefore, the token is never in the same qube as the browser. Our proxy forwards only the data necessary to actually perform the authentication, leaving all unnecessary data out, so it won’t become a vector of attack. This is depicted in the diagram below (click for full size).
The Qubes U2F Proxy has two parts: the frontend and the backend. The frontend
runs in the same qube as the browser and presents a fake USB-like HID device
uhid. The backend runs in
sys-usb and behaves like a browser. This is
done using the
u2flib_host reference library. All of our code was written in
Python. The standard qrexec policy is responsible for directing calls to the
vault qube with a dashed line in the bottom portion of the diagram depicts
future work in which we plan to implement the Qubes U2F Proxy with a software
token in an isolated qube rather than a physical hardware token. This is similar
to the manner in which Split GPG allows us to emulate the smart card model
without physical smart cards.
One very important assumption of U2F is that the browser verifies every request sent to the U2F token — in particular, that the web application sending an authentication request matches the application that would be authenticated by answering that request (in order to prevent, e.g., a phishing site from sending an authentication request for your bank’s site). With the WebUSB feature in Chrome, however, a malicious website can bypass this safeguard by connecting directly to the token instead of using the browser’s U2F API.
The Qubes U2F Proxy also prevents this class of attacks by implementing an
additional verification layer. This verification layer allows you to enforce,
for example, that the web browser in your
https://twitter.com. This means that if anything in your
For even more protection, you can combine this with the Qubes firewall to
ensure, for example, that the browser in your
banking qube accesses only one
website (your bank’s website). By configuring the Qubes firewall to prevent your
banking qube from accessing any other websites, you reduce the risk of another
website compromising the browser in an attempt to bypass U2F authentication.
The Qubes U2F Proxy tool can be installed in Qubes 3.2 and 4.0. (However, the
Advanced usage features are only available in 4.0.) These instructions assume
that there is a
sys-usb qube that holds the USB stack, which is the default
configuration in most Qubes OS installations.
$ sudo qubes-dom0-update qubes-u2f-dom0
$ qvm-service --enable work qubes-u2f-proxy
In Fedora TemplateVMs:
$ sudo dnf install qubes-u2f
In Debian TemplateVMs:
$ sudo apt install qubes-u2f
qvm-service --enable (or do this in VM settings -> Services in the Qube
Manager) for all qubes that should have the proxy enabled. As usual with
software updates, shut down the templates after installation, then restart
sys-usb and all qubes that use the proxy. After that, you may use your U2F
token (but see Browser support below).
Advanced usage: per-qube key access
If you are using Qubes 4.0, you can further compartmentalise your U2F keys by
restricting each qube’s access to specific keys. For example, you could make it
so that your
regardless of whether any of the web browsers in your
To enable this, create a file in dom0 named
/etc/qubes-rpc/policy/policy.RegisterArgument+u2f.Authenticate with the
sys-usb @anyvm allow,target=dom0
Next, empty the contents of
/etc/qubes-rpc/policy/u2f.Authenticate so that it
is a blank file. Do not delete the file itself. (If you do, the default file
will be recreated the next time you update, so it will no longer be empty.)
Finally, follow your web application’s instructions to enroll your token and use
it as usual. (This enrollment process depends on the web application and is in
no way specific to Qubes U2F.)
The default model is to allow a qube to access all and only the keys that were
enrolled by that qube. For example, if your
banking qube enrolls your banking
key, and your
will have access to your banking key but not your Twitter key, and your
TemplateVM and browser support
The large number of possible combinations of Qubes version (3.2, 4.0), TemplateVM (Fedora 27, 28; Debian 8, 9), and browser (multiple Google Chrome versions, multiple Chromium versions, multiple Firefox versions) made it impractical for us to test every combination that users are likely to attempt with the Qubes U2F Proxy. In some cases, you may be the first person to try a particular combination. Consequently (and as with any new feature), users will inevitably encounter bugs. We ask for your patience and understanding in this regard. As always, please report any bugs you encounter.
Please note that, in Firefox before Quantum (e.g. Firefox 52 in Debian 9), you
have to install the U2F Support Add-on. In Firefox post-Quantum
you may have to enable the
security.webauth.u2f flag in
and Chromium do not require any special browser extensions.
The U2F specification foresees not only USB tokens, but also smartcard-like (ISO 7816) devices, including NFC devices (mainly used with smartphones). Our qrexec API should work with these, but the backend has not been implemented.
In theory, U2F tokens are not limited to web applications, though much of the standardisation work was done with that use case in mind. Fedora, the distribution we use in dom0, has packages intended to allow user authentication using the same tokens, and the U2F proxy also works in dom0, though we haven’t tested it. (The package is provided, though.) If you’d like to try it yourself, by all means please do and share your experiences on the qubes-devel mailing list.
We’d like to thank Google’s Enterprise Infrastructure Protection Team (aka the Google Security Team) for supporting this project. As part of this collaboration, we’ve also developed another piece of software, which we intend to announce in the near future. Stay tuned.