Breaking 2fa In Wordpress Account Takeover Via Csrf In Google Authenticator
The Google Authenticator plugin for WordPress saved a new two-factor secret without checking a nonce or referer, so a request forged from another site could replace an administrator's 2FA secret. An attacker who tricks a logged-in admin into submitting their own secret and a valid code can then take over the account and lock the real owner out.
Published on infosecwriteups.com
In the WordPress ecosystem, security plugins are the first line of defense. However, when they fail, the impact can be critical.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The save handler for the 2FA setup page updated the user's secret and enabled flag without any nonce or referer check, so any cross-site POST was trusted.
Impact
The attacker gains full access to the administrator account, keeps persistence, bypasses 2FA entirely and locks the legitimate administrator out.
What the attacker needed
Victim is a logged-in administrator; victim is tricked into visiting a phishing site; victim enters the attacker's secret and a code
The fix
The handler should verify a nonce and the admin referer before saving the secret, as the text says the developer omitted those checks.
How it was found
- The attacker generates a valid secret and adds it to their own authenticator app.
- The attacker sets up a phishing site and sends the admin an email about a critical 2FA update.
- The victim adds the attacker's secret to their app and generates a valid one-time code.
- The victim enters the secret and code into the malicious website.
- The browser sends a POST request without a nonce and WordPress accepts it, replacing the secret.
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 write-up has not been written yet. The Original tab links to the source.
Two-factor authentication (2FA) is a second code, usually from a phone app, needed on top of a password. This plugin let a page on another website quietly submit a form to the WordPress site, and because the site did not check that the request really came from its own pages, it accepted the change. The attacker swaps the admin's secret code for their own, so only the attacker's app can generate the right codes afterwards.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.