Skip to content

Net::IMAP connection uses insecure deprecated options #1586

Open
@nevans

Description

@nevans

The parameters that are used to create the Net::IMAP connection in Mail::IMAP are undocumented:

imap = Net::IMAP.new(settings[:address], settings[:port], settings[:enable_ssl], nil, false)

I believe the documentation was removed in 2007 (ruby/net-imap@e631911e). Pending the following PR: ruby/net-imap#175, the next release of net-imap will print a deprecation warning when those parameters are used. About a year later, they'll be removed entirely.

A bigger issue is that the fifth and final argument is false: that is the verify parameter and by setting it to false, the SSLContext will have verify_mode: OpenSSL::SSL::VERIFY_NONE.

Proposal

When Hash.try_convert(enable_ssl) returns a Hash, that will be used with

  Net::IMAP.new(settings[:address],
                port: settings[:port],
                ssl: Hash.try_convert(settings[:enable_ssl]))

When Hash.try_convert(enable_starttls) returns a Hash, that will be used with

  imap.starttls Hash.try_convert(settings[:enable_starttls])

In this way, any SSLContext attribute can be set.

When enable_ssl or enable_starttls are truthy but not hash-like, use {}. This way, the default is secure.

I can write a PR for this, if you agree with my proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions