Closed
      
        Bug 362213
      
      
        Opened 18 years ago
          Closed 17 years ago
      
        
    
  
heap overflow in MimeExternalBody_parse_eof    
    Categories
(Thunderbird :: Security, defect)
Tracking
(Not tracked)
        RESOLVED
        FIXED
        
    
  
People
(Reporter: guninski, Assigned: Bienvenu)
Details
(Keywords: fixed1.8.0.9, fixed1.8.1.1, Whiteboard: [sg:critical])
Attachments
(2 files, 1 obsolete file)
| 1.78 KB,
          text/plain         | Details | |
| 920 bytes,
          patch         | mscott
:
              
              superreview+ mscott
:
              
              approval-thunderbird2+ dveditz
:
              
              approval1.8.0.9+ | Details | Diff | Splinter Review | 
heap overflow in MimeExternalBody_parse_eof
MimeExternalBody_parse_eof:
	  h = (char *) PR_MALLOC((at ? strlen(at) : 0) + ...
doesn't allocate space for |ct| and    
FROB("Type",			ct);
overflows.
in addition in 	|(url ? strlen(url) : 0) + 100);| the constant |100| seems
small and may be overflowed even if allocating |ct|.
overflowing mailbox to follow.
|   | Reporter | |
| Comment 1•18 years ago
           | ||
|   | Reporter | |
| Updated•18 years ago
           | 
Severity: normal → major
|   | Reporter | |
| Comment 2•18 years ago
           | ||
|   | ||
| Updated•18 years ago
           | 
Flags: wanted1.8.0.x?
Flags: blocking1.8.1.1?
Flags: blocking-thunderbird2?
|   | Assignee | |
| Comment 3•18 years ago
           | ||
geez, I love libmime. That code is crying out for rewriting with nsCStrings...Dan, I can look at this if you want.
| Updated•18 years ago
           | 
Assignee: dveditz → bienvenu
Flags: wanted1.8.1.x+
Flags: wanted1.8.0.x?
Flags: wanted1.8.0.x+
Flags: blocking1.8.0.9?
Whiteboard: [sg:critical]
| Updated•18 years ago
           | 
Flags: blocking1.8.1.1?
Flags: blocking1.8.1.1+
Flags: blocking1.8.0.9?
Flags: blocking1.8.0.9+
|   | Assignee | |
| Comment 4•18 years ago
           | ||
just add ct to the size calculation - I think all other fields are accounted for.
        Attachment #246962 -
        Flags: superreview?(mscott)
| Updated•18 years ago
           | 
Whiteboard: [sg:critical] → [sg:critical] needs reviews (mscott)
|   | ||
| Updated•18 years ago
           | 
        Attachment #246962 -
        Flags: superreview?(mscott)
        Attachment #246962 -
        Flags: superreview+
        Attachment #246962 -
        Flags: approval-thunderbird2+
|   | Assignee | |
| Comment 5•18 years ago
           | ||
Comment on attachment 246962 [details] [diff] [review]
proposed fix
simple fix.
        Attachment #246962 -
        Flags: approval1.8.0.9?
|   | Assignee | |
| Comment 6•18 years ago
           | ||
fixed on trunk and 1.8.1 branch
Status: NEW → RESOLVED
Closed: 18 years ago
Keywords: fixed1.8.1.1
Resolution: --- → FIXED
Whiteboard: [sg:critical] needs reviews (mscott) → [sg:critical]
| Comment 7•18 years ago
           | ||
Comment on attachment 246962 [details] [diff] [review]
proposed fix
approved for 1.8.0 branch, a=dveditz
        Attachment #246962 -
        Flags: approval1.8.0.9? → approval1.8.0.9+
|   | Assignee | |
| Updated•18 years ago
           | 
Keywords: fixed1.8.0.9
|   | Reporter | |
| Comment 8•18 years ago
           | ||
(In reply to comment #1)
(In reply to comment #0)
> the constant |100| seems small
this comment is dumb, but the logic of adding |strlen()| is strange. shouldn't it be MAX(strlen()) instead of + strlen?
|   | Assignee | |
| Comment 9•18 years ago
           | ||
all the strings get concatenated together, so we have to add all the strlens...
you're right that 100 is too small - it needs to be ~76 (the total length of the header strings) + (4 * 12) (the per header overhead times the number of possible headers). That would handle the case where all the headers are present...So 150 would be a safe number...
|   | Assignee | |
| Comment 10•18 years ago
           | ||
address G30rgi's comment about 100 seeming too small, sorry I missed that before...
        Attachment #247417 -
        Flags: superreview?(mscott)
        Attachment #247417 -
        Flags: review?(dveditz)
|   | Assignee | |
| Comment 11•18 years ago
           | ||
I'm reopening this, unless we want a new bug for the issue the first patch didn't address.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
|   | ||
| Updated•18 years ago
           | 
        Attachment #247417 -
        Flags: superreview?(mscott) → superreview+
|   | Reporter | |
| Comment 12•18 years ago
           | ||
(In reply to comment #9)
> all the strings get concatenated together, so we have to add all the strlens...
> 
are you sure about this?
tried to exploit it with no luck.
373 # define FROB(STR,VAR) \
374       if (VAR) \
375         { \
376           PL_strcpy(h, STR ": "); \
377           PL_strcat(h, VAR); \
378           PL_strcat(h, MSG_LINEBREAK); \
379           status = MimeHeaders_parse_line(h, strlen(h), hdrs); \
380           if (status < 0) goto FAIL; \
381         }
PL_strcpy starts from the begging of |h| ?
|   | Assignee | |
| Comment 13•18 years ago
           | ||
no, I think you're right - re-resolving as fixed. So I have no idea why they're adding together all the strlens...
Status: REOPENED → RESOLVED
Closed: 18 years ago → 18 years ago
Resolution: --- → FIXED
|   | Assignee | |
| Updated•18 years ago
           | 
        Attachment #247417 -
        Attachment is obsolete: true
        Attachment #247417 -
        Flags: review?(dveditz)
| Updated•18 years ago
           | 
Flags: wanted1.8.1.x+
Flags: wanted1.8.0.x+
|   | ||
| Comment 14•18 years ago
           | ||
clearing blocking flag on a fix already landed on the branch.
Flags: blocking-thunderbird2?
| Updated•18 years ago
           | 
Group: security
|   | Reporter | |
| Updated•17 years ago
           | 
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
|   | Reporter | |
| Updated•17 years ago
           | 
Status: REOPENED → RESOLVED
Closed: 18 years ago → 17 years ago
Resolution: --- → FIXED
          You need to log in
          before you can comment on or make changes to this bug.
        
Description
•