Closed
Bug 258005
Opened 20 years ago
Closed 20 years ago
heap overflows triggered by "send page"
Categories
(MailNews Core :: Security, defect)
MailNews Core
Security
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: guninski, Assigned: mscott)
References
Details
(Keywords: fixed-aviary1.0, fixed1.7.5, Whiteboard: [sg:fix] fixed1.7.3)
Attachments
(4 files, 1 obsolete file)
132 bytes,
application/x-perl
|
Details | |
136 bytes,
text/plain
|
Details | |
4.02 KB,
text/html
|
Details | |
8.40 KB,
patch
|
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115
Build Identifier: Mozilla/5.0
there are heap based buffer overflows triggered by "send page" and then sending
the email. the overflow is at least in 1.7 and nightly from 3.sep.
the fucked code is in
nsMsgCompUtils.cpp
mime_generate_attachment_headers
one of the overflows is triggered by:
if (*s == ' ')
PUSH_STRING("%20");
one char consumes 3 bytes of memory, while only 2 are allocated.
to reproduce try to send as page "data:text/html;,A_LOT_OF_SPACES.
the other buffer overflow is triggered by sending long http urls containing ' ',
not clear which code fucks it.
btw, the macro PUSH_STRING is quite unsafe and i suggest it checks whether there
is enough space left.
Reproducible: Always
Steps to Reproduce:
will attach testcases.
Actual Results:
the heap is fucked up
Expected Results:
the heap is not fucked up
Reporter | ||
Comment 1•20 years ago
|
||
put in cgi-bin, access it, click on the link then choose "send page" and send
the email.
Reporter | ||
Comment 2•20 years ago
|
||
put in cgi-bin, access it, put web server on localhost:1234 which should serve
anything, send the page as email.
Updated•20 years ago
|
Flags: blocking1.7.x+
Flags: blocking-aviary1.0PR+
Comment 3•20 years ago
|
||
mscott, can you take a look?
/be
Assignee: sspitzer → mscott
Status: UNCONFIRMED → NEW
Ever confirmed: true
Reporter | ||
Comment 4•20 years ago
|
||
Reporter | ||
Comment 5•20 years ago
|
||
bug 257314 was fixed by changing PL_strcpy with nsCAutoString, so this patch
does the same.
the risk from regression is low, the performance hit is minimal.
the only potential problem may be memory leak in this:
return PL_strdup(buf.get());
couldn't find the definition of nsCAutoString
Assignee | ||
Comment 6•20 years ago
|
||
I took Georgi's original patch and did the following:
1) removed the tabs
2) changed the nsCAutoString to an nsCString
3) I also did a review on the code to make sure each .Append call had the same
arguments as the old push string call.
4) Note that many (but not all!) of these changes are inside of a
GENERATE_CONTENT_BASE ifdef which we don't defined during the build so some of
it isn't actually executed.
There are still more cases of PUSH_STRING that could probably be converted over
to using the string APIs in this file.
Assignee | ||
Updated•20 years ago
|
Attachment #157934 -
Attachment is obsolete: true
Assignee | ||
Comment 7•20 years ago
|
||
Comment on attachment 158152 [details] [diff] [review]
updated version of the fix
See:
http://bugzilla.mozilla.org/show_bug.cgi?id=258005#c6
for details
Attachment #158152 -
Flags: superreview?(bienvenu)
Updated•20 years ago
|
Whiteboard: [sg:fix] → [sg:fix] [have patch] need review bienvenu
Updated•20 years ago
|
Attachment #158152 -
Flags: superreview?(bienvenu) → superreview+
Assignee | ||
Comment 8•20 years ago
|
||
fixed on the aviary 1.0 branch and the trunk. We should probably let this bake
for a couple days before landing for 1.7.x?
Comment 9•20 years ago
|
||
+ nsCString buf("");
no need for the "" argument, strings are empty by default
Comment 10•20 years ago
|
||
If the string-expanding PUSH_STRING("%20") is inside the ifdef, then the buffer
overrun must be somewhere else. Does this really fix it?
Comment 11•20 years ago
|
||
Checked "updated version" into the 1.7.2 branch
Fixes the html testcase linked above, can't test the cgi-bin testcases right now.
I'm concerned similar PUSH_STRING() problems lurk in mime_generate_headers:
> /* Add a bunch of slop for the static parts of the headers. */
> /* size += 2048; */
> size += 2560;
If the "slop" had to be increased once there's no guarantee we haven't added new
headers since. Or that it was even right to begin with.
Reporter | ||
Comment 12•20 years ago
|
||
dveditz: i agree that other occurences of PUSH_STRING should be fixed also in
the same simple way.
per your previous comment, i believe the c++ stuff fixes the overflow in both
testcases as evidence suggests.
btw, are there any docs which explain the methods and usage of basic NS* classes?
Comment 13•20 years ago
|
||
> are there any docs which explain the methods and usage of basic NS* classes?
For nsString
<http://www.mozilla.org/projects/xpcom/string-quickref.html>
<http://www.mozilla.org/projects/xpcom/string-guide.html>
but they may be outdated and incomplete.
Updated•20 years ago
|
Whiteboard: [sg:fix] [have patch] need review bienvenu → [sg:fix] fixed1.7.2+, needed-1.7.x
Comment 14•20 years ago
|
||
at least that second link is pretty up-to-date.
Updated•20 years ago
|
Group: security
Whiteboard: [sg:fix] fixed1.7.2+, needed-1.7.x → [sg:fix] fixed1.7.3, needed-1.7.x
Updated•20 years ago
|
Summary: heap overflows triggerd by "send page" → heap overflows triggered by "send page"
Comment 15•20 years ago
|
||
(In reply to comment #11)
> Checked "updated version" into the 1.7.2 branch
>
I found this patch is not in 1.7 branch. Is there anything wrong?
Comment 16•20 years ago
|
||
I found this patch is in MOZILLA_1_7_3_RELEASE branch but not in
MOZILLA_1_7_BRANCH. Should we check it into MOZILLA_1_7_BRANCH so that we can
have it in mozilla 1.7.4 and later?
Comment 17•20 years ago
|
||
Yes, please put this on the 1.7 branch.
Updated•20 years ago
|
Product: MailNews → Core
Comment 18•20 years ago
|
||
It is still not on the MOZILLA_1_7_BRANCH for 1.7.5.
Updated•20 years ago
|
Keywords: fixed1.7.5
Whiteboard: [sg:fix] fixed1.7.3, needed-1.7.x → [sg:fix] fixed1.7.3
Comment 19•20 years ago
|
||
Both Tracy and I tested the html testcase using 1.75 Windows 20041216 - I tested
using 1.75 Mac 20041216-09. verifying fixed after discussion with dveditz.
Status: RESOLVED → VERIFIED
Comment 20•20 years ago
|
||
(note: fix checked into 1.7 branch by mkaply on 12/15)
Updated•17 years ago
|
Product: Core → MailNews Core
You need to log in
before you can comment on or make changes to this bug.
Description
•