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

feat: disable mail dispatch for invalid recovery email #2585

Closed
wants to merge 2 commits into from
Closed

feat: disable mail dispatch for invalid recovery email #2585

wants to merge 2 commits into from

Conversation

mszekiel
Copy link
Contributor

@mszekiel mszekiel commented Jul 8, 2022

Added send property for courier.templates.recovery.invalid configuration field, suppressing email sending when recovery email does not exist.

Related issue(s)

#2345

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I am following the contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security. vulnerability,
    I confirm that I got green light (please contact [email protected]) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added or changed the documentation.

Further Comments

Included additional configuration field for invalid recovery. I've also considered extending directly email field by send property but it would affect all other flows using the same struct. Extended schema definition. Here I wasn't sure if $ref template can be extended, so just overwrote it. For getEmail cypress command now it's possible to omit check if email is existing.

@codecov
Copy link

codecov bot commented Jul 8, 2022

Codecov Report

Merging #2585 (9e5b402) into master (d8514b5) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 9e5b402 differs from pull request most recent head 901a7f9. Consider uploading reports for the commit 901a7f9 to get more accurate results

@@           Coverage Diff           @@
##           master    #2585   +/-   ##
=======================================
  Coverage   75.81%   75.82%           
=======================================
  Files         302      302           
  Lines       17784    17789    +5     
=======================================
+ Hits        13483    13488    +5     
  Misses       3270     3270           
  Partials     1031     1031           
Impacted Files Coverage Δ
driver/config/config.go 83.18% <100.00%> (+0.05%) ⬆️
selfservice/strategy/link/sender.go 72.16% <100.00%> (+0.88%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Sytten
Copy link

Sytten commented Jul 8, 2022

Also related to #1835, this is absolutely needed for anything serious in production.

@mszekiel mszekiel changed the title feat: diable mail dispatch for invalid recovery email feat: disable mail dispatch for invalid recovery email Jul 8, 2022
@mrtndwrd
Copy link

We use Kratos in a privacy-focused organization and we would also really like to disable the "invalid" emails. What is needed to move this PR forward?

@mszekiel mszekiel marked this pull request as ready for review October 12, 2022 14:07
Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Thank you! To get this shipped we will need a couple of changes:

  1. Make this work in the new code strategy.
  2. Configure this within the code and link strategy - or alternatively in recovery and verification.
  3. If this enabled, the user is mislead thinking that an email was sent but they had a typo and never receive one. Shouldn't we show an error that the email is not known?

@@ -66,6 +66,7 @@ const (
ViperKeyCourierSMTPClientKeyPath = "courier.smtp.client_key_path"
ViperKeyCourierTemplatesPath = "courier.template_override_path"
ViperKeyCourierTemplatesRecoveryInvalidEmail = "courier.templates.recovery.invalid.email"
ViperKeyCourierTemplatesRecoveryInvalidSend = "courier.templates.recovery.invalid.send"
Copy link
Member

Choose a reason for hiding this comment

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

I think this key should go in another object because here we are configuring the templates. Given that this affects recovery and the link and code strategy, it should probably be configured there?

For completeness it would also be good to be able to disable this for both recovery and verification.

@@ -67,6 +67,12 @@ func (s *Sender) SendRecoveryLink(ctx context.Context, r *http.Request, f *recov

address, err := s.r.IdentityPool().FindRecoveryAddressByValue(ctx, identity.RecoveryAddressTypeEmail, to)
if err != nil {
if !s.r.Config().CourierTemplatesRecoveryInvalidSend(ctx) {
Copy link
Member

Choose a reason for hiding this comment

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

Since this PR was opened, we also added a code strategy which is now the default and also needs this feature.

@ariep
Copy link

ariep commented Oct 26, 2022

Hi, interested party here as we use kratos.

3. If this enabled, the user is mislead thinking that an email was sent but they had a typo and never receive one. Shouldn't we show an error that the email is not known?

It should be possible to configure kratos in such a way that a user cannot see the difference between successful and unsuccessful sending. Having a difference, for example in the form of an error message, reveals information about the set of existing users.

We'll add a message to the reset-link form to warn the user that if they do not receive an email, they should check if they made an error when typing their address, or if they're maybe registered using a different email address.

@Sytten
Copy link

Sytten commented Jan 6, 2023

@mszekiel Do you intend in continuing the PR, still baffles me that this behaviour is the default.

@mszekiel
Copy link
Contributor Author

mszekiel commented Feb 6, 2023

Moved to #3075

@mszekiel mszekiel closed this Feb 6, 2023
aeneasr pushed a commit that referenced this pull request Feb 14, 2023
Added the ability to configure whether the system should notify unknown recipients, if some tries to recover their account or verify their address ("anti-account-enumeration measures").

BREAKING CHANGES: By default, Kratos no longer sends out these Emails. If you want to keep notifying unknown addresses (keep the current behavior), set `selfservice.flows.recovery.notify_unknown_recipients` to `true` for recovery, or `selfservice.flows.verification.notify_unknown_recipients` for verification flows.

Closes #2345 
Closes #2585
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.

5 participants