Nobody needs convincing that the security of our data and accounts is extremely important, although it doesn't hurt to remind ourselves every now and then. What people disagree on is how to protect their property. Some say they have nothing important to hide and a single password is enough. Others arm themselves in every possible way: they encrypt files on their disk and their emails, and some even keep a separate computer just for online banking. Of course, it all depends on the situation, on how safe we feel and on how much we know about the possible threats. We approach logging in to a service that stores our contracts very differently from logging in to a site with memes. Still, a few basic rules are worth drilling into ourselves, and one of them is turning on two-factor authentication in most places.
In this article we explain what this technique is, why you should use it, and which variants are available. Variants, because it doesn't come in just one version but in three basic ones, and some companies try to introduce complementary and hybrid solutions.
What is 2FA?
Two-factor authentication (2FA) is a way of logging in to a service by confirming your identity in two different ways. Note the words "two different ways". It doesn't mean entering your password twice, or using two different passwords typed into a similar-looking window. To explain why this matters so much, let's look at three examples.
We all know people who use one password for everything, or a few that are variations of the first one. They explain it as a way to remember their access to services more easily, but they obviously don't assume that this password could leak somewhere. And yet it can happen to anyone: we type our credentials into the wrong place, someone watches the keys we press over our shoulder, or we mix up the fields and the password lands in the browser's autofill. The consequences in this case can be disastrous. Since the attacker knows our email address (which is easy enough to find), they can log in everywhere with the same password, including our email account (which lets them reset passwords in other services) and our bank account. I hardly need to describe what that leads to.
Now take a person who is aware of the threat and has a different password for each service, or for most of them. The strength of those passwords is a separate matter, but let's assume they have a reasonable length and contain uppercase and lowercase letters, digits and special characters. Is that safe? Certainly safer than in the previous example, but a password can still leak through our carelessness, or someone can simply guess it with a so-called brute force attack (trying all combinations, possibly with the help of a dictionary). Of course, if an attacker breaks into one service this way, we can still limit the damage by changing our secret there once we notice. But if someone discovers the password to our email account, things stop being funny, because they can reset the passwords everywhere else. And creating a separate email account for every profile on the Internet is, let's be honest, unrealistic and impractical.
But let's assume we look after our passwords regularly: we not only use a different one for each site and service, but also change them from time to time. We make sure nobody sees them being typed, we enter them only on one designated computer, and we have the habit of clearing the browser cache. But remember that we are only one side of the communication. On the other side is the service we log in to, and it may not always be equally well protected. Alerts about leaked information often appear precisely after databases are broken into. Fortunately, most services hash passwords, which makes it much harder for an intruder to guess them, but it is still not impossible.
All these cases have one thing in common: if someone knows our login (usually an email address) and our password, they can impersonate us. What's more, it is hard to counteract this actively or to find out that we are falling victim to an attack right now. The "hacker" (although the word is a big exaggeration here) needs nothing else. Of course, more passwords to enter can raise the level of security, but it is all useless when someone has access to our computer or smartphone, or has enough time to guess the second and every further secret as well. That is why it is so important that the second level of verification we want to enable requires a different channel. It is the same principle that requires sending an encrypted archive and its password by two different methods (for example email and phone).
Enabling 2FA lets you choose (naturally, in services that implement the given method) one of three ways of additional verification: SMS, one-time codes and so-called U2F.
Short text messages (SMS)
This is the most common form, and many people have gotten used to it. After the user enters the password, the service sends them an SMS with a one-time code to type in. Only after entering this string of characters in the application is the user authenticated.
For many people this is the simplest form to understand and the most intuitive. Especially since everyone (or almost everyone) has a mobile phone and coverage, so access to text messages is very common. From the user's point of view it therefore seems the most promising way of confirming authentication, particularly because a thief would need to get hold of our phone. However, like everything else, the SMS method has its drawbacks.
First, it requires giving the service your phone number. For some people that is no obstacle at all, because they share much more anyway, but for others it means overcoming a certain barrier, since we usually share a phone number much less willingly than an email address. We used to worry about silly prank calls, but today giving out a number can land you in the database of telemarketers and scammers, or you may simply dread a call from a service's support team, because not everyone likes talking on the phone. The solution, of course, is a second phone number used only for 2FA.
Second, it is a relatively expensive form for application developers. Sending an SMS through gateways provided by various external companies is not free, and with a huge number of users who may generate several such messages a day, the cost becomes considerable. Incidentally, this is probably the reason why in March 2023 Twitter, on Elon Musk's decision, blocked this form for users of the free service. Some will say it was about security (more on that in a moment), others that it was about saving money. I lean toward the second version (especially since Musk has switched off services before to save on servers and see which ones are really needed), although I admit that from a PR point of view it looks like an attempt to patch up the budget at the expense of users' security. That isn't entirely true once you look at it more closely, but the impression remains.
Third, security itself. SMS messages are not fully secure. They can fail when exposed to a SIM card attack, which is entirely possible. Still, it is better to have SMS codes turned on than to have no form of 2FA at all.
One-time codes (OTP)
The second method also involves "passwords" that are short-lived and can be used only once (one-time passwords, OTP), but it skips the SMS route. It is familiar to customers of some banks, which provide code cards or apps that generate tokens. How does it work?
First, the user has to install an authenticator app on their phone. The choice is quite wide, from the most popular Google Authenticator and Microsoft Authenticator to less well-known but still good options such as LastPass, Auth0, Twilio and many others. Most of them are free, some also have a desktop version, and they differ in details, but the way they work is similar.
After installation, the user can pair the app with the services they want to log in to. For example, if we want to use it to log in to Mastodon, we add a new "account" in the authenticator, and then open the QR code in Mastodon's settings. We scan that QR code with the phone, and from then on the app generates one-time codes that are valid for a limited time (then refreshes them on its own, creating new sets of numbers). It works exactly like SMS, except that we don't receive any text messages. Besides the QR code, you can also use setup keys.
As you can see, this method is very similar and, what's more, it doesn't even require Internet access. All you need is the app installed on your phone, which generates new codes for the paired services from time to time. When we need to log in or confirm some operation, we open the app and copy the code. It is free (although some services offer paid features), easy to apply, and cheaper for the creators of the services too.
Unfortunately, here too the problem remains of codes being intercepted or extracted by social engineering (so-called phishing).
Hardware key (U2F)
We come to the third and most secure method of two-step authentication, based on the FIDO standard. U2F hardware keys are usually small devices resembling flash drives, which you plug into the computer's USB port and activate at the right moment, which triggers the entry of a code. So there is no interception of codes and no generating them from outside, because you must physically possess the device. And these devices are usually with their owner, attached to a keychain or hidden in a safe place. Each unit has its own unique, encrypted access code, and it can be considered, more or less, impossible to counterfeit.
Of course, every rose has its thorn: such a key costs the user some money. Depending on the version and the level of protection, the price starts at around 150 zł. Like the OTP apps discussed earlier, one unit can be used to log in to many different services, and you don't need a separate device for each. Remembering to carry the key everywhere you want to log in to a protected application can also be a problem, but if we attach it to our keys, we shouldn't suffer much.
This method is therefore the most secure and is recommended by industry sites such as Niebezpiecznik or Zaufana Trzecia Strona (both Polish security portals). An amount of around 150 zł for one key (although it is worth having two, more on that in a moment) is really modest for protecting your accounts in many services against unauthorized access. You can also check which key best fits your needs on the manufacturer's site, that is Yubico. You can also read more about this method on Sekurak.
Other methods
Application developers have known about this problem for a long time, and they try to attract users by focusing on security and showing how advanced they are in this area. A huge number of popular services support the methods listed above, but also add their own. One example is the option to provide a backup email address, or to display login history, which lets users see whether someone has tried, or even managed, to take over their account.
And what if we didn't have to type a password at all? At this point some will mention fingerprints, face recognition and iris scanning, in other words everything that falls under biometrics. Many people already use these technologies, but others have concerns, for example about a device failure and being unable to log in to their account despite having every right to (say, the fingerprint is not matched correctly to the stored pattern). Some developers also use one-time passwords sent to an email address, so you don't have to set a permanent one. It is a kind of "forced" OTP.
What if I lose my authentication device?
This is a worry that keeps some people awake at night. Indeed, losing a phone or a key, as well as ordinary hardware failures, is a problem you need a solution for. Many services offer so-called backup codes, which you can use when there is a problem with SMS or the OTP app. You have to generate them beforehand and store them somewhere, though. With hardware keys, it is worth investing in two devices, where the second serves as exactly such a backup. We then carry one with us and leave the spare in a safe place at home.
Summary
Two-factor authentication is a good way to add protection to your accounts in services (and not only the most valuable ones), and for more prominent people or business services it is practically a necessity if you don't want to become the unfortunate hero of some attack. If 2FA is available, we recommend setting it up and using it, because trouble never sleeps and you never know when the protection will turn out to be needed.
Best regards and thank you, Jakub Rojek.


