Review main Merged

87391[FEATURE] Notify backend user on failed MFA verification attempts

Torben Hansen CR +2 V +2 Normal +156 −0 updated 12/16/24, 10:41

Commit message

In terms of security, it is best practice to notify the user on
failed MFA verification attempts. TYPO3 currently only logs failed
MFA verification attempts to the sys_log, resulting in the users
not being informed about the failed MFA verification attempt.

This change adds a notification mechanism to inform TYPO3 backend
users via email when an MFA provider is configured and an
incorrect MFA verification code is entered during login. The
notification is only sent if the backend user has a valid email
address configured.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 5

Review log 4963

Show 2938 earlier messages
  1. Torben Hansen uploaded patch set 1 12/06/24, 17:41

  2. core-ci voted on patch set 1 V +1 12/06/24, 17:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70719

  3. Simon Schaufelberger commented on patch set 1 12/07/24, 00:32

    MfaController.php:66

    why private?
  4. Torben Hansen uploaded patch set 2 V +1 12/07/24, 04:44

  5. Torben Hansen commented on patch set 2 12/07/24, 04:45

    MfaController.php:66 Reply

    Good spot. I changed it to protected.
  6. core-ci voted on patch set 2 V +1 12/07/24, 04:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70735

  7. Simon Schaufelberger uploaded patch set 3 V +1 12/07/24, 13:37

  8. Simon Schaufelberger uploaded patch set 4 12/07/24, 13:39

  9. core-ci voted on patch set 3 V +1 12/07/24, 13:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70743

  10. core-ci voted on patch set 4 V +1 12/07/24, 13:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70744

  11. Oliver Hader voted on patch set 4 CR +1 12/09/24, 11:45

  12. Simon Schaufelberger voted on patch set 4 CR +1 V +1 12/10/24, 09:16

  13. Garvin Hicking commented on patch set 4 CR +1 V +1 12/10/24, 09:59

    Very nice!
  14. Andreas Kienast commented on patch set 4 V +1 12/10/24, 10:31

    FailedMfaNotification.html:24

    I wonder whether it makes sense to add the server timezone as the user may have a different one.
  15. Torben Hansen uploaded patch set 5 CR +1 V +1 12/10/24, 18:08

  16. Torben Hansen commented on patch set 4 12/10/24, 18:08

    FailedMfaNotification.html:24 Reply

    Yes, that is a good idea. I added the shorthand timezone after the date.
  17. core-ci voted on patch set 5 V +1 12/10/24, 18:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70872

  18. Torben Hansen uploaded patch set 6 V +1 12/10/24, 18:25

  19. Simon Schaufelberger voted on patch set 6 CR +1 V +1 12/10/24, 18:29

  20. core-ci voted on patch set 6 V +1 12/10/24, 18:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70875

  21. Garvin Hicking voted on patch set 6 CR +1 V +1 12/10/24, 18:32

  22. Andreas Kienast voted on patch set 6 CR +1 V +1 12/11/24, 07:34

  23. Oli Bartsch commented on patch set 6 CR -1 12/12/24, 07:29

    MfaController.php:138

    Instead of directly sending mails here, could we use the `MfaVerificationFailedEvent`?

    MfaController.php:250

    This does not belong here and should be moved to a dedicated service.

    Feature-105783-NotifyBackendUserOnFailedMFAVerificationAttempt.rst:23

    We should then also notify users on failed login attempts in general, right?
  24. Garvin Hicking commented on patch set 6 CR 0 12/12/24, 07:42

    Feature-105783-NotifyBackendUserOnFailedMFAVerificationAttempt.rst:23 Reply

    A normal failed login attempt wouldn't mean that the password is compromised (which it would be in case of a mismatching MFA PIN), and where login rate limiting would apply. I'd argue this would create too much spam possibility; in that case the "positive login notification" would be more helpful for people who want to get notified (user setting "Notify me by email when somebody logs in from my account").
  25. Oli Bartsch commented on patch set 6 12/12/24, 08:01

    Feature-105783-NotifyBackendUserOnFailedMFAVerificationAttempt.rst:23 Reply

    > which it would be in case of a mismatching MFA PIN Why does this mean that the password has been compromised? I think it's the same as the password. A user might just enter the wrong one, e.g. because it's expired or just transposed digits. > "Notify me by email when somebody logs in from my account" So we might just implement this instead of the notify on MFA failed attempt?
  26. Torben Hansen commented on patch set 6 12/12/24, 08:03

    Feature-105783-NotifyBackendUserOnFailedMFAVerificationAttempt.rst:23 Reply

    It is common security practice to notify a user on failed MFA attempts. This option must not be opt-in (like the suggested "Notify me..." option, which a user always must enable manually). There is basically less to none spam possibility here, since the MFA provider will be locked after 3 failed attempts. A maximum of 3 notification emails to the user in case of compromised account credentials is more than valid in order to raise awareness, that account credentials did possible leak somewhere.
  27. Torben Hansen uploaded patch set 7 CR +1 V +1 12/12/24, 08:40

  28. Torben Hansen uploaded patch set 8 12/12/24, 08:42

  29. Torben Hansen commented on patch set 8 12/12/24, 08:43

    MfaController.php:138 Reply

    Done

    MfaController.php:250 Reply

    Done

    Feature-105783-NotifyBackendUserOnFailedMFAVerificationAttempt.rst:23 Reply

    In changed the wording in the RST, so it is more clear, that the feature is useful for backend user accounts with active MFA setup.
  30. core-ci voted on patch set 7 V -1 12/12/24, 08:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71012

  31. Torben Hansen uploaded patch set 9 12/12/24, 08:48

  32. core-ci voted on patch set 8 V -1 12/12/24, 08:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71013

  33. core-ci voted on patch set 9 V +1 12/12/24, 08:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71016

  34. Garvin Hicking commented on patch set 9 CR +1 V +1 12/12/24, 10:57

    Thanks for the rework!
  35. Simon Schaufelberger commented on patch set 9 12/12/24, 12:18

    MfaController.php:60

    please revert this useless change

    FailedMfaAttemptNotification.php:39

    defining the event here is not necessary, or?
  36. Simon Schaufelberger commented on patch set 9 12/12/24, 12:21

    FailedMfaAttemptNotification.php:39 Reply

    it's also not defined in InitializeCodeEditorInEditFileForm
  37. Torben Hansen uploaded patch set 10 CR +1 V +1 12/12/24, 13:02

  38. Torben Hansen commented on patch set 9 12/12/24, 13:03

    MfaController.php:60 Reply

    Done

    FailedMfaAttemptNotification.php:39 Reply

    Done.
  1. core-ci voted on patch set 10 V +1 12/12/24, 13:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71028

  2. Simon Schaufelberger voted on patch set 10 CR +1 V +1 12/12/24, 13:09

  3. Garvin Hicking voted on patch set 10 CR +1 V +1 12/12/24, 14:16

  4. Oli Bartsch commented on patch set 10 12/12/24, 15:59

    FailedMfaAttemptNotification.php:48

    We should prevent undefined array key access here.

    FailedMfaAttemptNotification.php:54

    Should we add the name here if available ('realName' or `username`).

    FailedMfaNotification.html:7

    Since this is dispatched for every kind of MFA, "verification code" might be misleading e.g. for passkey attempts.
  5. Torben Hansen uploaded patch set 11 CR +1 V +1 12/13/24, 06:51

  6. Torben Hansen commented on patch set 11 12/13/24, 06:52

    FailedMfaAttemptNotification.php:48 Reply

    Done

    FailedMfaAttemptNotification.php:54 Reply

    Done

    FailedMfaNotification.html:7 Reply

    I changed the term to `multi-factor authentication`
  7. core-ci voted on patch set 11 V +1 12/13/24, 06:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71056

  8. Garvin Hicking commented on patch set 12 V +1 12/13/24, 08:46

    Published edit on patch set 11.
  9. Garvin Hicking voted on patch set 12 CR +1 V +1 12/13/24, 08:48

  10. core-ci voted on patch set 12 V +1 12/13/24, 08:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71060

  11. Oli Bartsch uploaded patch set 13 CR +1 V +1 12/13/24, 09:07

  12. Oli Bartsch voted on patch set 13 CR +1 V +1 12/13/24, 09:07

  13. core-ci voted on patch set 13 V +1 12/13/24, 09:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71061

  14. Garvin Hicking voted on patch set 13 CR +1 V +1 12/13/24, 09:21

  15. Guido Schmechel voted on patch set 13 CR +1 V +1 12/13/24, 20:46

  16. Georg Ringer commented on patch set 13 12/15/24, 18:53

    FailedMfaAttemptNotification.php:48

    IMO ?? is not needed, this is a DB field and not a uc field, therefore it is always set, also below with email

    FailedMfaNotification.html:15

    IMO we should use Site name, it could be mixed with the hostname of server

    FailedMfaNotification.html:24

    can't we use 1 f:format:date?
  17. Garvin Hicking commented on patch set 13 12/15/24, 21:44

    FailedMfaNotification.html:24 Reply

    I thought the same, but the customized "ddmmyy" format is only used when no format is given. We do not (yet) have a way to append the time to the customized default date. Hence IMO we need to have two calls here for now to separate "base date" and time.
  18. Andreas Kienast commented on patch set 13 12/16/24, 07:21

    FailedMfaAttemptNotification.php:48 Reply

    It's not only about "not there", but also about having a fallback to a string value if the left-hand operand is NULL. I checked the database, both fields are not nullable by default, so it might be safe to remove null coalescing here.
  19. Torben Hansen uploaded patch set 14 CR +1 V +1 12/16/24, 08:08

  20. Torben Hansen commented on patch set 13 12/16/24, 08:09

    FailedMfaAttemptNotification.php:48 Reply

    Done

    FailedMfaNotification.html:15 Reply

    Done. I additionally added the hostname after the sitename.

    FailedMfaNotification.html:24 Reply

    Nothing we can change here currently.
  21. core-ci voted on patch set 14 V +1 12/16/24, 08:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71162

  22. Oli Bartsch voted on patch set 14 CR +1 V +1 12/16/24, 08:55

  23. Garvin Hicking voted on patch set 14 CR +1 V +1 12/16/24, 10:10

  24. Oli Bartsch voted on patch set 14 CR +2 V +2 12/16/24, 10:41

  25. Oli Bartsch merged patch set 15 12/16/24, 10:41