Skip to content

Malformed mail address causes notification mail loop #20294

Closed
nextcloud/activity
#448

Description

@bluikko

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. Add a user "A" with malformed e-mail, for example john.doe (missing @Domain).
  2. Add a share using another user "B" that allows user A with malformed mail address and normal users C, D, E. Causes users A, C, D, E to get activity notification.
  3. All users A, C, D, E keep getting activity notifications on every notification processing.

Expected behaviour

If user in LDAP has malformed "mail" attribute, the user should just be skipped and deleted from activity_mq table when sending activity notifications.

Or in other words:

  1. If activity notification mail sending fails for one user with SMTP permanent error, it should be skipped permanently.
  2. If activity notification mail sending to a group has error(s) on some user(s), only users with errors should be retried - not sending the same mail again to all those users, including those who already got the activity notification.

Actual behaviour

If user has malformed "mail" attribute in LDAP it causes an activity notification loop. Pending activity notification mails are not removed from activity_mq table for any user, causing every user keep getting the same activity notification on every processing.

User in LDAP had malformed "mail" attribute: it was missing @ character and domain. Example mail address:

john.doe

A share was added by another user to a company-wide group in LDAP so everyone in the company got an "activity notification" mail.

The malformed mail address caused even those mails that were already sent out to not be deleted from activity_mq table. Notifications were sent out again to all users. This repeats on every activity notification processing until activity_mq table is cleaned up manually.

It seems that the activity_mq table entries are not deleted at all if even one entry in a batch of activity notifications fail.

Server configuration

Operating system: EL7

Web server: Apache

Database: MySQL

PHP version: 7.3

Nextcloud version: 17.0.2

Updated from an older Nextcloud/ownCloud or fresh install: several updates from 15

Where did you install Nextcloud from: official

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
only default + ldap

Nextcloud configuration:

Config report
very much default

Are you using external storage, if yes which one: no

Are you using encryption: no

Are you using an external user-backend, if yes which one: ActiveDirectory

LDAP configuration (delete this part if not used)

LDAP config
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Configuration                 | s01                                                                                                                                                                                                                                      |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| hasMemberOfFilterSupport      | 1                                                                                                                                                                                                                                        |
| homeFolderNamingRule          |                                                                                                                                                                                                                                          |
| lastJpegPhotoLookup           | 0                                                                                                                                                                                                                                        |
| ldapAgentName                 | x|
| ldapAgentPassword             | ***                                                                                                                                                                                                                                      |
| ldapAttributesForGroupSearch  |                                                                                                                                                                                                                                          |
| ldapAttributesForUserSearch   |                                                                                                                                                                                                                                          |
| ldapBackupHost                | ldaps://x                                                                                                                                                                                                        |
| ldapBackupPort                | 626                                                                                                                                                                                                                                      |
| ldapBase                      | x                                                                                                                                                                                                              |
| ldapBaseGroups                | x                                                                                                                                                                                                              |
| ldapBaseUsers                 | x                                                                                                                                                                                                              |
| ldapCacheTTL                  | 600                                                                                                                                                                                                                                      |
| ldapConfigurationActive       | 1                                                                                                                                                                                                                                        |
| ldapDefaultPPolicyDN          |                                                                                                                                                                                                                                          |
| ldapDynamicGroupMemberURL     |                                                                                                                                                                                                                                          |
| ldapEmailAttribute            | mail                                                                                                                                                                                                                                     |
| ldapExperiencedAdmin          | 0                                                                                                                                                                                                                                        |
| ldapExpertUUIDGroupAttr       | cn                                                                                                                                                                                                                                       |
| ldapExpertUUIDUserAttr        | userPrincipalName                                                                                                                                                                                                                        |
| ldapExpertUsernameAttr        | userPrincipalName                                                                                                                                                                                                                        |
| ldapExtStorageHomeAttribute   |                                                                                                                                                                                                                                          |
| ldapGidNumber                 | gidNumber                                                                                                                                                                                                                                |
| ldapGroupDisplayName          | cn                                                                                                                                                                                                                                       |
| ldapGroupFilter               | (&(|(objectclass=group)))                                                                                                                                                                                                                |
| ldapGroupFilterGroups         |                                                                                                                                                                                                                                          |
| ldapGroupFilterMode           | 0                                                                                                                                                                                                                                        |
| ldapGroupFilterObjectclass    | group                                                                                                                                                                                                                                    |
| ldapGroupMemberAssocAttr      | member                                                                                                                                                                                                                                   |
| ldapHost                      | x                                                                                                                                                                                                        |
| ldapIgnoreNamingRules         |                                                                                                                                                                                                                                          |
| ldapLoginFilter               | (&(&(objectclass=person)(&(|(primaryGroupID=513)(memberof:1.2.840.113556.1.4.1941:=CN=x))(!(userAccountControl:1.2.840.113556.1.4.803:=2))(|(userPrincipalName=%uid)(sAMAccountName=%uid))))) |
| ldapLoginFilterAttributes     |                                                                                                                                                                                                                                          |
| ldapLoginFilterEmail          | 0                                                                                                                                                                                                                                        |
| ldapLoginFilterMode           | 1                                                                                                                                                                                                                                        |
| ldapLoginFilterUsername       | 1                                                                                                                                                                                                                                        |
| ldapNestedGroups              | 1                                                                                                                                                                                                                                        |
| ldapOverrideMainServer        |                                                                                                                                                                                                                                          |
| ldapPagingSize                | 500                                                                                                                                                                                                                                      |
| ldapPort                      | 636                                                                                                                                                                                                                                      |
| ldapQuotaAttribute            | roomNumber                                                                                                                                                                                                                               |
| ldapQuotaDefault              | 42949672960                                                                                                                                                                                                                              |
| ldapTLS                       | 0                                                                                                                                                                                                                                        |
| ldapUserAvatarRule            | default                                                                                                                                                                                                                                  |
| ldapUserDisplayName           | displayname                                                                                                                                                                                                                              |
| ldapUserDisplayName2          |                                                                                                                                                                                                                                          |
| ldapUserFilter                | (&(objectclass=person)(&(|(primaryGroupID=513)(memberof:1.2.840.113556.1.4.1941:=CN=x))(!(userAccountControl:1.2.840.113556.1.4.803:=2))))                                                    |
| ldapUserFilterGroups          |                                                                                                                                                                                                                                          |
| ldapUserFilterMode            | 1                                                                                                                                                                                                                                        |
| ldapUserFilterObjectclass     | person                                                                                                                                                                                                                                   |
| ldapUuidGroupAttribute        | auto                                                                                                                                                                                                                                     |
| ldapUuidUserAttribute         | auto                                                                                                                                                                                                                                     |
| turnOffCertCheck              | 0                                                                                                                                                                                                                                        |
| turnOnPasswordChange          | 0                                                                                                                                                                                                                                        |
| useMemberOfToDetectMembership | 1                                                                                                                                                                                                                                        |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Client configuration

Browser: irrelevant

Operating system: irrelevant

Logs

Web server error log

Web server error log
Insert your webserver log here

Nextcloud log (data/nextcloud.log)

Nextcloud log
{"reqId":"evVUI0YR8mu44QiDs2eI","level":3,"time":"2020-03-15T21:30:06+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":{"Exception":"TypeError","Message":"idn_to_ascii() expects parameter 1 to be string, null given","Code":0,"Trace":[{"file":"\/opt\/www\/nextcloud\/lib\/private\/Mail\/Message.php","line":78,"function":"idn_to_ascii","args":[null,0,1]},{"file":"\/opt\/www\/nextcloud\/lib\/private\/Mail\/Message.php","line":143,"function":"convertAddresses","class":"OC\\Mail\\Message","type":"->","args":[{"john.doe":"John Doe"}]},{"file":"\/opt\/www\/nextcloud\/apps\/activity\/lib\/MailQueueHandler.php","line":394,"function":"setTo","class":"OC\\Mail\\Message","type":"->","args":[{"john.doe":"John Doe"}]},{"file":"\/opt\/www\/nextcloud\/apps\/activity\/lib\/MailQueueHandler.php","line":163,"function":"sendEmailToUser","class":"OCA\\Activity\\MailQueueHandler","type":"->","args":["john.doe@domain.corp","john.doe","en","Asia\/Bangkok",1584307801]},{"file":"\/opt\/www\/nextcloud\/apps\/activity\/lib\/BackgroundJob\/EmailNotification.php","line":65,"function":"sendEmails","class":"OCA\\Activity\\MailQueueHandler","type":"->","args":[500,1584307801]},{"file":"\/opt\/www\/nextcloud\/lib\/private\/BackgroundJob\/Job.php","line":61,"function":"run","class":"OCA\\Activity\\BackgroundJob\\EmailNotification","type":"->","args":[null]},{"file":"\/opt\/www\/nextcloud\/lib\/private\/BackgroundJob\/TimedJob.php","line":55,"function":"execute","class":"OC\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]},{"file":"\/opt\/www\/nextcloud\/cron.php","line":124,"function":"execute","class":"OC\\BackgroundJob\\TimedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]}],"File":"\/opt\/www\/nextcloud\/lib\/private\/Mail\/Message.php","Line":78,"CustomMessage":"--"},"userAgent":"--","version":"17.0.2.1"}

Browser log

Browser log
irrelevant

Activity

  1. added
    0. Needs triage
    on Apr 3, 2020
  2. kesselb commented on Apr 4, 2020

    @kesselb
    Contributor

    cc @nextcloud/server-triage

  3. nickvergessen commented on Apr 4, 2020

    @nickvergessen
    Member

    Well fix your ldap and it works again. Or remove the broken email entry for that user from oc_preferences

  4. bluikko commented on Apr 4, 2020

    @bluikko
    Author

    @nickvergessen That has been done of course.

  5. reopened this on Apr 4, 2020
  6. nickvergessen commented on Apr 4, 2020

    @nickvergessen
    Member

    So oc_prefernces is fixed? Then the emails should be sent on next cron

  7. bluikko commented on Apr 4, 2020

    @bluikko
    Author

    I fixed address in LDAP and cleared activity_mq. The problem is not that notification mails were not sent, the problem is that they were repeatedly sent to everyone except the malformed mail address user!

  8. kesselb commented on Apr 4, 2020

    @kesselb
    Contributor

    Thanks @bluikko for reporting 👍

    I recall some reports here on GitHub describing that behaviour (for example #15600). Your observation that a malformed email address is responsible is correct. Fix at nextcloud/activity#448.

  9. bluikko commented on Apr 5, 2020

    @bluikko
    Author

    #15600 is missing any logs so cannot say if it is the same problem but the symptoms sound exactly the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagebugfeature: activity and notification

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions