Pre-generation of 2FA secret/backup codes seems like an unnecessary risk
The two-factor authentication setup page pre-generates and embeds the 2FA secret and backup codes in the page's HTML before the user has confirmed enabling 2FA. An attacker who already has script execution in the victim's session could read these values from the page and later use them to bypass 2FA if the victim enables it.
- Triaged in 19 hours
- Fixed in 8 days
- Paid in 13 days
- Disclosed after 13 days
If you manage to get a malicious script running in HackerOne, requesting https://hackerone.com/settings/authentication/edit and parsing out the two factor authentication form will yield either…
- the 2FA secret key and backup codes that will be used if 2FA is enabled for the first time this session
- the backup codes that will be used if 2FA is already being used and the codes are regenerated during this session
While activating 2FA or confirming backup codes regeneration requires knowledge of the user's password/TOTP code, reading the values out from the DOM does not (again, provided that you've compromised the user's session and are running script in their domain)
A theoretical attack might play out like this:
- A victim clicks a link or something in HackerOne which triggers XSS (which seems unlikely, but …)
- The XSS makes a request to
https://hackerone.com/settings/authentication/editto obtain the victim's potential 2FA secret and backup codes. Possibly the attacker is able to abuse a password manager's behavior to obtain the victim's username/password at this point. - Because of the strange behavior that occurred when they clicked the link, the victim possibly closes and re-opens the window (in an attempt to stop whatever the script is doing) and then enables 2FA on their account
- The attacker would now know the 2FA secret and backup codes that are currently being used for the victim's account
While achieving this attack seems rather unlikely, it seems that it could be mitigated by not generating the 2FA values until the user is trying to enable 2FA or generate their codes and has provided their password (and then generating new codes each time, regardless of whether the process was cancelled previously)
(Also, I was somewhat surprised to see that the https://hackerone.com/settings/authentication/edit form contained a 2FA secret/backup codes for users that aren't allowed to set up two factor authentication.)
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 generates and renders the 2FA secret and backup codes on page load rather than only after the user has confirmed enabling 2FA with their password or TOTP code.
Impact
If an attacker can run script in the victim's session, they could obtain the 2FA secret and backup codes and later bypass the victim's two-factor authentication, though the report notes this attack seems rather unlikely.
What the attacker needed
Script execution in victim's session; victim later enables 2FA
The fix
The 2FA secret and backup codes should not be generated until the user actually tries to enable 2FA or regenerate codes and has provided their password, with new codes generated each time.
How it was found
- Get a malicious script running in the victim's HackerOne session (for example through an XSS flaw).
- The script requests the authentication settings page and parses the two-factor authentication form.
- The script reads the pre-generated 2FA secret and backup codes from the page.
- The victim later enables 2FA, and the attacker now knows the secret and backup codes in use.
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. The secret key that generates those codes, and the backup codes for when the app is unavailable, should only be created when you actually turn 2FA on. Here, the website created them early and put them in the page, so anyone who could run their own script in your logged-in session could read them and later pretend to be you.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.