Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1511330 - libmad's mad_bit_read & mad_bit_skip of bit.c may make array out of bounds reads with crafted input
Summary: libmad's mad_bit_read & mad_bit_skip of bit.c may make array out of bounds r...
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: libmad
Version: 26
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Nicolas Chauvet (kwizart)
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-11-09 07:33 UTC by Liu Woon Yung
Modified: 2018-05-29 12:40 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-29 12:40:54 UTC


Attachments (Terms of Use)
Test case for libmad's mad_bit_read() segment fault (deleted)
2017-11-09 07:33 UTC, Liu Woon Yung
no flags Details
Test case for libmad's mad_bit_read() segment fault (fixed) (deleted)
2017-11-16 06:13 UTC, Liu Woon Yung
no flags Details
md_size.diff (deleted)
2018-02-09 19:39 UTC, Ozkan Sezer
no flags Details | Diff
length-check.patch (deleted)
2018-02-09 19:40 UTC, Ozkan Sezer
no flags Details | Diff

Description Liu Woon Yung 2017-11-09 07:33:52 UTC
Created attachment 1349778 [details]
Test case for libmad's mad_bit_read() segment fault

Description of problem:
libmad's mad_bit_read() and mad_bit_skip() functions may make array out of bounds reads when a malformed MP1/MP2/MP3 frame is supplied to the libmad library.

Version-Release number of selected component (if applicable):
libmad-0.15.1b-21

How reproducible:
Always

Steps to Reproduce:
1. Compile libmadtest.c with address sanitizer
2. ./libmadtest libmadfault.mp3

Actual results:
ASAN:DEADLYSIGNAL
=================================================================
==1921==ERROR: AddressSanitizer: SEGV on unknown address 0x5653621b7000 (pc 0x565361f99919 bp 0x565361fa25a0 sp 0x7fff0a9c80b8 T0)
    #0 0x565361f99918 in mad_bit_read /home/nozomi/CZ4062/libmad-0.15.1b/bit.c:168
    #1 0x565361f9c148 in II_samples /home/nozomi/CZ4062/libmad-0.15.1b/layer12.c:303
    #2 0x565361f9cbbb in mad_layer_II /home/nozomi/CZ4062/libmad-0.15.1b/layer12.c:490
    #3 0x565361f9a482 in mad_frame_decode /home/nozomi/CZ4062/libmad-0.15.1b/frame.c:453
    #4 0x565361f99257 in run_sync /home/nozomi/CZ4062/libmad-0.15.1b/decoder.c:404
    #5 0x565361f99732 in mad_decoder_run /home/nozomi/CZ4062/libmad-0.15.1b/decoder.c:557
    #6 0x565361f9878b in main (/home/nozomi/CZ4062/libmadtest/libmadtest-noafl+0x178b)
    #7 0x7fed48dfc2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    #8 0x565361f98859 in _start (/home/nozomi/CZ4062/libmadtest/libmadtest-noafl+0x1859)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/nozomi/CZ4062/libmad-0.15.1b/bit.c:168 in mad_bit_read
==1921==ABORTING

Expected results:
Test terminates with no error.

Additional info:
Related Debian security patch: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508133

Comment 1 Liu Woon Yung 2017-11-16 06:13:13 UTC
Created attachment 1353251 [details]
Test case for libmad's mad_bit_read() segment fault (fixed)

Contains libmadtest (test driver for libmad) & libmad_fault.mp3.
libmad_fault.mp3 is a test case that triggers fault in mad_bit_read(), via II_samples().

There are three possible areas in mad_bit_read() to fault in: line 142, 163 & 168. An out-of-bounds read can be made by this function, when called from either I_sample() or II_samples().

Comment 2 Ozkan Sezer 2018-02-09 19:38:17 UTC
Debian recently applied two patches to fix CVE-2017-8372, CVE-2017-8373
and CVE-2017-8374, which also fixes the segfault here.  The patches are
in their libmad-0.15.1b-9 package, here:
http://http.debian.net/debian/pool/main/libm/libmad/libmad_0.15.1b-9.diff.gz
The patches in question are 'md_size.diff' and 'length-check.patch', to
be applied in that order, both authored by Kurt Roeckx.  Attaching them
here for convenience.

c.f.: https://bugzilla.redhat.com/show_bug.cgi?id=1447357

Comment 3 Ozkan Sezer 2018-02-09 19:39:25 UTC
Created attachment 1393966 [details]
md_size.diff

patch for CVE-2017-8372 and CVE-2017-8373

Comment 4 Ozkan Sezer 2018-02-09 19:40:07 UTC
Created attachment 1393967 [details]
length-check.patch

patch for CVE-2017-8374

Comment 5 Fedora End Of Life 2018-05-03 08:23:43 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. 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 EOL if it remains open with a Fedora  'version'
of '26'.

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.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 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, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

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.

Comment 6 Ozkan Sezer 2018-05-03 08:31:00 UTC
This affects not only f26 but all fedoras with libmad included(In reply to Fedora End Of Life from comment #5)
> This message is a reminder that Fedora 26 is nearing its end of life.

This affects not only f26, but all fedoras with libmad included.

Comment 7 Fedora End Of Life 2018-05-29 12:40:54 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
is no longer maintained, which means that it will not receive any
further security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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