the-djmaze / snappymail

Simple, modern & fast web-based email client
https://snappymail.eu
GNU Affero General Public License v3.0
994 stars 120 forks source link

Sometimes unable to login #1640

Closed realsimix closed 3 months ago

realsimix commented 3 months ago

Describe the bug It's quite strange that I can sometimes not login as mail user and sometimes it works.

To Reproduce Steps to reproduce the behavior:

  1. Enter username and password and login

Expected behavior User should be logged in.

Please complete the following information:

Debug/logging information I see these error in PHP log: [20-Jun-2024 12:11:46 UTC] PHP Warning: Undefined array key 0 in /usr/share/snappymail/2.36.3/app/libraries/MailSo/Imap/Traits/Status.php on line 122 [20-Jun-2024 12:11:46 UTC] PHP Warning: Undefined array key 9 in /usr/share/snappymail/2.36.3/app/libraries/MailSo/Imap/Traits/Status.php on line 165 [20-Jun-2024 13:10:50 UTC] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /usr/share/snappymail/2.36.3/app/libraries/MailSo/Imap/Traits/ResponseParser.php on line 199

Find attached a slightly shortened log file. I hope this is useful to find what is causing the issue. log-2024-06-20-info.txt

Thanks!

realsimix commented 3 months ago

Looking at the detailed log it seems that actually the IMAP login succeeds but the error happens while fetching the folder list.

the-djmaze commented 3 months ago

That is weird.

PHP[WARNING]: Undefined array key 0 /usr/share/snappymail/2.36.3/app/libraries/MailSo/Imap/Traits/Status.php [line:122, code:2]

That should return NULL But then:

SERVICE[WARNING]: base64_encode(): Argument #1 ($string) must be of type string, array given
#0 /usr/share/snappymail/2.36.3/app/libraries/MailSo/Imap/Traits/Status.php(122): base64_encode()

And php says it's an array. i wonder how that is possible at all.

For now i just made a workaround.

realsimix commented 3 months ago

I still have often issues logging in with a lot of this:

[23-Jun-2024 15:44:58 UTC] PHP Warning: Undefined array key 9 in /usr/share/snappymail/2.36.3/app/libraries/MailSo/Imap/Traits/Status.php on line 169

Is this another place with the same problem? Thanks!

realsimix commented 3 months ago

When it's not working I often see this error (but the server is not busy at all):

[24-Jun-2024 05:58:56 UTC] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /usr/share/snappymail/2.36.3/app/libraries/MailSo/Imap/Traits/ResponseParser.php on line 207

the-djmaze commented 3 months ago

FolderStatus and FolderList could potentially produce your issue. Yet, your log is missing those commands. Like:

> TAG3 LIST "" "*" RETURN (SUBSCRIBED SPECIAL-USE STATUS (MESSAGES UNSEEN UIDNEXT UIDVALIDITY HIGHESTMODSEQ SIZE))\r\n
< * LIST () "." virtual\r\n
< * NO Mailbox doesn't exist: virtual\r\n
< * LIST (\UnMarked) "." ToDo\r\n
< * STATUS ToDo (MESSAGES 1 UIDNEXT 2 UIDVALIDITY 1588756711 UNSEEN 0 HIGHESTMODSEQ 5 SIZE 2454)\r\n
realsimix commented 3 months ago

I didn't want to post the full log here, can I send it somehow by private message/email?

realsimix commented 3 months ago

With the new patch I get a number of messages like below:

[24-Jun-2024 12:29:58 UTC] INBOX.Ecommerce.Delta invalid MAILBOXID value

These messages are random, the folders work fine.

the-djmaze commented 3 months ago

Your response has:

* STATUS INBOX (... MAILBOXID ((ü×GrU) ...)\r\n

https://datatracker.ietf.org/doc/html/rfc8474#section-7

objectid = 1*255(ALPHA / DIGIT / "_" / "-") status-att-val =/ "MAILBOXID" SP "(" objectid ")"

It seems your cyrus-imapd is at fault and crashes the SnappyMail parser.

Go to Admin -> Domains -> Domain and disable the OBJECTID capability for your server.

the-djmaze commented 3 months ago

As a note: due to the bug in Cyrus the response is completely broken:

    [ResponseList] => Array
        (
            [0] => *
            [1] => STATUS
            [2] => INBOX
            [3] => Array
                (
                    [0] => MESSAGES
                    [1] => 109
                    [2] => UIDNEXT
                    [3] => 113
                    [4] => UIDVALIDITY
                    [5] => 1202996492
                    [6] => MAILBOXID
                    [7] => Array
                        (
                            [0] => Array
                                (
                                    [0] => ü×GrU
                                )

                            [1] => UNSEEN
                            [2] => 0
                            [3] => SIZE
                            [4] => 4944775
                            [5] => HIGHESTMODSEQ
                            [6] => 13
                        )

                )

        )

While it should have been:

    [ResponseList] => Array
        (
            [0] => *
            [1] => STATUS
            [2] => INBOX
            [3] => Array
                (
                    [0] => MESSAGES
                    [1] => 109
                    [2] => UIDNEXT
                    [3] => 113
                    [4] => UIDVALIDITY
                    [5] => 1202996492
                    [6] => MAILBOXID
                    [7] => Array
                        (
                            [0] => a-zA-Z0-9_
                        )

                    [8] => UNSEEN
                    [9] => 0
                    [10] => SIZE
                    [11] => 4944775
                    [12] => HIGHESTMODSEQ
                    [13] => 13
                )
realsimix commented 3 months ago

I don't have OBJECTID in the list there, is that correct?

the-djmaze commented 3 months ago

I don't have OBJECTID in the list there, is that correct?

Read https://github.com/the-djmaze/snappymail/wiki/IMAP-capabilities

realsimix commented 3 months ago

Thanks, got it and now the errors are gone.

So, this is a bug then in my version of cyrus-imapd? It's the version of RHEL9 and if I know exactly what is wrong maybe I can report the bug there.

the-djmaze commented 3 months ago

https://github.com/cyrusimap/cyrus-imapd/issues/4944

realsimix commented 3 months ago

Thanks a lot for reporting the bug to cyrusimap!

realsimix commented 3 months ago

Any chance you could make a release with this change?

Thanks!

the-djmaze commented 3 months ago

Done