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

Add detection of configuration based on SRV records (RFC6186) #4719

Closed
wants to merge 33 commits into from

Conversation

livmackintosh
Copy link
Contributor

@livmackintosh livmackintosh commented May 3, 2020

If "XML Discovery" yields no connection settings, query SRV records
on the domain portion of the email address. This will help increase
the likelihood of being able to set up accounts with only the email and
password.

  • Automated tests

NB: I attempted to merge the code that @daquexian had worked on but it
has drifted so far behind master that the amount of effort to merge that
in would be very large.

References:
#865
#2530

@livmackintosh
Copy link
Contributor Author

I'm going to contribute some automated tests and fix the issues mentioned over the weekend but I thought it would be nice to get it out into the open to get eyes on it.

@cketti
Copy link
Member

cketti commented May 3, 2020

Thanks for working on this 👍

Actually using this method to discover server settings comes with the same problems as mentioned here: #3879 (review)
Sadly, I didn't actually create an issue outlining a plan to tackle this. I'll try to do this today.

For now I think it would be best to limit this pull request to the ConnectionSettingsDiscovery implementation. I'll add some comments in a bit.

@livmackintosh
Copy link
Contributor Author

@cketti I won't reply individually to the comments as I'm generally in agreement with you with most of them, especially around "graceful failure".

Thanks for your comments :)

@livmackintosh
Copy link
Contributor Author

livmackintosh commented May 4, 2020

@cketti Would there be an issue in me using JUnit-QuickCheck to write property-based tests? I feel the number of variables to account for could easily become quite high. I feel like there are many outcomes that depend only on one or two variables. It would be useful to generate data in the test that might account for situations where the SRV records have weird data.

Hopefully that makes at least a little sense. I posted this just before going to sleep :)

@cketti
Copy link
Member

cketti commented May 4, 2020

@cketti Would there be an issue in me using JUnit-QuickCheck to write property-based tests?

Without concrete example I currently don't see how it could be useful. Just go for it and I'll have a look at the result?

@livmackintosh livmackintosh force-pushed the account-redux branch 2 times, most recently from bc9e978 to 113c045 Compare May 5, 2020 23:56
If "XML Discovery" yields no connection settings, query SRV records
on the domain portion of the email address. This will help increase
the likelihood of being able to set up accounts with only the email and
password.

This implementation prefers TLS incoming servers (IMAPs/POP3s) with the
lowest priority value. If neither can be found, it will fall back to
using IMAP/POP3 with STARTTLS security. It is then left to
finishAutoSetup() to handle testing of the connection.

Things this commit hasn't covered:

  * Domain validation ("the user should be alerted if the SRV target
      is not part of the email domain")

  * Setting SSL/TLS security for the outbound server (it assumes
      STARTTLS currently)

NB: I attempted to merge the code that @daquexian had worked on but it
has drifted so far behind master that the amount of effort to merge that
in would be very large.

References thunderbird#2530
Among a few minor style/convention changes, add an interface for the SRV
resolver and remove POP3/POP3S support.
Allow SrvServiceDiscovery to be initialized with arbitrary SrvResolution
interface implementation

Add test for null happy-path case (no SRV records)
Previous commit was missing the required dependencies. This commit fixes
that.
@livmackintosh livmackintosh marked this pull request as ready for review May 6, 2020 20:23
Copy link
Contributor Author

@livmackintosh livmackintosh left a comment

Choose a reason for hiding this comment

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

I feel like this is close to completion @cketti with the following caveats worth considering:

  • It is probably advisable for us to check if the email domain is the parent of any servers returned in SRV records and check with the user (in case of DNS hijacking). This does feel outside the scope of this PR though and something that would be implemented higher up the stack before validating the settings and we maybe should see how this fits into Automatic account setup / server settings autodiscovery #4721

  • How can we determine the security setting for the SMTP server? There is no differentiation like IMAP/IMAPS in RFC6186. Should we assume STARTTLS? Or possibly attempt SSL/TLS depending on port number?

NB: I'm not a self-identified Kotlin/Java/Android developer so I may have done things in a weird/non-standard way - please let me know if this is the case. 😄

@cketti
Copy link
Member

cketti commented May 6, 2020

How can we determine the security setting for the SMTP server? There is no differentiation like IMAP/IMAPS in RFC6186. Should we assume STARTTLS? Or possibly attempt SSL/TLS depending on port number?

_submissions._tcp was added by RFC 8314, section 5.1

@livmackintosh
Copy link
Contributor Author

_submissions._tcp was added by RFC 8314, section 5.1
Perfect! Thank you 👍

@livmackintosh livmackintosh requested a review from cketti May 7, 2020 11:18
Copy link
Member

@cketti cketti left a comment

Choose a reason for hiding this comment

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

Thanks 👍

As you mentioned, this does have security implications. When implementing the plan outlined in #4721 we'll have to distinguish between trusted server settings and those we can only use after checking with the user. That's one of the reasons I don't want to use this in AccountSetupBasics just yet.

@livmackintosh livmackintosh requested a review from cketti May 8, 2020 23:46
cketti added a commit that referenced this pull request May 9, 2020
Git history was manually cleaned up.
@cketti
Copy link
Member

cketti commented May 9, 2020

Thanks 👍 I manually cleaned up the Git history dfe2698 and merged the changes just now.

@cketti cketti closed this May 9, 2020
@livmackintosh livmackintosh deleted the account-redux branch May 10, 2020 01:43
@cketti
Copy link
Member

cketti commented May 11, 2020

@livmackintosh: Do you want to continue working on this? Unfortunately, the plan outlined in #4721 is quite a lot of work. But if I know someone is willing to work on it, I'd be happy to break it down into more manageable tasks.

@livmackintosh
Copy link
Contributor Author

livmackintosh commented May 12, 2020

@cketti Most definitely; I would love to see this over the line - it's crucial to getting K9 up to 2020+ standards. I can probably work with #4721 but equally, if you wish to break it down that's cool too.

@cketti
Copy link
Member

cketti commented May 12, 2020

Awesome. I created issue #4759 with a description of what I think is a reasonable next step.

@monperrus
Copy link

Really cool! Do we check the validity of the SRV record with DNSSEC?

@cketti
Copy link
Member

cketti commented Jun 4, 2020

@monperrus: Not yet, but the code isn't used yet. The plan is to trust host names under the email domain and records signed via DNSSEC.

@livmackintosh
Copy link
Contributor Author

Might pick up on some of this this evening, just been crazy busy lately 😄

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

3 participants