Pre-generation & Static 2FA Authenticator Secret Code can cause risks to accounts
The 2FA authenticator secret key for an account remained static across logout and login sessions, even if the user never enabled 2FA. An attacker who had already obtained the victim's credentials could silently retrieve this secret and later use it to generate valid 2FA codes after the victim enabled 2FA.
GitLab
Originally disclosed on GitLab
- Fixed in 17 months
- Disclosed after 17 months
HackerOne report #511260 by rgupt on 2019-03-17, assigned to asaba:
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 application as well.
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.
An attack might play out like this:
- The attacker is able to abuse a password manager's behavior to obtain the victim's username/password at this point.
- The attacker logs into Gitlab & silently grabs the 2FA Authenticator Code without enabling the 2FA.
- Victim logs into their account and then tries to enable 2FA to prevent hacker from accessing the victim's account.
- However since attacker already has the 2FA secret code, and since the 2FA secret code remains static & does not change, the attacker can silently continue to access the victim's account credentials with the 2FA code the attacker possess.
Steps To Reproduce:
- Login to a Gitlab account which does not has 2FA enabled.
- Navigate to Settings -> Accounts Page and click on the button to enable 2FA.
- The Secret Key for the 2FA Authenticator Code will be displayed. Note this code.
- Logout of that session and login again and navigate to Settings -> Accounts Page.
- Again click on the button to enable 2FA and check if the same Secret Key for the 2FA Authenticator code is displayed.
In all the cases, the Secret Key for the 2FA Authenticator Code never changes and remains static.
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). This is how secure sites like HackerOne & Github performs.
Impact
As a result, if a hacker was able to access the victim's account credential, the hacker can silently get the 2FA Authenticator code without enabling the 2FA Authentication. Next time when victim enables the 2FA, Hacker would still have access to the 2FA Authenticator Code and can continue to login to victim's account.
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 and stored the 2FA secret key once per account and reused it for every subsequent 2FA setup attempt, instead of creating a fresh secret each time.
Impact
If an attacker already had the victim's credentials, they could silently obtain the static 2FA secret and continue to access the account even after the victim enabled 2FA.
What the attacker needed
Attacker already has victim's credentials; victim has not yet enabled 2FA; attacker can log in as victim
The fix
The 2FA secret should be regenerated each time the user attempts to enable 2FA, regardless of whether a previous attempt was cancelled.
How it was found
- Log in to a GitLab account that does not have 2FA enabled.
- Go to Settings -> Accounts and click the button to enable 2FA.
- Note the displayed secret key for the 2FA authenticator code.
- Log out and log in again, then return to Settings -> Accounts.
- Click to enable 2FA again and observe that the same secret key is shown.
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 an app. That app relies on a secret key shared with the website. If the website shows the same secret key every time you try to turn on 2FA, someone who already knows your password can copy that key in advance and later generate the same codes as you.
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.