Navigation Menu

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

Send email notifications to a user whenever their settings are changed (2FA, token_auth, user is updated or deleted), and to super users when security settings are changed (brute force logic, 2FA, cors changes) #17531

Merged
merged 13 commits into from May 26, 2021

Conversation

flamisz
Copy link
Contributor

@flamisz flamisz commented May 7, 2021

Description:

Send email notifications when critical action happened.

Critical actions:

  • making any kind of changes to the 2FA -> user
  • if a token auth was created or deleted -> user
  • changes to the brute force logic, two FA and CORS were made -> superusers
  • when users are created/deleted -> user

Review

  • Functional review done
  • Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@flamisz flamisz self-assigned this May 7, 2021
@flamisz flamisz added the Needs Review PRs that need a code review label May 10, 2021
@flamisz flamisz added this to the 4.3.0 milestone May 10, 2021
@flamisz flamisz marked this pull request as ready for review May 10, 2021 03:05
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Left some comments that came to my mind when looking at the code changes. Haven't done any local tests yet...

plugins/CoreAdminHome/lang/en.json Outdated Show resolved Hide resolved
plugins/TwoFactorAuth/Controller.php Show resolved Hide resolved
plugins/TwoFactorAuth/Controller.php Outdated Show resolved Hide resolved
plugins/UsersManager/API.php Show resolved Hide resolved
@Findus23
Copy link
Member

One thing: To anticipate an issue like #14447, I guess it would be useful to have an option to disable those E-Mails (even though I find it hard to know where to draw the line)

@tsteur
Copy link
Member

tsteur commented May 10, 2021

One thing: To anticipate an issue like #14447, I guess it would be useful to have an option to disable those E-Mails (even though I find it hard to know where to draw the line)

For MVP this might not be needed and we could wait until this comes up as a request and then someone could even develop a plugin for this etc.

@flamisz flamisz requested a review from sgiehl May 12, 2021 22:05
Copy link
Member

@diosmosis diosmosis left a comment

Choose a reason for hiding this comment

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

Tested locally, everything works. I left a couple code related comments, and a bunch more comments regarding the contents of the email (mostly making them more specific/informative).

plugins/CoreAdminHome/Emails/SecurityNotificationEmail.php Outdated Show resolved Hide resolved
plugins/CoreAdminHome/Emails/SettingsChangedEmail.php Outdated Show resolved Hide resolved
plugins/CoreAdminHome/lang/en.json Outdated Show resolved Hide resolved
plugins/CorePluginsAdmin/API.php Outdated Show resolved Hide resolved
plugins/CorePluginsAdmin/API.php Show resolved Hide resolved
plugins/UsersManager/API.php Show resolved Hide resolved
Copy link
Contributor Author

@flamisz flamisz left a comment

Choose a reason for hiding this comment

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

@diosmosis I updated my pr but added some questions as comments, can you please check those?
and still waiting for some comments from the other, I will modify those parts after the comment.
thanks

plugins/CoreAdminHome/Emails/SecurityNotificationEmail.php Outdated Show resolved Hide resolved
Comment on lines 42 to 46
if (count($this->superuserEmails)) {
foreach ($this->superuserEmails as $login => $email) {
return $email;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here it's possible we send the email to ourselves. should we find the first superuser email which is not us?
what if there is no other superuser? what is the recommendation in the email to the user?

Copy link
Member

Choose a reason for hiding this comment

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

ping @tsteur / @mattab

Copy link
Member

Choose a reason for hiding this comment

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

Not sure I understand, it should be sent to the user that enabled the two factor and nobody else?

Copy link
Member

Choose a reason for hiding this comment

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

Like you can't enable it for a different user AFAIK?

Copy link
Member

Choose a reason for hiding this comment

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

Oh i see now it's for who we mention to contact, I'll have a think

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep it simple and do same thing as for password change etc.
We could reuse the same translation key : UsersManager_IfThisWasYouPasswordChange. which says If this was you, feel free to ignore this email. If this was not you, please contact your Matomo administrator immediately, as your account might have been compromised! and this would maybe also make the other comments obsolete.

I wonder if we can document this for future reference somewhere but wouldn't really know where right now. It's really good to have this SecurityNotificationEmail base class now maybe this could provide such a method or constant or something to be reused across emails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reused that translation key. I'll think about that method or constant.

plugins/CoreAdminHome/lang/en.json Outdated Show resolved Hide resolved
plugins/CorePluginsAdmin/API.php Outdated Show resolved Hide resolved
@diosmosis
Copy link
Member

@tsteur can you look at the comments pinging you above? There are some questions I can't answer.

@mattab mattab modified the milestones: 4.3.0, 4.4.0 May 26, 2021
@diosmosis diosmosis merged commit 70b05de into 4.x-dev May 26, 2021
@diosmosis diosmosis deleted the new-email-notifications branch May 26, 2021 22:29
@mattab mattab added c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. labels Jul 27, 2021
@mattab mattab changed the title Email notifications for critical actions Send email notifications to a user whenever their settings are changed (2FA, token_auth, user is updated or deleted), and to super users when settings change (brute force logic, 2FA, cors changes) Jul 27, 2021
@mattab mattab changed the title Send email notifications to a user whenever their settings are changed (2FA, token_auth, user is updated or deleted), and to super users when settings change (brute force logic, 2FA, cors changes) Send email notifications to a user whenever their settings are changed (2FA, token_auth, user is updated or deleted), and to super users when security settings are changed (brute force logic, 2FA, cors changes) Jul 27, 2021
@bluikko
Copy link

bluikko commented Aug 8, 2021

I believe that this change breaks install via the ExtraTools. I really wish team Matomo would realize what the time is and #10257 got some attention.

@tsteur
Copy link
Member

tsteur commented Aug 8, 2021

@bluikko I've had a look through the PR and not sure where this could break ExtraTools. Have you created an issue for this problem on the ExtraTools issue tracker? It may be related to something else or maybe the plugin developer can work around it. Re #10257 we may put some focus on it in the near future but I can't promise anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants