| Description | BACKGROUND
I have a "mailbot" that processed emails that arrive in the INBOX and after processing, they are placed into a top-level folder called ‘Processed’. The email received has a particular subject line that contains a URL ending with "?Result=". Accessing the ‘Processed’ folder in SoGo shows no email, but the folder has messages when checked directly over IMAP.
VERSIONS
SOGo 5.12.13 (mailcow-dockerized), Dovecot 2.3.21.1 (d492236fa0)
SYMPTOM
Opening a mail folder in the web UI shows an empty list. |
|---|
| Steps To Reproduce | Can be done manually, but the below script does everything required.
doveadm mailbox create -u user@example.com -s SogoBulk
for i in $(seq 1 11); do
printf 'From: Sender a@example.com\nTo: b@example.com\nSubject: ABCDEFGHIKJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIKJKLMNOPQRSTUVWXYZab=\nDate: Mon, 16 Nov 2026 12:00:00 +0800\n\nbody\n' \
| doveadm save -u user@example.com -m SogoBulk
done
Open SogoBulk in the web UI: empty list. |
|---|
| Additional Information | LOGS
sogo-mailcow-1 | Nov 16 14:10:57 e5d89ff67e6b sogod[80:80] EXCEPTION: <NSException: 0x55c5ab7b5930> NAME:NSRangeException REASON:in subdataWithRange:, range { 94, 0 } extends beyond size (93) INFO:(null)
sogo-mailcow-1 | Nov 16 14:10:57 e5d89ff67e6b sogod [80]: x.x.x.x "POST /SOGo/so/user@example.com/Mail/0/folderSogoBulk/view HTTP/1.1" 501 0/45 0.084 - - 0 - 14
CAUSE
I believe the issue is the late bounds check on line 124 and lack of a bounds check on line 130 in the decodedHeader function in "SoObjects/Mailer/NSData+Mail.m"
The while loop finds the '=' at the end of the subject, has to perform the '?' check, which is an out-of-bounds read.
If that memory happens to contain a '?', it drops us into the if on line 130, which has no bounds check.
The code then attempts to read from beyond the string length.
122 // Find beginning of encoded text
123 i = 1;
124 while ((cData != '=' || (cData+1) != '?') && i < len)
125 {
126 cData++;
127 i++;
128 }
129
130 if (cData == '=' && (cData+1) == '?')
131 {
132 NSString *enc;
In theory any Subject line over 6 characters, ending with '=' should fail, but it depends on the next character being a '?' by coincidence.
That is why for my setup, a 93 byte Subject line was the cause, and it only happens with 11+ messages in the folder. |
|---|