nextcloud / nextcloud/mail

Background (sync) jobs executed with missing oauth access token

Open
#9,051 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop bug feature:integration
Dominant language
JavaScript
Stars
1k
Forks
348
Avg merge
12h 28m
Merged PRs (30d)
91

Description

⚠️ This issue respects the following points: ⚠️
Bug description

I'm currently running a nextcloud server on v27.1.2~ynh3 and i'm getting an error whenever i attempt to login into a school/work outlook email account. From what i've seen it has something to do with after logging on with Microsofts 2FA it forgets or doesn't pass on the var $authenticatedCiphertext correctly. Also this might have nothing to do with it, whenever Microsofts popup shows up about the 2FA it goes into a completly different window so maybe it has something to do with that however it didn't seem likely but worth to mention.

I haven't found a workaround for this, is this issue known and can it be fixed?

Steps to reproduce
  1. Create a outlook school/work account and enable 2FA on it
  2. attempt to login to the account with nextcloud's mail
Expected behavior

No issues thrown and able to login to the account

Installation method

Community Web installer on a VPS or web space

Nextcloud Server version

27

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MySQL

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "ikhebgeenwebsite.nl"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "config_is_read_only": true,
        "version": "27.1.2.1",
        "overwrite.cli.url": "https:\/\/ikhebgeenwebsite.nl",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "updatechecker": false,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "integrity.check.disabled": true,
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": "6379",
            "timeout": "0.0",
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "hashing_default_password": true,
        "localstorage.allowsymlinks": true,
        "simpleSignUpLink.shown": false,
        "logout_url": "https:\/\/ikhebgeenwebsite.nl\/yunohost\/sso\/?action=logout"
    }
}
List of activated Apps
Enabled:
  - activity: 2.19.0
  - circles: 27.0.1
  - cloud_federation_api: 1.10.0
  - comments: 1.17.0
  - contactsinteraction: 1.8.0
  - dashboard: 7.7.0
  - dav: 1.27.0
  - federatedfilesharing: 1.17.0
  - federation: 1.17.0
  - files: 1.22.0
  - files_external: 1.19.0
  - files_pdfviewer: 2.8.0
  - files_reminders: 1.0.0
  - files_rightclick: 1.6.0
  - files_sharing: 1.19.0
  - files_trashbin: 1.17.0
  - files_versions: 1.20.0
  - firstrunwizard: 2.16.0
  - logreader: 2.12.0
  - lookup_server_connector: 1.15.0
  - mail: 3.4.4
  - nextcloud_announcements: 1.16.0
  - notifications: 2.15.0
  - oauth2: 1.15.1
  - password_policy: 1.17.0
  - photos: 2.3.0
  - privacy: 1.11.0
  - provisioning_api: 1.17.0
  - recommendations: 1.6.0
  - related_resources: 1.2.0
  - richdocuments: 8.2.2
  - serverinfo: 1.17.0
  - settings: 1.9.0
  - sharebymail: 1.17.0
  - support: 1.10.0
  - survey_client: 1.15.0
  - systemtags: 1.17.0
  - text: 3.8.0
  - theming: 2.2.0
  - twofactor_backupcodes: 1.16.0
  - user_ldap: 1.17.0
  - user_status: 1.7.0
  - viewer: 2.1.0
  - weather_status: 1.7.0
  - workflowengine: 2.9.0
Disabled:
  - admin_audit: 1.17.0
  - bruteforcesettings: 2.7.0
  - encryption: 2.15.0
  - suspicious_login: 5.0.0
  - twofactor_totp: 9.0.0
  - updatenotification: 1.17.0 (installed 1.17.0)
Nextcloud Signing status
disabled.
Nextcloud Logs
{"reqId":"OvQ17EdpCp51JxUttq99","level":3,"time":"2023-11-03T14:15:02+00:00","remoteAddr":"","user":"--","app":"mail","method":"","url":"--","message":"Cron mail sync failed for account 33","userAgent":"--","version":"27.1.2.1","exception":{"Exception":"TypeError","Message":"OC\\Security\\Crypto::decrypt(): Argument nextcloud/server#1 ($authenticatedCiphertext) must be of type string, null given, called in /var/www/nextcloud/apps/mail/lib/IMAP/IMAPClientFactory.php on line 107","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/lib/IMAP/IMAPClientFactory.php","line":107,"function":"decrypt","class":"OC\\Security\\Crypto","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/mail/lib/IMAP/MailboxSync.php","line":103,"function":"getClient","class":"OCA\\Mail\\IMAP\\IMAPClientFactory","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/SyncJob.php","line":110,"function":"sync","class":"OCA\\Mail\\IMAP\\MailboxSync","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":81,"function":"run","class":"OCA\\Mail\\BackgroundJob\\SyncJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":103,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":93,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/lib/private/Security/Crypto.php","Line":124,"message":"Cron mail sync failed for account {accountId}","exception":[],"CustomMessage":"Cron mail sync failed for account 33"},"id":"65481ed960e0e"}
Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with apps/mail/lib/IMAP/IMAPClientFactory.php at line 107, then trace the calls from MailboxSync.php and BackgroundJob/SyncJob.php shown in the log. Reproduce an Outlook school/work login with 2FA and a subsequent cron sync, checking how the authenticated token reaches Crypto::decrypt(). Done means the background sync no longer fails with a null token and the mailbox synchronizes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.