Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 249214 (CVE-2008-4316) - dev-libs/glib <2.16.6-r1 g_base64_encode heap-based buffer overflow (CVE-2008-4316)
Summary: dev-libs/glib <2.16.6-r1 g_base64_encode heap-based buffer overflow (CVE-2008...
Status: RESOLVED FIXED
Alias: CVE-2008-4316
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Security
URL: http://www.ocert.org/advisories/ocert...
Whiteboard: A2? [glsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-29 01:43 UTC by Robert Buchholz (RETIRED)
Modified: 2009-04-03 13:51 UTC (History)
1 user (show)

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


Attachments
glib2-CVE-2008-4316.patch (glib2-CVE-2008-4316.patch,2.63 KB, patch)
2009-01-16 01:33 UTC, Robert Buchholz (RETIRED)
no flags Details | Diff
ebuild using above patch (glib-2.16.6-r1.ebuild,2.44 KB, text/plain)
2009-02-27 16:53 UTC, Daniel Gryniewicz (RETIRED)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Buchholz (RETIRED) gentoo-dev 2008-11-29 01:43:07 UTC
** Please note that this issue is confidential and no information should be
disclosed until it is made public, see "Whiteboard" for a date **

oCERT informed us about the following vulnerability:

Base64 encoding and decoding functions in glib suffer from
vulnerabilities during memory allocations which may result in arbitrary
code execution when processing large strings.

g_base64_encode and g_base64_decode allocate memory for their respective
behavior using a similar pattern:

  ret = g_malloc0 (input_length * 3 / 4);

In g_base64_decode, input_length is typed as a gint and its value is
derived directly from a strlen(3) call over an input string.  Since the
multiplication is evaluated prior to the division, an input_length
greater than (UINT_MAX/3), or 1431655765, will wrap resulting in smaller
allocation than required.  It is also possible to achieve the same
effect with a carefully calculated signedness overflow, like -1/4 = 0.

In g_base64_encode, input_length (or 'len' in this case) is of type
gsize.  This suffers from the same overflow as above, but without the
signedness issue.  In addition, gsize's width changes by platform which
will affect the overall reach of an encoding overflow.  However, the
decoding buffer overflow is a more likely target due to the immediate
control of the output data when overwriting the heap metadata.
Comment 1 Robert Buchholz (RETIRED) gentoo-dev 2008-11-29 01:43:48 UTC
Patch and embargo timeline to be discussed.
Comment 2 Rémi Cardona (RETIRED) gentoo-dev 2008-11-30 17:31:59 UTC
FYI, dev-util/pkgconfig needs to be checked because it bundles glib 1.2.x
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2008-11-30 17:36:01 UTC
I think g_mime was only implemented in 2.0
Comment 4 Mart Raudsepp gentoo-dev 2008-12-01 01:31:49 UTC
Isn't that g_base64_* stuff? None of that is used in pkg-config at least, the static copy has only a few files, base64 ones not part of it, and pkg-config code itself doesn't have any references to "64" and based on pkg-config functionality I don't see a place where it would make sense to use such stuff anyways. So this ones clear and safe
Comment 5 Mart Raudsepp gentoo-dev 2008-12-07 05:22:27 UTC
Any news on the patch or embargo date?
Comment 6 Robert Buchholz (RETIRED) gentoo-dev 2008-12-07 13:56:47 UTC
No word from upstream yet, a patch has been proposed on Friday and the targeted embargo date is middle of January next year. I'll attach the patch here as soon as we have an upstream ack.
Comment 7 Robert Buchholz (RETIRED) gentoo-dev 2009-01-16 01:33:31 UTC
Created attachment 178655 [details, diff]
glib2-CVE-2008-4316.patch

Matthias Clasen (who apparantly is part of the glib upstream) approved of the attached patch by Tomas Hoger of RedHat. Please test and prepare an ebuild, attach it to this bug. Do not commit anything to CVS, we will do prestable testing here.
Comment 8 Robert Buchholz (RETIRED) gentoo-dev 2009-02-25 17:44:54 UTC
upstream is targeting for the first week of march to lift the embargo and has underlined that the patch is ok and will be applied in 2.20 to be released around that time as well.
leio/remi, can we get it applied on our current stable? Please attach an ebuild to this bug so we can test it before then. Thanks.
Comment 9 Mart Raudsepp gentoo-dev 2009-02-27 01:21:26 UTC
Taking the liberty to CCing Daniel and Gilles here, as I will not be able to prepare an ebuild for glib-2.16 early enough considering the disclosure date (will be on devaway for a week or so), and I trust their security handling and not telling anything about this confidential bug outside here until it is announced here to have been publicly disclosed.

I should be back around the time of the current preliminary disclosure date though.
Comment 10 Daniel Gryniewicz (RETIRED) gentoo-dev 2009-02-27 16:53:15 UTC
Created attachment 183385 [details]
ebuild using above patch

Here's an ebuild for glib-2.16.2-r1 using the above patch.  I've tested it on a stable amd64 system.
Comment 11 Robert Buchholz (RETIRED) gentoo-dev 2009-02-27 17:01:34 UTC
Arch Security Liaisons, please test the attached ebuild and report it stable on this bug.
Target keywords : "alpha amd64 arm hppa ia64 m68k ppc ppc64 s390 sh sparc x86"

CC'ing current Liaisons:
   alpha : yoswink, armin76
   amd64 : keytoaster, tester
    hppa : jer
     ppc : dertobi123
   ppc64 : corsair
   sparc : fmccor
     x86 : maekke, armin76
Comment 12 Ferris McCormick (RETIRED) gentoo-dev 2009-02-27 18:25:14 UTC
Looks fine on sparc (all tests pass).
Comment 13 Jeroen Roovers (RETIRED) gentoo-dev 2009-02-27 22:14:35 UTC
HPPA is OK.
Comment 14 Mart Raudsepp gentoo-dev 2009-03-02 17:44:01 UTC
Note that there is a typo in the attachment comment and it should get saved and used as glib-2.16.6-r1.ebuild as the attachment name is.
Comment 15 Mart Raudsepp gentoo-dev 2009-03-02 19:33:47 UTC
Won't we need to pre-stable a 2.18 revision as well because 2.18 is under stabilization right now?
Comment 16 Robert Buchholz (RETIRED) gentoo-dev 2009-03-02 20:00:27 UTC
(In reply to comment #15)
> Won't we need to pre-stable a 2.18 revision as well because 2.18 is under
> stabilization right now?

From what I see, arches are not yet CC'ed on that bug report. Since this bug is going to be public soon (no clear date yet), can the 2.18 stabling just wait until then?
The first 2.18 ebuild revision to carry the patch would be the target for regular stabling then.
Comment 17 Robert Buchholz (RETIRED) gentoo-dev 2009-03-03 17:29:26 UTC
target date has been pushed to next week, possibly 2009-03-12.
Comment 18 Mart Raudsepp gentoo-dev 2009-03-03 17:58:57 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > Won't we need to pre-stable a 2.18 revision as well because 2.18 is under
> > stabilization right now?
> 
> From what I see, arches are not yet CC'ed on that bug report. Since this bug is
> going to be public soon (no clear date yet), can the 2.18 stabling just wait
> until then?
> The first 2.18 ebuild revision to carry the patch would be the target for
> regular stabling then.

Arches are CC'ed on full GNOME-2.24 stabilization and the list there includes glib-2.18

Comment 19 Robert Buchholz (RETIRED) gentoo-dev 2009-03-03 18:54:22 UTC
(In reply to comment #18)
> Arches are CC'ed on full GNOME-2.24 stabilization and the list there includes
> glib-2.18

Oh, I was looking at bug 253934, but it seems the action is on bug 260063 now. Feel free to add a 2.18 ebuild to this bug for testing by Arch Liaisons.
Comment 20 Robert Buchholz (RETIRED) gentoo-dev 2009-03-12 16:27:47 UTC
This is now public and committed to upstream SVN:
http://svn.gnome.org/viewvc/glib?view=revision&revision=7973

The prestable process was not too successful, but please commit with the gathered keywords and leave a comment once fixed versions are in the tree for the other arches to stable.
Comment 21 Tobias Scherbaum (RETIRED) gentoo-dev 2009-03-12 17:35:29 UTC
a little bit late, but 2.16.6-r1 looks good on ppc.
Comment 22 Daniel Gryniewicz (RETIRED) gentoo-dev 2009-03-13 00:20:52 UTC
2.16.6-r1 is in with sparc, hppa, and ppc stable.
2.18.4-r1 is in with amd64 stable.
Comment 23 Robert Buchholz (RETIRED) gentoo-dev 2009-03-13 21:16:43 UTC
Arches, please test and mark stable:
=dev-libs/glib-2.16.6-r1
Target keywords : "alpha amd64 arm hppa ia64 m68k ppc ppc64 s390 sh sparc x86"
Already stabled : "hppa ppc sparc"
Missing keywords: "alpha amd64 arm ia64 m68k ppc64 s390 sh x86"

=dev-libs/glib-2.18.4-r1
Target keywords : "alpha amd64 arm hppa ia64 m68k ppc ppc64 s390 sh sparc x86"
Already stabled : "amd64"
Missing keywords: "alpha arm hppa ia64 m68k ppc ppc64 s390 sh sparc x86"


Comment 24 Stefan Behte (RETIRED) gentoo-dev Security 2009-03-15 11:44:53 UTC
CVE-2008-4316 (http://nvd.nist.gov/nvd.cfm?cvename=CVE-2008-4316):
  Multiple integer overflows in glib/gbase64.c in GLib before 2.20
  allow context-dependent attackers to execute arbitrary code via a
  long string that is converted either (1) from or (2) to a base64
  representation.

Comment 25 Brent Baude (RETIRED) gentoo-dev 2009-03-15 12:55:41 UTC
ppc64 done
Comment 26 Markus Meier gentoo-dev 2009-03-15 15:08:16 UTC
amd64/x86 stable
Comment 27 Tobias Klausmann (RETIRED) gentoo-dev 2009-03-15 17:10:30 UTC
Both stable on alpha.
Comment 28 Raúl Porcel (RETIRED) gentoo-dev 2009-03-17 12:32:15 UTC
m68k stable, thanks to kolla for testing
Comment 29 Brent Baude (RETIRED) gentoo-dev 2009-03-18 18:54:39 UTC
ppc done
Comment 30 Jeroen Roovers (RETIRED) gentoo-dev 2009-03-23 05:21:06 UTC
HPPA is already stable except for 2.18.4-r1 which will be done through bug #260063.
Comment 31 Raúl Porcel (RETIRED) gentoo-dev 2009-03-27 17:50:08 UTC
arm/ia64/s390/sh/sparc stable
Comment 32 Robert Buchholz (RETIRED) gentoo-dev 2009-04-03 13:51:28 UTC
GLSA 200904-02