Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix authentication failures after going halfway through a sign-in attempt #16607

Merged

Conversation

ClearlyClaire
Copy link
Contributor

@ClearlyClaire ClearlyClaire commented Aug 15, 2021

In some cases, attempting to sign in may result in an incorrect “Invalid E-Mail or password.” error.

This can occur when first entering the correct password for an account, but not resolving the 2FA or sign-in token challenge, then trying to log into another user that would require a 2FA or sign-in token challenge.

Indeed, upon the first successful password login, the attempt_user_id field of the (securely encrypted) session is set to the account being logged into. However, while this field is set, subsequent log-in attempts will ignore the provided email and look up the attempt_user_id instead, resulting in password comparison with the wrong account (which also means someone managing two accounts with the same password can mistakenly log into the wrong account, should they solve the correct challenge).

This PR fixes it by using the provided email first to find the appropriate account, then check whether the found account and attempt_user_id match. Thorough review is needed as this may have security implications (I'm fairly confident it does not, but my first attempt did not check that attempt_user_id, making it possible, although very improbable, to bypass password authentication).

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.
@ClearlyClaire ClearlyClaire changed the title Fix authentification failures after going halfway through a sign-in attempt Fix authentication failures after going halfway through a sign-in attempt Aug 15, 2021
@ClearlyClaire ClearlyClaire force-pushed the fixes/two-step-authentication-mixup branch from 913e845 to fc80220 Compare August 15, 2021 18:27
@ClearlyClaire ClearlyClaire marked this pull request as ready for review August 15, 2021 18:35
…_factor` to make the two authentication steps more obvious
@ClearlyClaire ClearlyClaire force-pushed the fixes/two-step-authentication-mixup branch from a0df0b6 to 8d838f7 Compare August 15, 2021 19:07
@Gargron Gargron merged commit 94bcf45 into mastodon:main Aug 25, 2021
Gargron pushed a commit that referenced this pull request Nov 5, 2021
…empt (#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
kadoshita pushed a commit to kadoshita/mastodon that referenced this pull request Nov 6, 2021
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
kadoshita pushed a commit to kadoshita/mastodon that referenced this pull request Nov 7, 2021
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
ClearlyClaire added a commit to ClearlyClaire/mastodon that referenced this pull request Jan 28, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
dependabot bot added a commit to akyoz/Plustodon that referenced this pull request Nov 12, 2022
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
ClearlyClaire added a commit to ClearlyClaire/mastodon that referenced this pull request Jul 6, 2023
…empt (mastodon#16607)

* Add tests

* Add security-related tests

My first (unpublished) attempt at fixing the issues introduced (extremely
hard-to-exploit) security vulnerabilities, addressing them in a test.

* Fix authentication failures after going halfway through a sign-in attempt

* Refactor `authenticate_with_sign_in_token` and `authenticate_with_two_factor` to make the two authentication steps more obvious
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants