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

Prevent notification MFA fatigue attacks #316

Merged
merged 7 commits into from
Dec 19, 2024
Merged

Conversation

johanib
Copy link
Contributor

@johanib johanib commented Dec 2, 2024

Prior to this change, if a bad actor could obtain the login credentials
of a user, and the user has push notifications enabled, the bad actor
could trigger a flood of push notifications in the hope the user would
push one.

This change makes it so a push notification will never be sent if the
user did not complete a QR authentication in the browser.

If a QR is scanned, the most recently used notification address is
stored in a secure cookie.
If that address is still the same when a user logs back in, a push
notification will be sent allowing the user to perform MFA.

@johanib johanib force-pushed the feature/prevent-mfa-fatigue branch 6 times, most recently from c5dcfde to 96153f5 Compare December 11, 2024 08:11
@johanib johanib linked an issue Dec 11, 2024 that may be closed by this pull request
@johanib johanib force-pushed the feature/prevent-mfa-fatigue branch from 96153f5 to 0fcf042 Compare December 11, 2024 08:39
@johanib johanib changed the title WIP Prevent MFA fatigue Prevent notification MFA fatigue attacks Dec 11, 2024
@johanib johanib marked this pull request as ready for review December 11, 2024 08:42
src/Features/authentication.feature Show resolved Hide resolved
src/Features/authentication.feature Show resolved Hide resolved
TiqrUserInterface $user,
Response $responseObject
): void {
// @TODO Valideren bij Pieter / Michiel of deze fallback er wel in moet
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wat ik denk dat er gebeurd:
Als iemand inlogt met QR, wordt er geen notification address meegestuurd. Dus die wordt niet overschreven in storage.

In dat geval, slaan we in de cookie het eerder opgeslagen address op, indien beschikbaar.

Als het notificationaddress wel wordt meegestuurd, is het een notificatie authenticatie?
In dat geval, gebruiken we het nieuwe address, wat we meekrijgen.

Onduidelijk voor mij: Als je een qr scant, stuurt de app dan een notificatie address mee? Dat zou verder niet uit moeten maken voor de werking hier.

Copy link
Member

@pmeulen pmeulen Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether a notificationAdress is sent depends on the Tiqr client. A client may not send a notification address, for instance because it could not get one from the Apple/Google notification service. For an authentication, the notification address is send by the tiqr client as part of the OCRA response. It does not matter how the Tiqr authentication was started - using a QR code, or using a push notification - both the QR code and the push notification and contain the same Tiqr authentication URI.

It does not make sense to set the the cookie when no notification address is present IMO, because that means that the client probably can't receive a push notification. We should update the notificationaddress after each successful authentication. This might mean that a user that is using multiple browser and intermittently send a notification address has to scan a QR more than once. That's a corner case.

We must read the actual notification address we're going to use to send the push notification from the database, not use the address from the cookie as that address could be stale.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed: The tiqr app always sends an notificationAddress, so only use the one we receive.

TODO: Remove fallback to storage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️ This has been solved: Removed the fallback.
If the Tiqr app does not send the notificationAddress, a cookie is not set.

*/
public function weHaveATrustedCookie(string $notificationAddress): void
{
$userId = $this->metadata->identity->identifier;
Copy link
Contributor Author

@johanib johanib Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the userId the same the next time a user logs in? Or is it randomized for every authentication attempt? In which case, it should be removed from the cookie.

Edit: Tiqr stores this userId (Token ID) on registration. So it should match.
Still, discuss, this is a deviation from the spec.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tiqr userid is what is unique for the tiqr token. It will be the same for each authentication with the token.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed: Is preferential to use a fixed cookie name. The notificationaddress is in the payload.

Copy link
Contributor Author

@johanib johanib Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'tiqr-trusted-device-cookie'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️ This has been solved: Uses configurable static cookie name.

@johanib
Copy link
Contributor Author

johanib commented Dec 12, 2024

Should the docs/personal-data.md document be updated?

Prior to this change, if a bad actor could obtain the login credentials
of a user, and the user has push notifications enabled, the bad actor
could trigger a flood of push notifications in the hope the user would
push one.

This change makes it so a push notification will never be sent if the
user did not complete a QR authentication in the browser.

If a QR is scanned, the most recently used notification address is
stored in a secure cookie.
If that address is still the same when a user logs back in, a push
notification will be sent allowing the user to perform MFA.

Resolves #290
@johanib johanib force-pushed the feature/prevent-mfa-fatigue branch from 0fcf042 to 8b84379 Compare December 12, 2024 09:39
@johanib johanib requested a review from MKodde December 16, 2024 08:53
Copy link
Member

@MKodde MKodde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this a very hard PR to review. Too many things going on here. I think we should peer review this to put the missing pieces in place.

@johanib johanib force-pushed the feature/prevent-mfa-fatigue branch from e044ca8 to fa13e94 Compare December 18, 2024 10:40
@johanib johanib requested a review from MKodde December 18, 2024 10:43
@johanib johanib force-pushed the feature/prevent-mfa-fatigue branch from 1b67ff6 to baa29b0 Compare December 19, 2024 10:14
@johanib johanib force-pushed the feature/prevent-mfa-fatigue branch from baa29b0 to b14d3fb Compare December 19, 2024 10:18
@johanib johanib requested a review from pmeulen December 19, 2024 10:28
@johanib johanib force-pushed the feature/prevent-mfa-fatigue branch from b14d3fb to 00b18af Compare December 19, 2024 10:34
@pmeulen pmeulen merged commit d688525 into main Dec 19, 2024
2 checks passed
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.

Require Tiqr QR scan 1st time (Prevent MFA fatigue)
3 participants