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

Filename Description Type Creator Created Size Actions
attachment.diff command line handling patch solar 2004-05-15 09:38 0000 2.36 KB Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 46998 depends on: Show dependency tree
Show dependency graph
Bug 46998 blocks:

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







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


Description:   Opened: 2004-04-06 14:33 0000
from bugtraq@securityfocus.com:


...
Details
########

A stack-based buffer overflow vulnerability exists in
the popular 'shar' utility packaged in the GNU
sharutils distribution, due to lack of bounds checking
when handling the '-o' command-line option.

During the command-line argument parsing routine, when
the '-o' flag is encountered, 'shar' performs a
'strcpy()' call to blindly copy the user-supplied
argument after '-o' without bounds checking, into a
fixed length buffer, output_base_name, which has only
50 allocated to it.
...
Solution
#########

I contacted the vendor, GNU, and received no response
within 4 1/2 days.

Although this issue isn't to be considered a serious
security threat, there are instances where this can be
exploited by a would-be attacker to execute code, such
as in the circumstances suggested above (cgi script,
sXid program, etc).  Therefore, it would be considered
good practice to apply the fix regardless of whether
your system is likely to be compromised as a result of
the issue.

I have written a simple patch below to fix the buffer
overflow bug:


--- shar-bof.patch ---

--- shar.1.c    2004-04-06 16:26:55.000000000 +0100
+++ shar.c      2004-04-06 16:32:32.000000000 +0100
@@ -1905,7 +1905,7 @@
        break;

       case 'o':
-       strcpy (output_base_name, optarg);
+       strncpy (output_base_name, optarg,
sizeof(output_base_name));
        if (!strchr (output_base_name, '%'))
          strcat (output_base_name, ".%02d");
        part_number = 0;
--- EOF ---
...

above text is a snippet from the bugtraq maillist.
Apply the patch, and rebuild:

---
bash# patch < shar-bof.patch && make && make install



so long
rootshell


 

Reproducible: Always
Steps to Reproduce:
1.
2.
3.

------- Comment #1 From SpanKY 2004-04-06 14:56:02 0000 -------
sharutils-4.2.1-r8 has this patch

i dont think we need a GLSA as this doesnt seem to have any exploitable-ness to it ...

------- Comment #2 From Thierry Carrez (RETIRED) 2004-04-07 08:48:29 0000 -------
4.2.1-r8 must be stable before we get into GLSA process.
Resetting component to Security.

------- Comment #3 From SpanKY 2004-04-07 15:46:08 0000 -------
i tested on x86 / sparc / hppa so those are stable now

------- Comment #4 From Aron Griffis (RETIRED) 2004-04-07 18:55:10 0000 -------
alpha and ia64 are stable

------- Comment #5 From Joshua Kinard 2004-04-07 21:31:25 0000 -------
Stable on mips.

------- Comment #6 From solar 2004-04-08 02:35:06 0000 -------
sharutils-4.2.1-r8 bug update. Currently in cvs portage tree as.
KEYWORDS="x86 ~amd64 ~ppc sparc alpha hppa ia64 ~ppc64 s390 mips"

Adding amd64 & ppc to this bug.

I would think this would fall under the "good practice" vs GLSA and thus 
the 'Severity' could be lowered from critical to normal. Users can
usually walk all over themselves from the command line.

------- Comment #7 From Jon Portnoy (RETIRED) 2004-04-08 07:36:51 0000 -------
Marked stable on amd64

------- Comment #8 From solar 2004-04-09 07:22:14 0000 -------
While adding another patch to the sharutils bug that Florian had sent us
in mail, I noticed that the code lacked bounds checking a few lines
below in the same -o option.

--- 1907,1912 ----
        case 'o':
        strcpy (output_base_name, optarg);
+       memset(output_base_name, '\0', sizeof(output_base_name));
+       strncpy (output_base_name, optarg, sizeof(output_base_name)-1);
        if (!strchr (output_base_name, '%'))
          strcat (output_base_name, ".%02d");

As we can see we can fill the string up to sizeof(blah)-1 but what if 
the string contains a format identifier? It will overflow right again.
Not only will it overflow but we have the full makings here of a format
string vuln. Check it out..

solar@simple sharutils $ shar -o `perl -e 'print "%p" x 54'`
solar@simple sharutils $ ls
solar@simple sharutils $ shar -o `perl -e 'print "%p" x 54'`
shar: No input files
Try `shar --help' for more information.
solar@simple sharutils $ ls
0x10x2e80f0200x30356230x5e2e60c80x2e8e1dd70x30x5e2e62a40xe25c7dd0xe25ecc00xe25eff00xe25f1e00xe25f2120x5e2e62580xe258dcd0xe25f1e00x250x320xe25ecc0(nil)0x2e82dd500x2e8253f00x2e80fb200x30x2e80fda80x2e80eff8

# fun with all the format identifiers...
shar -o `perl -e 'print "%d" x 54'`
shar -o `perl -e 'print "%s" x 54'`

It's safe to say this is not fixed and new patch should be created.

------- Comment #9 From solar 2004-04-13 13:26:10 0000 -------
I'm reviewing this patch shortly.

http://marc.theaimsgroup.com/?l=bugtraq&m=108164583423126&w=2

------- Comment #10 From solar 2004-04-13 14:43:23 0000 -------
Ok patch works for the -o format string problem.  But while looking over
other areas of code in sharutils I found what looks like more undesired 
voodoo.. Actually quite a bit of it.

This thing needs either a complete rewrite or a full audit in my
opinion. Neither of which I intend to do.. (Volunteers Welcome)

I also can't make heads/tails of who to exactly mail upstream about all 
this.

------- Comment #11 From Kurt Lieber 2004-04-20 04:43:43 0000 -------
OK, the only semi-relevant email address I can find is
bug-gnu-utils@prep.ai.mit.edu, which is listed in the README included with the
sharutils sources.  

I contacted them and asked them to look at our bug here and provide some sort
of response.  (and hopefully a patch)

------- Comment #12 From Kurt Lieber 2004-04-20 04:52:03 0000 -------
OK, Google proved its worth once more.  The current active address for
bug-gnu-utils seems to be bug-gnu-utils@gnu.org.  Looking at the archives[1]
for the mailing list, it appears there are two semi-active maintainers of
sharutils; Karl Eichwalder <keichwa@gmx.net> and Paul Eggert
<eggert@twinsun.com>.

Solar -- since you're most familiar with the issues you've found in sharutils
(outside of the -o issue) would you mind emailing these folks and asking for
their input?  

[1]http://mail.gnu.org/archive/html/bug-gnu-utils/

------- Comment #13 From solar 2004-04-23 01:01:31 0000 -------
mail sent.

------- Comment #14 From solar 2004-05-15 09:38:26 0000 -------
Created an attachment (id=31485) [edit]
command line handling

From:	Karl Eichwalder <ke@gnu.franken.de
To:	solar@gentoo.org
Cc:	eggert@twinsun.com
Subject:	Re: <=app-arch/sharutils-4.2.1-r8 - Multiple command line
vulnerabilities.
Date:	Sat, 15 May 2004 11:19:19 +0200

Thanks for the info; I'm going to add tht appended patch supplied by
Suse Linux.  My sharutils CVS is here:
http://developer.berlios.de/projects/sharutils/ - if one of you wants
to become a "developer" or a "project admin" please drop me a line.

2004-05-15  Karl Eichwalder  <ke@gnu.franken.de>

	* shar.c (open_output): Fix command line handling; reported by Ned
	Ludd: http://bugs.gentoo.org/show_bug.cgi?id=46998
	Use patch supplied by Michael Schr

------- Comment #15 From solar 2004-05-15 09:38:26 0000 -------
Created an attachment (id=31485) [edit]
command line handling

From:	Karl Eichwalder <ke@gnu.franken.de
To:	solar@gentoo.org
Cc:	eggert@twinsun.com
Subject:	Re: <=app-arch/sharutils-4.2.1-r8 - Multiple command line
vulnerabilities.
Date:	Sat, 15 May 2004 11:19:19 +0200

Thanks for the info; I'm going to add tht appended patch supplied by
Suse Linux.  My sharutils CVS is here:
http://developer.berlios.de/projects/sharutils/ - if one of you wants
to become a "developer" or a "project admin" please drop me a line.

2004-05-15  Karl Eichwalder  <ke@gnu.franken.de>

	* shar.c (open_output): Fix command line handling; reported by Ned
	Ludd: http://bugs.gentoo.org/show_bug.cgi?id=46998
	Use patch supplied by Michael Schröder: http://bugzilla.suse.de
	[#39122, password protected].

------- Comment #16 From solar 2004-05-15 09:55:03 0000 -------
Updated existing patch in portage tree but revision bumped to force updates.

sharutils-4.2.1-r9.ebuild:
KEYWORDS="~x86 ~amd64 ~ppc ~sparc ~alpha ~hppa ~ia64 ~ppc64 ~s390 ~mips"

------- Comment #17 From Thierry Carrez (RETIRED) 2004-05-15 10:59:14 0000 -------
arch-maintainers : please mark stable on all arches (except arm)

------- Comment #18 From Gustavo Zacarias (RETIRED) 2004-05-15 11:27:50 0000 -------
Marked stable on sparc.

------- Comment #19 From Guy Martin 2004-05-15 13:12:31 0000 -------
Marked stable on hppa.

------- Comment #20 From Joshua Kinard 2004-05-15 13:18:03 0000 -------
Marked stable on mips.

------- Comment #21 From Jon Portnoy (RETIRED) 2004-05-15 13:27:08 0000 -------
Stable on amd64 and x86

------- Comment #22 From Bryan Østergaard (RETIRED) 2004-05-15 13:54:49 0000 -------
Stable on alpha.

------- Comment #23 From Luca Barbato 2004-05-15 18:51:16 0000 -------
Stable on ppc

------- Comment #24 From Thierry Carrez (RETIRED) 2004-05-16 03:15:45 0000 -------
Ready for a GLSA draft

------- Comment #25 From solar 2004-05-16 10:08:17 0000 -------
Send a GLSA if you want. 
But please note that further auditing should be done on sharutils.

------- Comment #26 From Thierry Carrez (RETIRED) 2004-05-16 10:10:30 0000 -------
GLSA drafted for the case we need it...

------- Comment #27 From Thierry Carrez (RETIRED) 2004-05-20 14:15:58 0000 -------
Not really exploitable so closed without GLSA.

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