Bug 451025

Summary: crash in mailimf_group_parse due to a colon in To: address
Product: [Fedora] Fedora Reporter: Vinay Y S <vinay>
Component: libetpanAssignee: Andreas Bierfert <andreas.bierfert>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: low    
Version: 8CC: thoger
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 0.54-1.fc9 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-06-26 08:31:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
The test message that causes the crash in mime parser.
none
A simple test code that reproduces the crash.
none
A patch that fixes the crash none

Description Vinay Y S 2008-06-12 14:03:52 UTC
Description of problem:
If the email's To: header has a colon after display name, etpan crashes in
library's src/low-level/imf/mailimf.c line 3049 

 free_mailbox_list:
  mailimf_mailbox_list_free(mailbox_list);

For example:
A mail having
To: Michael:
will cause the mailbox_list to be null and upon reaching this list free
function, it will segfault and crash.

Version-Release number of selected component (if applicable):
libetpan-0.52-1

How reproducible:
Steps to Reproduce:
1. Please take a standard e-mail and insert a : in front of the displayname in
the To e-mail address. (This happens due to bad e-mail server sending such e-mails).
2. Parse that e-mail with etpan. 
3. Notice the segfault.
  
Actual results:
etpan crashes.

Expected results:
etpan should return error.

Additional info:
A fix is to check for null of mailbox_list before calling
mailimf_mailbox_list_free on it.

Please provide this fix ASAP.

Comment 1 Tomas Hoger 2008-06-12 20:07:47 UTC
Vinay, how did you come across this problem?  Only application in Fedora using
libetpan seems to be the claws-mail, but I fail to reproduce the problem with
it. Why did you flagged this as security issue?

Comment 2 Andreas Bierfert 2008-06-13 14:15:25 UTC
Seems like he is using the etpan mail client provided from the etpan folks.
Could you provide some more info regarding this?

Comment 3 Vinay Y S 2008-06-14 13:02:51 UTC
Yes, I've written an application that receives e-mail from a mail gateway and
parses it using etpan library. When a mail with a colon in the To address comes
in, the parser crashes.

Let me know if you need a standalone code to repro this issue.

Comment 4 Vinay Y S 2008-06-14 22:45:20 UTC
Created attachment 309375 [details]
The test message that causes the crash in mime parser.

This mime message has an extra colon in the To header after the display name.
The parser doesn't handle this case. It goes into a bad state and tries to free
up a unallocated structure, causing it to seg-fault.

Comment 5 Vinay Y S 2008-06-14 22:46:43 UTC
Created attachment 309376 [details]
A simple test code that reproduces the crash.

This is a very simple test code that calls mailmime_parse on the test message
to reproduce the crash.

Comment 6 Vinay Y S 2008-06-14 22:59:14 UTC
Created attachment 309377 [details]
A patch that fixes the crash

This patch changes libetpan-0.52/src/low-level/imf/mailimf.c
mailimf_group_parse function to checks the mailbox_list pointer before calling
mailimf_mailbox_list_free on it.

Comment 7 Vinay Y S 2008-06-14 23:01:46 UTC
Please accept the above patch and release a fixed rpm for Fedora.

Although the above patch fixes this crash, ideally the parser should be able to
ignore the extra : after displayname and continue parsing. This maybe a more
complex fix.

Comment 8 Vinay Y S 2008-06-15 18:09:28 UTC
This issue has been fixed with the same null check in the upstream cvs repository.

http://libetpan.cvs.sourceforge.net/libetpan/libetpan/src/low-level/imf/mailimf.c?view=diff&r1=1.46&r2=1.47



Comment 9 Tomas Hoger 2008-06-16 14:16:14 UTC
Un-restricting bug, as the patch is public in upstream CVS.

Comment 10 Fedora Update System 2008-06-17 15:18:23 UTC
libetpan-0.54-1.fc8 has been submitted as an update for Fedora 8

Comment 11 Fedora Update System 2008-06-17 15:20:22 UTC
libetpan-0.54-1.fc9 has been submitted as an update for Fedora 9

Comment 12 Fedora Update System 2008-06-20 19:06:28 UTC
libetpan-0.54-1.fc9 has been pushed to the Fedora 9 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update libetpan'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F9/FEDORA-2008-5469

Comment 13 Fedora Update System 2008-06-26 08:31:50 UTC
libetpan-0.54-1.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 14 Fedora Update System 2008-06-26 08:34:45 UTC
libetpan-0.54-1.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2008-07-26 06:07:13 UTC
libetpan-0.54-1.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.