Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heap-Buffer Overflow in SDL_LoadWAV_RW (IMA_ADPCM_decode) #785

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

Heap-Buffer Overflow in SDL_LoadWAV_RW (IMA_ADPCM_decode) #785

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 1.2
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2019-02-07 04:17:28 +0000, Radue wrote:

Created attachment 3602
PoC

A heap buffer overflow vulnerability was discovered in SDL-1.2.15 library.

Asan output:

=================================================================
==23116==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61200000bfcd at pc 0x7fb733c1cdea bp 0x7ffc5475fa70 sp 0x7ffc5475fa68
READ of size 1 at 0x61200000bfcd thread T0
# 0 0x7fb733c1cde9 in IMA_ADPCM_decode /home/radu/apps/sdl_player_lib/SDL-1.2.15/build/../src/audio/SDL_wave.c:358:24
# 1 0x7fb733c1cde9 in SDL_LoadWAV_RW /home/radu/apps/sdl_player_lib/SDL-1.2.15/build/../src/audio/SDL_wave.c:542
# 2 0x4db938 in main /home/radu/apps/sdl_player_lib/SDL-1.2.15/test/loopwave.c:76:7
# 3 0x7fb73298e82f in __libc_start_main /build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:291
# 4 0x4352f8 in _start (/home/radu/apps/sdl_player_lib/SDL-1.2.15/test/loopwave+0x4352f8)

0x61200000bfcd is located 0 bytes to the right of 269-byte region [0x61200000bec0,0x61200000bfcd)
allocated by thread T0 here:
# 0 0x4bc2c2 in malloc (/home/radu/apps/sdl_player_lib/SDL-1.2.15/test/loopwave+0x4bc2c2)
# 1 0x7fb733c1cea1 in ReadChunk /home/radu/apps/sdl_player_lib/SDL-1.2.15/build/../src/audio/SDL_wave.c:584:25

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/radu/apps/sdl_player_lib/SDL-1.2.15/build/../src/audio/SDL_wave.c:358 IMA_ADPCM_decode
Shadow bytes around the buggy address:
0x0c247fff97a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff97b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff97c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff97d0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
0x0c247fff97e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c247fff97f0: 00 00 00 00 00 00 00 00 00[05]fa fa fa fa fa fa
0x0c247fff9800: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff9810: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff9820: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff9830: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff9840: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==23116==ABORTING

PoC: See attachment
Reproducing steps:

  1. Download SDL-1.2.15 library
  2. ./configure with Asan enabled
  3. ./make
  4. sudo make install
  5. cd examples
  6. ./configure with Asan enabled
  7. make
  8. ./loopwave PoC

On 2019-02-07 07:16:22 +0000, Radue wrote:

Assigned CVE-2019-7574 by MITRE.

On 2019-02-14 14:58:34 +0000, Petr Pisar wrote:

Created attachment 3610
Fix

On 2019-06-10 15:52:20 +0000, Sam Lantinga wrote:

Fixed, thanks!
https://hg.libsdl.org/SDL/rev/a6e3d2f5183e

This code has been rewritten in SDL 2.0, can you verify that this issue has been fixed there?
http://www.libsdl.org/tmp/SDL-2.0.zip

On 2019-06-10 21:01:34 +0000, Simon Hug wrote:

The WAVE file (attachment 3602) specifies a 1 byte IMA ADPCM block size with 57120 sample frames per block. Pretty good compression, if it would work like that. Also seems to have the MS ADPCM coefficients attached in the fmt chunk.

With the current tip, SDL_LoadWAV_RW rejects this file with "Invalid IMA ADPCM block size (nBlockAlign)" as it detects that the block size is just too small.

On 2019-06-11 13:24:52 +0000, Sam Lantinga wrote:

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant