Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
schleuder
schleuder
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 97
    • Issues 97
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • schleuder
  • schleuderschleuder
  • Issues
  • #483

Closed
Open
Opened Jan 18, 2021 by ng@n_gOwner

Properly validate email addresses

Our regexp is rather ehm basic:

https://0xacab.org/schleuder/schleuder/-/blob/26e8dc880fde033fa9a37e0cacc05fb0e56baa3c/lib/schleuder/conf.rb#L7

This can lead to issues, when for example subscriptions with invalid email addresses are registered, that are later then re-formatted by the mail-gem.

An example of that has been reported as the basis for #482 and went the following way:

  • Subscription with email ' my@email.com'
  • Key was assigned to subscription

When delivery happends, the following is happening:

gpg_options for mail-gpg gets the following hash (https://0xacab.org/schleuder/schleuder/-/blob/26e8dc880fde033fa9a37e0cacc05fb0e56baa3c/lib/schleuder/subscription.rb#L61):

{'encrypt' => true, 'keys' => { ' my@email.com' => '0x.....' } }

receivers is set to mail.to https://github.com/jkraemer/mail-gpg/blob/481d4096c67bac6a4248604dba0d43753f5b2404/lib/mail/gpg.rb#L34 (+ Line 46) which is: 'my@email.com':

Mail.new(to: ' my@email.com').to
=> ["my@email.com"]

This is then used to look up the keys for the emails @ https://github.com/jkraemer/mail-gpg/blob/481d4096c67bac6a4248604dba0d43753f5b2404/lib/mail/gpg/gpgme_helper.rb#L14

email_or_shas in this function: https://github.com/jkraemer/mail-gpg/blob/481d4096c67bac6a4248604dba0d43753f5b2404/lib/mail/gpg/gpgme_helper.rb#L121-L154

are the previously recipients, parsed and formatted by Mail. But we then try to find a keyid in the key_data (that is the previously generated keys hash): https://github.com/jkraemer/mail-gpg/blob/481d4096c67bac6a4248604dba0d43753f5b2404/lib/mail/gpg/gpgme_helper.rb#L127-L128

Which obviously fails since, the key for the fingerprint is ' my@email.com', but the recipient is 'my@email.com'

  1. We should improve checking the validity of an emailaddress
  2. We might likely want to format (besides downcasing) all the emails for subscriptions how mail will treat them. Like this, we will ensure, they will also be found when used by mail-gpg. E.g. Mail::Address.new(' my@email').address
Assignee
Assign to
3.6.0
Milestone
3.6.0
Assign milestone
Time tracking
None
Due date
None
Reference: schleuder/schleuder#483