Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 71129 - joe non-critical buffer overflow
Summary: joe non-critical buffer overflow
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Tom Knight (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-14 01:51 UTC by GrayShade
Modified: 2004-11-22 05:33 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Silly patch for buffer overflow (joe_overflow_fix.patch,393 bytes, patch)
2004-11-14 09:05 UTC, Dan Margolis (RETIRED)
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description GrayShade 2004-11-14 01:51:32 UTC
'joe' suffers from an exploitable stack-based buffer overflow in parsing the path to the current user's home directory.. Note that this is not critical, because joe does not run with elevated privileges by default.

Reproducible: Always
Steps to Reproduce:
ulimit -c unlimited; HOME=`perl -e 'print "a"x1030; print "abcd"'` joe; echo q|gdb joe core
Actual Results:  
note that the actual "buffer size" may vary from distribution to 
distribution.. 1034 is on my actual gentoo system with joe-3.0 compiled with -
O3 and gcc 3.3.2.. if it does not work, try with 1056 or more


I found this bug about three years ago and it seems that it's still unfixed.. 
Could someone (joe maintainer?) take a look at it?

The actual vulnerable function is procrc (rc.c):

	s = (unsigned char *)getenv("HOME");
main.c:
/* ... */
	if (s) {
		s = vsncpy(NULL, 0, sz(s));
		s = vsncpy(sv(s), sc("/."));
		s = vsncpy(sv(s), sv(run));
		s = vsncpy(sv(s), sc("rc"));
		c = procrc(cap, s); 
/* ... */

int procrc(CAP *cap, unsigned char *name)
{
/* ... */
	unsigned char buf[1024];	/* Input buffer */ 
/* ... */
	strcpy(buf, name);
/* ... */
}
Comment 1 Dan Margolis (RETIRED) gentoo-dev 2004-11-14 08:49:32 UTC
Confirmed (propolice will prevent this, however). 
Comment 2 Dan Margolis (RETIRED) gentoo-dev 2004-11-14 09:05:34 UTC
Created attachment 43935 [details, diff]
Silly patch for buffer overflow
Comment 3 Dan Margolis (RETIRED) gentoo-dev 2004-11-14 09:07:30 UTC
This is extremely unlikely to be a security vuln. But I added a stupid patch anyway. What else do I do on a lazy Sunday morning?
Comment 4 Dan Margolis (RETIRED) gentoo-dev 2004-11-14 09:45:41 UTC
OK, I was going to reassign, but I had a collision with Jaervosz. In either case, definitely ``no'' on a GLSA for this, and personally, I wouldn't even consider it a security fix. But it's no big deal either eway. 
Comment 5 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2004-11-14 09:53:16 UTC
I agree with Dan reassigning to tomk.
Comment 6 GrayShade 2004-11-15 07:41:59 UTC
shouldn't it have been

    strncpy(buf, name, sizeof(buf));

instead of

    strncpy(buf, name, sizeof(buf) - 1);

?
Comment 7 Tom Knight (RETIRED) gentoo-dev 2004-11-22 05:33:18 UTC
Just to be on the safe side lets make it:

strcpy(buf, name, sizeof(buf) - 1);
buf[sizeof(buf)-1] = '\0';

Fixed, in CVS.