What's the optimal length for a 2FA code? (2024)

The other day, a company sent me a 2FA code which was only four digits long.

What's the optimal length for a 2FA code? (1)

I'll admit, this weirded me out. Surely 4 is just far too short. Right? I think almost every 2FA code I've seen has been 6 digits long. Even back in the days of carrying one of those physical RSA fobs, 6 has been the magic number.

But why?

A 2FA code is meant to prevent a specific class of problem. If an attacker has got hold of something you are (your username1) and something you know (your password), you are still protected by something you have (your phone). Whether your second-factor is an app generating unique codes, a SIM card receiving SMS2, or a cryptographic enclave producing signed transactions - it doesn't matter. The attacker can use your password but won't get the unique second code.

Suppose you received a 2FA code that was a single digit. Is that secure enough?

I think most reasonable people would say that wasn't secure. An attacker has a 10% chance of guessing the 2FA. If the system allows for a couple of retries before locking them out, they've got a 30% chance of getting in.

Similarly a 2 or 3 digit code probably doesn't provide sufficient protection.

A typical bank card PIN is 4 digits. So an attacker has a 1 in 10,000 chance of guessing. That might be slightly better as bank PINs usually don't allow repeated digits, palindromes, and a few other combinations.

I suppose that if an attacker had compromised tens of thousands of credentials, and the service allowed for a few incorrect entries, it is statistically likely that they might be able to compromise a few accounts if they were only protected by 4 digits.

As 2FA codes get longer, they begin to reach the limits of what humans can remember. Yes, I know you have an excellent memory - but not everyone does. And I know your fancy 2FA app automatically copies and pastes the codes - but not everyone does. We have to work to what the average user is capable of at a minimum.

I think most people would find it annoying - if not impossible - to remember a 10 digit one-time password.

If you're copying a code from your phone to type into your laptop, there's probably an upper limit on what people will be prepared to do. No one is going to manually transcribe 128 digits. And, if they did, they'd likely introduce several errors.

So the industry has seemingly settled on 6 digits. I've ranted before about the lack of standardisation in the OTP specification. But all of them seem to allow 6 - 8 digits.

I suspect 6 is the standard because that's what the original RSA SecurID tokens used by default.

What's the optimal length for a 2FA code? (2)

An attacker would have to be incredibly lucky to randomly guess a 6 digit code - literally a one-in-a-million chance3. Even if they had multiple retries, it's still statistically unlikely.

Once I logged in using my 4 digit code, I had full access to my account. But if I wanted to make any changes, I had to wait for another 2FA code to be sent. So I guess the effective length of code was actually 8 digits. Which seems excessive 🤣

Thoughts from the community

I asked my Twitter buddies for their wisdom:

What's the optimal length for a 2FA code? (3)What's the optimal length for a 2FA code? (4)
Replying to @edent@edent Depends on retry/lockout policy? 4 digits is enough for a bank card, but there is a physical token involved there - is the account as valuable as that, though?

Gut feeling is 6 digits is right for most circ*mstances though...

What's the optimal length for a 2FA code? (5)

Rob Styles

@mmmmmrob

What's the optimal length for a 2FA code? (6)
Replying to @mmmmmrob@edent 10,000 combinations is plenty to prevent guessing, and making the code longer doesn't add any additional protection if the message/device is compromised.

Making the code longer makes the usability exponentially worse when the code has to be re-keyed.

What's the optimal length for a 2FA code? (7)

Ryan Cullen

@artesea

What's the optimal length for a 2FA code? (8)
Replying to @edent@edent Assuming just three retries before the code expires, 3 in 10,000 doesn't sound too bad. Also easy to remember whilst switching between the messaging app/notification shade and the app/website wanting it. I find with 6 I need to go back and forth. Worse with alphanumeric.
What's the optimal length for a 2FA code? (9)

James Seconde

@SecondeJ

What's the optimal length for a 2FA code? (10)
Replying to @mmmmmrob@mmmmmrob @edent For these sorts of reasons, this is why @VonageDev 2FA (Verify) lets you choose between 4 and 6 digits
What's the optimal length for a 2FA code? (11)

Rhidian Bramley

@RhidianB

What's the optimal length for a 2FA code? (12)
Replying to @edent@edent Zero digits. More user friendly and secure to send a hyperlink with a single use time limited encryption key. No heed to compromise usability vs security. Win win.
What's the optimal length for a 2FA code? (13)

Chris Hill-Scott

@quis

What's the optimal length for a 2FA code? (14)
Replying to @edent@edent Design System says 5 digits: design-system.service.gov.uk/patterns/confi…

On Notify 2% of attempts are miskeyed – people with dyslexia probably disproportionately affected.

4 would be better – used by Airbnb and Uber – but you need stronger technical measures in place to prevent automated attacks.

What do you think?

  1. Traditionally, the something you are is a biometric. However biometrics are static - they never alter. So they're poor for some choices of authentication. A username represents something you are. Everyone can see your username - just like everyone can see the fingerprints you leave on every touchscreen and the DNA you shed all over the place.
  2. Let's gloss over SMS being a bit vulnerable for now.
  3. Although, as per Terry Pratchett: "Million-to-one chances crop up nine times out of ten.".
What's the optimal length for a 2FA code? (2024)

FAQs

What's the optimal length for a 2FA code? ›

Most 2FA/MFA apps (Microsoft and Google ones) use 6.

How long should a 2FA code last? ›

2FA codes have a short lifespan, typically 30-60 seconds. If the code is nearing its expiration, just hang tight and wait for the next one. 2. Is Your Phone's Clock Out of Sync?

How many digits is a 2FA code? ›

Perhaps the most common method of implementing 2FA. This method sends the user a unique token via SMS text message, normally a 5-10 digit code, after they have successfully entered their username and password.

How long should a verification code be? ›

Broadly, a code expiration of 5 minutes is recommended for verification use cases.

Why are 2FA codes 6 digits? ›

An attacker has a 10% chance of guessing the 2FA. If the system allows for a couple of retries before locking them out, they've got a 30% chance of getting in. Similarly a 2 or 3 digit code probably doesn't provide sufficient protection. A typical bank card PIN is 4 digits.

What is the 2FA code protocol? ›

Two-factor authentication (2FA) is a security system that requires two separate, distinct forms of identification in order to access something. The first factor is a password and the second commonly includes a text with a code sent to your smartphone, or biometrics using your fingerprint, face, or retina.

How long is an authenticator code? ›

Google Authenticator app generates a six-digit code for you to enter when you log in. The code changes about every minute.

What is the limit of 2 factor authentication? ›

Now this limit has been reduced from Rs. 100 crores to Rs. 20 Crores from 01st Nov 2023. Users are requested to register for 2FA immediately and also create sub-users so that EWB activities are managed without any problem.

How long does a security code have to be? ›

The card security code (CSC) is usually a 3 - or 4 - digit number, which is not part of the credit card number.

Why is 2-Step Verification bad? ›

Using two-factor authentication (2FA) to log in to your system is better than using a traditional password alone. But if your 2FA code is sent as a text, it could lead to a costly data breach. If you're currently using SMS for your 2FA, you better reconsider.

What are the odds of guessing a 6-digit code? ›

A six-digit code has 1,000,000 possible states, hence allows for a 1/1,000,000 chance to correctly guess it on the first try. Given that we can try thrice, the second chance is 1 / 999,999 and the third is 1 / 999,998.

What is the 2FA authentication standard? ›

Two-factor authentication (2FA) is an identity and access management security method that requires two forms of identification to access resources and data. 2FA gives businesses the ability to monitor and help safeguard their most vulnerable information and networks.

Can 2FA codes be guessed? ›

A six digit OTP has only a million possible values. Guessing once per second it only takes a couple days to guess. This is also why a platform should never confirm that a password is correct when 2FA is enabled, only confirm if both have been solved.

Do 2FA backup codes expire? ›

A backup code is used for verification on login. Each code can be used only one time. You can generate new backup codes as needed. Backup codes do not expire, however, if you generate a new set of backup codes, the previous set of your codes is no longer valid.

Does 2FA run out? ›

Each backup code expires after one use. To generate new backup codes, disable two-factor authentication and then re-enable it. If you run out of backup codes or lose them, you will need to contact customer support to disable two-factor authentication.

How often should I require 2FA? ›

Applications, unlike browsers, have a 90 day rolling token. This means that you should not be asked to verify with MFA if you use an app more frequently than every 90 days. Any changes that cause you to login again, such as a password change, will trigger MFA verification.

Why did my 2FA code stop working? ›

After you've set up two-factor authentication (2FA), the codes generated by your authenticator app may stop working. This commonly happens due to time sync issues. 2FA systems use global universal time (UTC). Your user device executes a time service to stay in sync with UTC.

Top Articles
Social Security Disability Rules After Age 55
PowerReviews Badges Definitions | PowerReviews
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
Things To Do In Atlanta Tomorrow Night
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Dmv In Anoka
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Gov. Deandrea McKenzie

Last Updated:

Views: 6307

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Gov. Deandrea McKenzie

Birthday: 2001-01-17

Address: Suite 769 2454 Marsha Coves, Debbieton, MS 95002

Phone: +813077629322

Job: Real-Estate Executive

Hobby: Archery, Metal detecting, Kitesurfing, Genealogy, Kitesurfing, Calligraphy, Roller skating

Introduction: My name is Gov. Deandrea McKenzie, I am a spotless, clean, glamorous, sparkling, adventurous, nice, brainy person who loves writing and wants to share my knowledge and understanding with you.