First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 234391
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo Security <security@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Maurice van der Pot <griffon26@gentoo.org>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:
Flags: Requestee:
 
 
  ()

Filename Description Type Creator Created Size Actions
ssmtp-2.62-off-by-one-typecasts-and-from-fix.patch Proposed misc fixes patch Maurice van der Pot 2008-08-10 17:52 0000 4.16 KB Details | Diff
ssmtp-2.62-typecasts-and-from-fix.patch Updated patch. Removed fix for off-by-one that wasn't an off-by-one. patch Maurice van der Pot 2008-08-21 17:57 0000 3.95 KB Details | Diff
ssmtp-unitialized-strdup.patch ssmtp-unitialized-strdup.patch patch Robert Buchholz 2008-09-09 12:34 0000 293 bytes Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 234391 depends on: Show dependency tree
Bug 234391 blocks: 236812

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2008-08-10 17:18 0000
In ssmtp.c the function fd_gets more or less looks like this:

char *fd_gets(char *buf, int size, int fd)
{
        while((i < size) && (fd_getc(fd, &c) == 1)) {
                        buf[i++] = c;
        }
        buf[i] = (char)NULL;
        return(buf);
}

Coming out of the loop, i can be size, causing a 0-byte to be written past the
end of the buffer.

There are also lots of "char c = (char)NULL;" and "char *p = (char)NULL;"
occurrences that may be indicative of careless programming and may warrant a
code review.

------- Comment #1 From Pierre-Yves Rofes 2008-08-10 17:22:58 0000 -------
I agree on the off-by-one error, but initializing variables to NULL before
using them seems a rather good practice to me, as it allows to find some bugs
more easily. We'll probably have to contact upstream.

------- Comment #2 From Maurice van der Pot 2008-08-10 17:52:09 0000 -------
Created an attachment (id=162630) [edit]
Proposed misc fixes

In addition to fixing the "(char)NULL" things and the off-by-one, this also
addresses a problem in from_format() that caused a call to strdup on a local
buffer with uninitialized contents.

This last problem was introduced in 2.62 and was the reason I started looking
at the source code in the first place (the From: line wasn't properly
formatted).

I have not looked at the rest of the source, so I'm not claiming this is a
complete solution.

------- Comment #3 From Robert Buchholz 2008-08-19 22:21:21 0000 -------
Concerning the potential off-by-one:
There is no off-by-one error if 'int size' is not the buffer size, but the
maximum number of characters the buffer can contain (not counting the NUL).
From my reading of the code, this is what happens:

The only call of that function is here:

int smtp_read(int fd, char *response)
{
        do {
                if(fd_gets(response, BUF_SZ, fd) == NULL) {
...

smtp_read() is called at several places, but all buffers that are passed as
'response' have been allocated as 'BUF_SZ + 1'. Am I missing something?

------- Comment #4 From Maurice van der Pot 2008-08-21 07:27:07 0000 -------
You're right about the buffer size. 

Now if the strdup is not something that can be abused, then this can be demoted
to a regular ssmtp bug.

------- Comment #5 From Maurice van der Pot 2008-08-21 17:57:12 0000 -------
Created an attachment (id=163507) [edit]
Updated patch. Removed fix for off-by-one that wasn't an off-by-one.

Updated patch.

------- Comment #6 From Robert Buchholz 2008-09-09 12:34:12 0000 -------
Created an attachment (id=165005) [edit]
ssmtp-unitialized-strdup.patch

Just the security-relevant hunk.

------- Comment #7 From Robert Buchholz 2008-09-09 12:44:26 0000 -------
Opening to the public, please commit with the patch.

------- Comment #8 From Robert Buchholz 2008-09-09 15:09:23 0000 -------
CVE-2008-3962 has been assigned.

------- Comment #9 From Tobias Scherbaum 2008-09-09 19:49:22 0000 -------
2.62-r3 is inCVS.

------- Comment #10 From Robert Buchholz 2008-09-11 09:23:13 0000 -------
As Tomas Hoger pointed out, this has been a re-introduction of bug 127592 since
that patch was dropped in the ebuild when 2.62 was bumped.

2.61 is also affected, but we patched it in 2006.

------- Comment #11 From Tobias Scherbaum 2008-09-12 14:08:07 0000 -------
(In reply to comment #10)
> As Tomas Hoger pointed out, this has been a re-introduction of bug 127592 since
> that patch was dropped in the ebuild when 2.62 was bumped.
> 
> 2.61 is also affected, but we patched it in 2006.
> 

only 2.61-r2 and 2.61-r31 where patched, but not -2.61-r30 which i apparantly
used as a base for 2.62, thus the patch got dropped for 2.62. 2.61-r30 was
always p.masked iirc. 

------- Comment #12 From Robert Buchholz 2008-09-12 14:12:43 0000 -------
Arches, please test and mark stable:
=mail-mta/ssmtp-2.62-r3
Target keywords : "alpha amd64 arm hppa ia64 m68k ppc ppc64 s390 sh sparc x86"

------- Comment #13 From Jeroen Roovers 2008-09-12 15:22:50 0000 -------
Stable for HPPA.

------- Comment #14 From Markus Meier 2008-09-12 21:42:56 0000 -------
amd64/x86 stable

------- Comment #15 From Raúl Porcel 2008-09-13 16:22:16 0000 -------
alpha/ia64/sparc stable

------- Comment #16 From Brent Baude 2008-09-17 14:44:47 0000 -------
ppc and ppc64 stable

------- Comment #17 From Robert Buchholz 2008-11-09 12:57:29 0000 -------
It was only stable for a short timeframe and the issue is almost impossible to
exploit. My vote is NO glsa.

------- Comment #18 From Pierre-Yves Rofes 2008-11-26 22:35:07 0000 -------
no too, and closing.

First Last Prev Next    No search results available      Search page      Enter new bug