U2F would prevent this from being exploitable, but one-time password schemes like TOTP would not.
U2F basically[0] signs the current URI and HTTPS key and sends it back. If there is a man-in-middle then the signatures will not match and the auth will fail.
[0]: https://developers.yubico.com/U2F/Protocol_details/Overview....