Bug 1188235 (CVE-2015-1472) - CVE-2015-1472 glibc: heap buffer overflow in glibc swscanf
Summary: CVE-2015-1472 glibc: heap buffer overflow in glibc swscanf
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2015-1472
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1188237 1209106 1209107 1242303
Blocks: 1188240 1210268 1262918
TreeView+ depends on / blocked
 
Reported: 2015-02-02 11:45 UTC by Vasyl Kaigorodov
Modified: 2021-02-17 05:41 UTC (History)
13 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
A heap-based buffer overflow flaw was found in glibc's swscanf() function. An attacker able to make an application call the swscanf() function could use this flaw to crash that application or, potentially, execute arbitrary code with the permissions of the user running the application.
Clone Of:
Environment:
Last Closed: 2015-11-20 05:49:53 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:2199 0 normal SHIPPED_LIVE Moderate: glibc security, bug fix, and enhancement update 2015-11-19 08:04:22 UTC
Red Hat Product Errata RHSA-2015:2589 0 normal SHIPPED_LIVE Important: glibc security update 2015-12-09 13:57:25 UTC
Sourceware 16618 0 None None None Never

Internal Links: 1209105

Description Vasyl Kaigorodov 2015-02-02 11:45:11 UTC
Heap buffer overflow was reported [1] in glibc stdio-common/vfscanf.c.

stdio-common/vfscanf.c has an ADDW macro that tries to determine whether to use malloc or alloca for allocations.  But in the malloc case, it only allocates newsize bytes instead of the required newsize * sizeof (CHAR_T).  Thus the allocated buffer gets overrun in the wide-string case, as shown in the following testcase:

  int
  main (void)
  {
    wchar_t *s = malloc ((SIZE + 1) * sizeof (*s));
    if (s == NULL)
      abort ();
    for (size_t i = 0; i < SIZE; i++)
      s[i] = L'0';
    s[SIZE] = L'\0';
    int i;
    if (swscanf (s, L"%d", &i) != 1)
      abort ();
    if (i != 0)
      abort ();
    free (s);
    return 0;
  }

CVE request: http://www.openwall.com/lists/oss-security/2015/02/01/8

[1]: https://sourceware.org/bugzilla/show_bug.cgi?id=16618

Comment 1 Vasyl Kaigorodov 2015-02-02 11:45:40 UTC
Created glibc tracking bugs for this issue:

Affects: fedora-all [bug 1188237]

Comment 2 Carlos O'Donell 2015-02-06 05:53:36 UTC
Now fixed in upstream.

commit 5bd80bfe9ca0d955bfbbc002781bc7b01b6bcb06
Author: Paul Pluzhnikov <ppluzhnikov>
Date:   Fri Feb 6 00:30:42 2015 -0500

    CVE-2015-1472: wscanf allocates too little memory
    
    BZ #16618
    
    Under certain conditions wscanf can allocate too little memory for the
    to-be-scanned arguments and overflow the allocated buffer.  The
    implementation now correctly computes the required buffer size when
    using malloc.
    
    A regression test was added to tst-sscanf.

Comment 6 Fedora Update System 2015-03-04 10:26:52 UTC
glibc-2.20-8.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Vasyl Kaigorodov 2015-05-21 15:59:53 UTC
Statement:

This issue did not affect the versions of glibc as shipped with Red Hat Enterprise Linux 5 and 6 as they did use different memory allocation algorithm in swscanf() function.

Comment 11 errata-xmlrpc 2015-11-19 04:16:04 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2015:2199 https://rhn.redhat.com/errata/RHSA-2015-2199.html

Comment 12 errata-xmlrpc 2015-12-09 08:58:14 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7.1 EUS - Server and Compute Node Only
  Red Hat Enterprise Linux 7.1 EUS  - Server and Compute Node Only

Via RHSA-2015:2589 https://rhn.redhat.com/errata/RHSA-2015-2589.html


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