SlideShare a Scribd company logo
1 of 64
Santiago Kantorowicz
medium.com/@skantos
[T]OTPs are not as secure
as you might believe
Twilio
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Who am I
● Working in CyberSecurity since 2008
● Working at Twilio since 2015
○ 6 years as Authy (Account Security) Security Officer
○ Now Staff Product Security Engineer
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
What’s an OTP/TOTP
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
What’s an OTP
● OTP: One Time Password
● Usually:
○ 4 to 8 digits
○ Random
○ Expires after a few minutes of creation
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
● TOTP: Time-based One Time Password
○ Created algorithmically (time + random secret)
○ 6-8 digits long
○ Also expires (usually) after a few minutes even if shown for some
seconds.
○ Many TOTP can be valid at any given time.
What’s an OTP
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Short Story
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Design & Implementation bugs
Many things can go wrong
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Design bugs
● Long expiration time
● Unlimited (too many) attempts
● OTP too short
● Too many OTPs valid at any given time
● OTP Reuse
● TOTP back use
● Answer machine take-over
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Implementation bugs
● Bypassing OTP flow
○ Forging OTP “pass” parameter/cookie
○ Using OTP validation from one user for another one.
○ OTP in HTML/cookie hidden in plain-text or hashed
● Legacy login without 2FA
● Insecure random
● etc…
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Implementation bugs
● Bypassing OTP flow
○ Forging OTP “pass” parameter/cookie
○ Using OTP validation from one user for another one.
○ OTP in HTML/cookie hidden in plain-text or hashed
● Legacy login without 2FA
● Insecure random
● etc…
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
● Implementation bugs
● SIM Swaps
● Network related attacks (e.g. SS7)
● Social Engineering
● Malware
What we won’t cover
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Attacking a Single OTP
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Windows
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Windows
● Arbitrary time:
○ a token is valid
○ attempts are counted
● Fixed and Sliding windows
0 N
OTP_0 OTP_1 OTP_2 Expiration
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Attacking a Single OTP
● 4 digit OTP: 0000-9999 → 10,000 possibilities.
● 1 attempt → 1 out of 10,000 chances of guessing.
● 5 attempts → 5 out of 10,000 chances of guessing.
So 0.05%. Not bad, not great.
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Let’s assume this:
● 4 digit OTP sent through SMS/email
● Valid for 3 minutes (considering SMS/email delays)
● 5 valid attempts in 3 minutes.
○ “Windows” are 3 minute long
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
You don’t receive the OTP
● Request multiple OTPs in 3 minutes
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
You don’t receive the OTP
● Request multiple OTPs in 3 minutes
○ For example up to 10
● 5*10/10,000 = 0.5%, so 1 in 200 chances of guessing.
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Repeating the attack
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Repeating the attack
● What happens after 3 minutes?
● Attacker can request another 10 OTPs
○ The first 10 are expired though
● So it’s still 1 in 200, right?
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Probability 101
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Going back to the basics
● Throwing a dice twice
● First throw: Odd of having a 6? 1 out of 6.
● Odd of at least one of the 2 throws being a 6?
● 1: 6 2: 1-6 or [6,1][6,2][6,3][6,4][6,5][6,6]
● 1: 1-6 2: 6 or [1,6][2,6][3,6][4,6][5,6][6,6]
● 11/36 ~ 1 out of 3 (0.305)
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Another way of calculating this
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Another way of calculating this
● Probability(of at least one throw being 6):
● 1 - Probability(Both Throws Not being 6) = 1 - P(BTN6)
● P(OTN6) = 1 - P(T6) = 1 - (1 / 6) = 0.83
● P(BTN6) = P(OTN6)2
= 0.832
= 0.694
● 1 - P(BTN6) = 0.305
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Wake up!
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
So: let’s keep the attack going!
● In 1 Hour:
○ 20 windows of 3 minutes (60 / 3 = 20)
● In a Day
○ 480 windows (24 * 20).
≈ 91% chance of success in just ONE day.
(4 digits OTP)
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
OTP Size increase to the Rescue
● Let’s try with 6 digits
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
OTP Size increase to the Rescue
● Let’s try with 6 digits
106
digits
Windows x day
Attempts x
Window
Valid OTPs
x Window
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
OTP Size increase to the Rescue
● Let’s try with 6 digits
● Probability of success in a day is: 2.3%
● Probability of success in 100 days, it’s 91%
● Probability of success in 6 months it’s around 99%
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
The math must be wrong!
● https://github.com/kantos/otp-brute-force-simulator/
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
The math must be wrong!
● https://github.com/kantos/otp-brute-force-simulator/
valid_otp_window = 10
attempts_per_otp = 5
window_length_minutes = 3
attack_days = 1
otp_creations = int(60/window_length_minutes )*24*attack_days
simulations = 10000
otp_length = 6
otp_max_size = 10**otp_length
otp_type = "numeric"
users = 1
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
The math must be wrong!
● https://github.com/kantos/otp-brute-force-simulator/
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
The math must be wrong!
● https://github.com/kantos/otp-brute-force-simulator/
$python otp_brute_force.py
Simulations: 1000
OTP windows: 480
OTP length:4
Probability of success: 0.91
(4 digits OTP)
≈ 91% chance of success in just ONE day.
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
OTP Size increase to the Rescue
● Let’s try with 6 digits
● Probability of success in a day is: 2.3%
● Probability of success in 100 days, it’s 91%
● Probability of success in 6 months it’s around 99%
$python otp_brute_force.py
Simulations: 100000
OTP windows: 480
OTP length:6
Probability of success: 0.0238
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
OTP Size increase to the Rescue
● Let’s try with 6 digits
● Probability of success in a day is: 2.3%
● Probability of success in 100 days, it’s 91%
● Probability of success in 6 months it’s around 99%
$python otp_brute_force.py
Simulations: 100000
OTP windows: 48000
OTP length:6
Probability of success: 0.90762
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
OTP Size increase to the Rescue
● Let’s try with 6 digits
● Probability of success in a day is: 2.3%
● Probability of success in 100 days, it’s 91%
● Probability of success in 6 months it’s around 99%
$python otp_brute_force.py
Simulations: 10000
OTP windows: 86400
OTP length:6
Probability of success: 0.9884
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Brute forcing windows
● Random OTPs are independent within windows.
○ OK to attempt same OTPs.
○ E.g. 000001, 000002, 000003, 000004, 000005, and repeat.
● TOTPs are not independent. It’s due to usage of sliding windows.
○ RFC6238: “We RECOMMEND that at most one time step is
allowed as the network delay.”
○ Recommendation: Incremental OTPs (and start over)
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
But TOTP is safer! Right? Right?
Time-step: 30 seconds. Window 1 minute. 2 time-steps valid per window. Since
it’s sliding there are 3 OTP valid at any given window.
TimeStep 0
OTP_0 OTP_0 / OTP_1 OTP_1 / OTP_2
TimeStep 1 TimeStep 2
Window 1
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
But TOTP is safer! Right? Right?
● Probability of guessing in 6 months is
around 93%
Time-step: 30 seconds. Window 1 minute. 2 time-steps valid per window.
Since it’s sliding there are 3 OTP valid at any given window.
6 months
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Let's take it up a notch
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Parallelizing the attack!
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Parallelizing the attack!
● Why attack one user at a time?
● Whatsapp, Uber, etc: Login = 1 valid OTP!
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Parallelizing the attack!
● Credential stuffing!!
○ Auth0(Okta): “nearly half of all login requests we receive each day are attempts at
credential stuffing.”
○ Google: “65% of all people reuse the same password on multiple (and sometimes
all) accounts”
https://auth0.com/blog/what-is-credential-stuffing/
https://services.google.com/fh/files/blogs/google_security_infographic.pdf
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Parallelizing the attack!
● 6 digit OTP, 10 valid at a time for 3 minutes, 5 attempts.
● Let’s attack 100 users in parallel.
● In 1 day: 91% chance of success
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Parallelizing the attack!
● OK, you convinced me, let’s go with 8 digit OTPs, that
should be enough.
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Parallelizing the attack! (8 digit OTP)
● Let’s attack 100 users in parallel.
○ In 100 days: 91% chance of success
● Let’s attack 1000 user in parallel
○ In 15 days: 97% chance of success
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
I know the drill, you will now introduce Alphanumeric
characters
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Let’s try something instead!
● Let’s introduce “attempt” rate limits
○ 60 per month (login/transact twice a day)
● In 1 month, attacking 1000 users (6 digit OTP)
○ 95% chance of success.
Rate limit
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Alphanumeric… sucks!
● Copy/Paste → OK!
● Typo errors
○ Shortsighted, minor/major disabilities, being human
Tubaam
wEze4A
MTB8QK
xjSehq
5t3CCv
6i8tKD
FmK7Xg
DUiz9n
xnPCdH
Am3Dwu
● Mobile phones automatic
○ Case change
○ Autocorrect
● Avoid l, 1, O, 0 (maybe B, 8)
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Alphanumeric… sucks! But works
● 58 character universe
● 6 OTP length
● 60 attempts x month (rate limit)
● For 6 months
● 10,000 attacks in parallel
● 0.47% chance of success.
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Mitigations
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Mitigations
1. Deliver always the same OTP during the same window.
2. 3-5 attempts per window.
3. Limit amount of attempts, per user, per day, per week, per month.
a. 5 per day, 10 per week, 20 per month.
b. Incremental failure delays
4. Detect credential stuffing attacks.
a. E.g. IP rate limits
b. Leaked password checks
c. Same invalid password attempts in different users.
d. etc.
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Mitigations
5. Don’t disclose if the OTP or the Password is wrong.
6. Use better solutions
○ U2F keys, push authentication, Direct carrier billing.
○ Enforce it on critical users or use-cases
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Mitigations
7. If you detect something “odd” implement some or all:
a. Service wide or per user CAPTCHA
b. Javascript (POW) validations,
c. Challenge the user with a knowledge question
d. Send another OTP through another channel (challenge them
separately)
e. Increase the length of the OTP (or character set).
8. Send email alerts to users
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Mitigations
● Combine them
● Do the math
● Accept what’s reasonable to your use case
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Final thoughts
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Final thoughts
● [T]OTP implementations are not foolproof.
● Design your security around your acceptable risk
● These findings apply to any low entropy challenge
[T]OTPs are not as secure as you might believe
Santiago Kantorowicz
Thank you!
https://xkcd.com/2543/

More Related Content

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

OWASP Global AppSec Dublin 2023 [T]OTPs are not as secure as you might believe

  • 1. Santiago Kantorowicz medium.com/@skantos [T]OTPs are not as secure as you might believe Twilio
  • 2. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Who am I ● Working in CyberSecurity since 2008 ● Working at Twilio since 2015 ○ 6 years as Authy (Account Security) Security Officer ○ Now Staff Product Security Engineer
  • 3. [T]OTPs are not as secure as you might believe Santiago Kantorowicz What’s an OTP/TOTP
  • 4. [T]OTPs are not as secure as you might believe Santiago Kantorowicz
  • 5. [T]OTPs are not as secure as you might believe Santiago Kantorowicz
  • 6. [T]OTPs are not as secure as you might believe Santiago Kantorowicz
  • 7. [T]OTPs are not as secure as you might believe Santiago Kantorowicz
  • 8. [T]OTPs are not as secure as you might believe Santiago Kantorowicz What’s an OTP ● OTP: One Time Password ● Usually: ○ 4 to 8 digits ○ Random ○ Expires after a few minutes of creation
  • 9. [T]OTPs are not as secure as you might believe Santiago Kantorowicz ● TOTP: Time-based One Time Password ○ Created algorithmically (time + random secret) ○ 6-8 digits long ○ Also expires (usually) after a few minutes even if shown for some seconds. ○ Many TOTP can be valid at any given time. What’s an OTP
  • 10. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Short Story
  • 11. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Design & Implementation bugs Many things can go wrong
  • 12. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Design bugs ● Long expiration time ● Unlimited (too many) attempts ● OTP too short ● Too many OTPs valid at any given time ● OTP Reuse ● TOTP back use ● Answer machine take-over
  • 13. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Implementation bugs ● Bypassing OTP flow ○ Forging OTP “pass” parameter/cookie ○ Using OTP validation from one user for another one. ○ OTP in HTML/cookie hidden in plain-text or hashed ● Legacy login without 2FA ● Insecure random ● etc…
  • 14. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Implementation bugs ● Bypassing OTP flow ○ Forging OTP “pass” parameter/cookie ○ Using OTP validation from one user for another one. ○ OTP in HTML/cookie hidden in plain-text or hashed ● Legacy login without 2FA ● Insecure random ● etc…
  • 15. [T]OTPs are not as secure as you might believe Santiago Kantorowicz ● Implementation bugs ● SIM Swaps ● Network related attacks (e.g. SS7) ● Social Engineering ● Malware What we won’t cover
  • 16. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Attacking a Single OTP
  • 17. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Windows
  • 18. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Windows ● Arbitrary time: ○ a token is valid ○ attempts are counted ● Fixed and Sliding windows 0 N OTP_0 OTP_1 OTP_2 Expiration
  • 19. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Attacking a Single OTP ● 4 digit OTP: 0000-9999 → 10,000 possibilities. ● 1 attempt → 1 out of 10,000 chances of guessing. ● 5 attempts → 5 out of 10,000 chances of guessing. So 0.05%. Not bad, not great.
  • 20. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Let’s assume this: ● 4 digit OTP sent through SMS/email ● Valid for 3 minutes (considering SMS/email delays) ● 5 valid attempts in 3 minutes. ○ “Windows” are 3 minute long
  • 21. [T]OTPs are not as secure as you might believe Santiago Kantorowicz You don’t receive the OTP ● Request multiple OTPs in 3 minutes
  • 22. [T]OTPs are not as secure as you might believe Santiago Kantorowicz You don’t receive the OTP ● Request multiple OTPs in 3 minutes ○ For example up to 10 ● 5*10/10,000 = 0.5%, so 1 in 200 chances of guessing.
  • 23. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Repeating the attack
  • 24. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Repeating the attack ● What happens after 3 minutes? ● Attacker can request another 10 OTPs ○ The first 10 are expired though ● So it’s still 1 in 200, right?
  • 25. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Probability 101
  • 26. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Going back to the basics ● Throwing a dice twice ● First throw: Odd of having a 6? 1 out of 6. ● Odd of at least one of the 2 throws being a 6? ● 1: 6 2: 1-6 or [6,1][6,2][6,3][6,4][6,5][6,6] ● 1: 1-6 2: 6 or [1,6][2,6][3,6][4,6][5,6][6,6] ● 11/36 ~ 1 out of 3 (0.305)
  • 27. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Another way of calculating this
  • 28. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Another way of calculating this ● Probability(of at least one throw being 6): ● 1 - Probability(Both Throws Not being 6) = 1 - P(BTN6) ● P(OTN6) = 1 - P(T6) = 1 - (1 / 6) = 0.83 ● P(BTN6) = P(OTN6)2 = 0.832 = 0.694 ● 1 - P(BTN6) = 0.305
  • 29. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Wake up!
  • 30. [T]OTPs are not as secure as you might believe Santiago Kantorowicz So: let’s keep the attack going! ● In 1 Hour: ○ 20 windows of 3 minutes (60 / 3 = 20) ● In a Day ○ 480 windows (24 * 20). ≈ 91% chance of success in just ONE day. (4 digits OTP)
  • 31. [T]OTPs are not as secure as you might believe Santiago Kantorowicz OTP Size increase to the Rescue ● Let’s try with 6 digits
  • 32. [T]OTPs are not as secure as you might believe Santiago Kantorowicz OTP Size increase to the Rescue ● Let’s try with 6 digits 106 digits Windows x day Attempts x Window Valid OTPs x Window
  • 33. [T]OTPs are not as secure as you might believe Santiago Kantorowicz OTP Size increase to the Rescue ● Let’s try with 6 digits ● Probability of success in a day is: 2.3% ● Probability of success in 100 days, it’s 91% ● Probability of success in 6 months it’s around 99%
  • 34. [T]OTPs are not as secure as you might believe Santiago Kantorowicz
  • 35. [T]OTPs are not as secure as you might believe Santiago Kantorowicz The math must be wrong! ● https://github.com/kantos/otp-brute-force-simulator/
  • 36. [T]OTPs are not as secure as you might believe Santiago Kantorowicz The math must be wrong! ● https://github.com/kantos/otp-brute-force-simulator/ valid_otp_window = 10 attempts_per_otp = 5 window_length_minutes = 3 attack_days = 1 otp_creations = int(60/window_length_minutes )*24*attack_days simulations = 10000 otp_length = 6 otp_max_size = 10**otp_length otp_type = "numeric" users = 1
  • 37. [T]OTPs are not as secure as you might believe Santiago Kantorowicz The math must be wrong! ● https://github.com/kantos/otp-brute-force-simulator/
  • 38. [T]OTPs are not as secure as you might believe Santiago Kantorowicz The math must be wrong! ● https://github.com/kantos/otp-brute-force-simulator/ $python otp_brute_force.py Simulations: 1000 OTP windows: 480 OTP length:4 Probability of success: 0.91 (4 digits OTP) ≈ 91% chance of success in just ONE day.
  • 39. [T]OTPs are not as secure as you might believe Santiago Kantorowicz OTP Size increase to the Rescue ● Let’s try with 6 digits ● Probability of success in a day is: 2.3% ● Probability of success in 100 days, it’s 91% ● Probability of success in 6 months it’s around 99% $python otp_brute_force.py Simulations: 100000 OTP windows: 480 OTP length:6 Probability of success: 0.0238
  • 40. [T]OTPs are not as secure as you might believe Santiago Kantorowicz OTP Size increase to the Rescue ● Let’s try with 6 digits ● Probability of success in a day is: 2.3% ● Probability of success in 100 days, it’s 91% ● Probability of success in 6 months it’s around 99% $python otp_brute_force.py Simulations: 100000 OTP windows: 48000 OTP length:6 Probability of success: 0.90762
  • 41. [T]OTPs are not as secure as you might believe Santiago Kantorowicz OTP Size increase to the Rescue ● Let’s try with 6 digits ● Probability of success in a day is: 2.3% ● Probability of success in 100 days, it’s 91% ● Probability of success in 6 months it’s around 99% $python otp_brute_force.py Simulations: 10000 OTP windows: 86400 OTP length:6 Probability of success: 0.9884
  • 42. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Brute forcing windows ● Random OTPs are independent within windows. ○ OK to attempt same OTPs. ○ E.g. 000001, 000002, 000003, 000004, 000005, and repeat. ● TOTPs are not independent. It’s due to usage of sliding windows. ○ RFC6238: “We RECOMMEND that at most one time step is allowed as the network delay.” ○ Recommendation: Incremental OTPs (and start over)
  • 43. [T]OTPs are not as secure as you might believe Santiago Kantorowicz But TOTP is safer! Right? Right? Time-step: 30 seconds. Window 1 minute. 2 time-steps valid per window. Since it’s sliding there are 3 OTP valid at any given window. TimeStep 0 OTP_0 OTP_0 / OTP_1 OTP_1 / OTP_2 TimeStep 1 TimeStep 2 Window 1
  • 44. [T]OTPs are not as secure as you might believe Santiago Kantorowicz But TOTP is safer! Right? Right? ● Probability of guessing in 6 months is around 93% Time-step: 30 seconds. Window 1 minute. 2 time-steps valid per window. Since it’s sliding there are 3 OTP valid at any given window. 6 months
  • 45. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Let's take it up a notch
  • 46. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Parallelizing the attack!
  • 47. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Parallelizing the attack! ● Why attack one user at a time? ● Whatsapp, Uber, etc: Login = 1 valid OTP!
  • 48. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Parallelizing the attack! ● Credential stuffing!! ○ Auth0(Okta): “nearly half of all login requests we receive each day are attempts at credential stuffing.” ○ Google: “65% of all people reuse the same password on multiple (and sometimes all) accounts” https://auth0.com/blog/what-is-credential-stuffing/ https://services.google.com/fh/files/blogs/google_security_infographic.pdf
  • 49. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Parallelizing the attack! ● 6 digit OTP, 10 valid at a time for 3 minutes, 5 attempts. ● Let’s attack 100 users in parallel. ● In 1 day: 91% chance of success
  • 50. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Parallelizing the attack! ● OK, you convinced me, let’s go with 8 digit OTPs, that should be enough.
  • 51. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Parallelizing the attack! (8 digit OTP) ● Let’s attack 100 users in parallel. ○ In 100 days: 91% chance of success ● Let’s attack 1000 user in parallel ○ In 15 days: 97% chance of success
  • 52. [T]OTPs are not as secure as you might believe Santiago Kantorowicz I know the drill, you will now introduce Alphanumeric characters
  • 53. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Let’s try something instead! ● Let’s introduce “attempt” rate limits ○ 60 per month (login/transact twice a day) ● In 1 month, attacking 1000 users (6 digit OTP) ○ 95% chance of success. Rate limit
  • 54. [T]OTPs are not as secure as you might believe Santiago Kantorowicz
  • 55. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Alphanumeric… sucks! ● Copy/Paste → OK! ● Typo errors ○ Shortsighted, minor/major disabilities, being human Tubaam wEze4A MTB8QK xjSehq 5t3CCv 6i8tKD FmK7Xg DUiz9n xnPCdH Am3Dwu ● Mobile phones automatic ○ Case change ○ Autocorrect ● Avoid l, 1, O, 0 (maybe B, 8)
  • 56. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Alphanumeric… sucks! But works ● 58 character universe ● 6 OTP length ● 60 attempts x month (rate limit) ● For 6 months ● 10,000 attacks in parallel ● 0.47% chance of success.
  • 57. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Mitigations
  • 58. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Mitigations 1. Deliver always the same OTP during the same window. 2. 3-5 attempts per window. 3. Limit amount of attempts, per user, per day, per week, per month. a. 5 per day, 10 per week, 20 per month. b. Incremental failure delays 4. Detect credential stuffing attacks. a. E.g. IP rate limits b. Leaked password checks c. Same invalid password attempts in different users. d. etc.
  • 59. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Mitigations 5. Don’t disclose if the OTP or the Password is wrong. 6. Use better solutions ○ U2F keys, push authentication, Direct carrier billing. ○ Enforce it on critical users or use-cases
  • 60. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Mitigations 7. If you detect something “odd” implement some or all: a. Service wide or per user CAPTCHA b. Javascript (POW) validations, c. Challenge the user with a knowledge question d. Send another OTP through another channel (challenge them separately) e. Increase the length of the OTP (or character set). 8. Send email alerts to users
  • 61. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Mitigations ● Combine them ● Do the math ● Accept what’s reasonable to your use case
  • 62. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Final thoughts
  • 63. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Final thoughts ● [T]OTP implementations are not foolproof. ● Design your security around your acceptable risk ● These findings apply to any low entropy challenge
  • 64. [T]OTPs are not as secure as you might believe Santiago Kantorowicz Thank you! https://xkcd.com/2543/