Skip to content
Account takeover Disclosed report Intermediate

Improper implementation of 2FA Secret Token can lead to Account Takeover

The 2FA secret token generated when enabling two-factor authentication remained static across login sessions until 2FA was actually enabled. An attacker who obtained a victim's password could log in, capture the secret token, and later use it to bypass 2FA even after the victim enabled it.

GitLab

Originally disclosed on GitLab

  • Fixed in 1 hour
  • Disclosed after 1 hour

HackerOne report #839070 by rgupt on 2020-04-04, assigned to @cmaxim:

Summary

This issue was inspired by one of the reports #100509 submitted to HackerOne. They have fixed this issue, however this issue is seen on Gitlab platform and can lead to Account Takeover because of improper implementation of 2FA Secret Token.

Description

It is observed that the 2FA Authenticator Secret Code generated for an account remains static even when user logs out and logs into the application multiple times.

Nowadays users credentials are almost compromised on one site or another on a daily basis and users almost have same passwords across all the websites. Hence, a hacker who is able to login to Gitlab with those compromised credentials can capture the 2FA Secret token and store them for future use and exploits and even when the victims enable their 2FA on their account, their account could still be accessible by the hacker since they have the 2FA Secret Token.

Steps to reproduce

  1. Login to Gitlab and go to Settings > Account > Two Factor Authentication and click on Enable 2FA.
  2. Note down the SECRET_TOKEN of the 2FA barcode. It is displayed under the section "Can't scan the code? To add the entry manually, provide the following details to the application on your phone."
  3. Now logout of Gitlab and login again.
  4. Go to Settings > Account > Two Factor Authentication and click on Enable 2FA.
  5. Notice that the SECRET_TOKEN remains static and does not changes.

It is observed that the 2FA secret code remains the same until the user actually enables the 2FActor Authentication.

Suggested Fix

It could be mitigated by generating a new 2FA Authenticator Secret Code each time the user tries to enable 2FA (regardless of whether the process was cancelled previously).

Impact

A hacker who gains access to victim's user credentials (through an another compromised website) can login to the victim's account and steal the 2FA secret code and use it for further exploits. At later point of time, even when victim enables the 2FA, the hacker would still have access to the victim's account, since the hacker already has the static 2Factor Secret Key.

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application generated the 2FA secret token only once per account and reused it for every subsequent 2FA setup attempt until 2FA was finally enabled.

Impact

An attacker who already knows the victim's password could log in, steal the static 2FA secret token, and later use it to access the account even after the victim enables 2FA.

What the attacker needed

Attacker knows victim's password; victim has not yet enabled 2FA

The fix

The 2FA secret token should be regenerated each time the user starts the 2FA setup process, regardless of whether a previous attempt was cancelled.

How it was found

  1. Log in to GitLab and go to Settings > Account > Two Factor Authentication, then click Enable 2FA.
  2. Note the secret token shown under the manual entry section for the 2FA barcode.
  3. Log out of GitLab and log in again.
  4. Go back to Settings > Account > Two Factor Authentication and click Enable 2FA.
  5. Observe that the secret token is the same as before and has not changed.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Two-factor authentication (2FA) adds a second step to logging in, usually a code from a phone app. The secret token is the shared key that the app uses to generate those codes. Here, the secret token did not change each time the user started setting up 2FA, so someone who saw it once could keep generating valid codes later.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.