Bug 496386 - glibc strfmon vulnerability
glibc strfmon vulnerability
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
10
i686 Linux
low Severity low
: ---
: ---
Assigned To: Andreas Schwab
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks: CVE-2008-1391
  Show dependency treegraph
 
Reported: 2009-04-18 10:15 EDT by Waasoo
Modified: 2009-11-22 19:49 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-11-22 19:49:06 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Waasoo 2009-04-18 10:15:46 EDT
Description of problem:

I'm able to reproduce vulnerability reported by Maksymilian Arciemowicz (http://securityreason.com/achievement_securityalert/53) for *BSD libc using glibc on Fedora Core 10.


Version-Release number of selected component (if applicable):
glibc v 2.9 rel 3. 


Steps to Reproduce:
==========example source===========
#include <monetary.h>
#include <stdlib.h>

int main(int argc, char ** argv)
{
	char buff[50];
	char * w_buff;
	w_buff = buff;
	strfmon(w_buff, sizeof(buff), "%9999999999n", 123.34);
	exit(EXIT_SUCCESS);
}
==========end======================

  
Actual results:
Segmentation fault


Expected results:
123.45
Comment 1 Ulrich Drepper 2009-04-18 15:57:45 EDT
There was a problem (fixed upstream).  But your expected result is wrong.  And it's really not a big issue since a) the format strings are hardly ever non-const and b) the written data is either the decimal representation of the number (in ASCII) or a space.
Comment 2 Jakub Jelinek 2009-04-27 16:11:53 EDT
Should be fixed in glibc-2.9.90-22.
Comment 3 Alexey Torkhov 2009-09-19 06:16:20 EDT
It seems that it still vulnerable to this:
http://sources.redhat.com/bugzilla/show_bug.cgi?id=10600

Running 
php -r 'money_format("%.1343741821i",1);'
eats about 3G on my machine and doesn't want to stop - I'm cancelling the task.

Reopening the bug.
Comment 4 Alexey Torkhov 2009-09-19 06:19:44 EDT
Test was run on fedora 11.
Comment 5 Andreas Schwab 2009-09-22 08:00:24 EDT
Don't do that then. You are requesting more than 1343741821 characters to be produced.
Comment 6 Alexey Torkhov 2009-09-22 08:13:21 EDT
(In reply to comment #5)
> Don't do that then. You are requesting more than 1343741821 characters to be
> produced.  

Strange, but it works fine in current Rawhide. I think, that's a bug in glibc and reassigning to php is wrong - program written in C would have same behaviour.
Comment 8 Joe Orton 2009-09-28 09:18:13 EDT
It makes no sense to assign this bug to php *and* mark it CLOSED->RAWHIDE. 
Nothing has changed in php.  Either there is a glibc bug which has been fixed,
there is a glibc bug which has not been fixed (completely), or there is a php
bug which has not been fixed.

Re-opening and reassigning to glibc, per thoger's comment at:

http://sources.redhat.com/bugzilla/show_bug.cgi?id=10600
Comment 9 Andreas Schwab 2009-09-28 12:11:52 EDT
There is nothing more to fix here.  Producing more than 1343741821 characters just needs a log of memory.
Comment 10 Tomas Hoger 2009-09-28 12:26:02 EDT
What does this do for you on rawhide / 32bit?

  printf("%.1073741821f\n", 0.0);

If my comments in upstream bug are incorrect, I'm happy to get corrected.  I've not tested rawhide, bug I did check F11 and I failed to see a fix in git to address problem I pointed out.

Anyway, lets stop calling this "strfmon" and "vulnerablitiy" ;).
Comment 12 Tomas Hoger 2009-09-28 13:56:27 EDT
I've been asked to provide more info about this, so here it comes.  It's already all in my comment in upstream bug (please do read it), but anyway:

$ rpm -q glibc
glibc-2.10.90-23.x86_64
glibc-2.10.90-23.i686

$ cat printf-int-overflow.c 
#include <stdio.h>

int main(void) {
	printf("%.1073741824f\n", 0.0);
	return 0;
}

$ gcc -Wall printf-int-overflow.c -m64 && ./a.out

$ gcc -Wall printf-int-overflow.c -m32 && ./a.out 
Segmentation fault

Running gdb, integer overflow I pointed out in the upstream bug is still there:

(gdb) i break
Num     Type           Disp Enb Address    What
1       breakpoint     keep y   0x003f388f in ___printf_fp at printf_fp.c:894
	breakpoint already hit 1 time


Breakpoint 1, ___printf_fp (fp=0x5264c0, info=0xffffd670, args=0xffffd6e4) at printf_fp.c:894
894	    size_t wbuffer_to_alloc = (2 + (size_t) chars_needed) * sizeof (wchar_t);
(gdb) n
895	    buffer_malloced = ! __libc_use_alloca (chars_needed * 2 * sizeof (wchar_t));
(gdb) 
904	      wbuffer = (wchar_t *) alloca (wbuffer_to_alloc);
(gdb) print chars_needed
$1 = 1073741826
(gdb) print wbuffer_to_alloc
$2 = 16

Btw, I'm *NOT* calling this security, but I still see bug that may be worth fixing.  Not oh-the-sky-is-falling priority, if you think this is not worth fixing / should not be fixed, please close-wontfix.  Rawhide resolution is not correct.  And it's not strfmon bug either.
Comment 14 Tomas Hoger 2009-10-13 12:31:32 EDT
printf("%.1073741824f\n", 0.0) no longer SEGVs with glibc-2.10.90-25, which includes following upstream git commit:

http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=199eb0de8d

Thanks, Andreas!
Comment 15 Bug Zapper 2009-11-18 07:50:03 EST
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 16 Ulrich Drepper 2009-11-22 19:49:06 EST
There is no problem, at least with the current code.

Note You need to log in before you can comment on or make changes to this bug.