The vulnerability exists in the models.UseRecoveryCode function, which was introduced in commit a617d52374e937db0edacfba2a26bdd14a05538e. This function is responsible for validating a 2FA recovery code during login. The flaw lies in its database query, which searches for an unused recovery code matching the one provided, but fails to check if that code belongs to the user attempting to authenticate. The userID is passed as an argument but is ignored. This allows an attacker, who has the victim's credentials, to enter a valid, unused recovery code from their own account to bypass the victim's 2FA and gain full access. The exploit is triggered through the user.LoginTwoFactorRecoveryCodePost route handler, which calls the vulnerable UseRecoveryCode function. The patch, in commit d568e048315dc9729c8518d8085cab7dbbfac80f, rectifies this by adding the user_id to the database query, ensuring the recovery code is scoped to the correct user.