Menu

#61 stack-buffer-overflow in WriteMP3GainAPETag apetag.c:592:3

v1.0 (example)
open
nobody
None
5
2025-07-11
2025-07-11
Kim Davies
No

stack-buffer-overflow in WriteMP3GainAPETag apetag.c:592:3

Environment:

Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04

Compiler:

Ubuntu clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix

Compiling:

CFLAGS="-fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -g" CXXFLAGS="-fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -g" make

Version:

commit f669c2c826411c132655be66465077e77f25d93d

PoCfile:

Unzip poc.zip.

Behavior:

./mp3gain poc/mp3gain_005.poc

Output:

/home/exp/src/mp3gain/mp3gain/mp3gain/apetag.c:296:39: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/exp/src/mp3gain/mp3gain/mp3gain/apetag.c:296:39 in 

/home/exp/src/mp3gain/mp3gain/mp3gain/apetag.c:492:37: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/exp/src/mp3gain/mp3gain/mp3gain/apetag.c:492:37 in 
/home/exp/src/mp3gain/mp3gain/mp3gain/apetag.c:496:72: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/exp/src/mp3gain/mp3gain/mp3gain/apetag.c:496:72 in 
=================================================================
==811175==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffcca02a3c4 at pc 0x557d4207ee34 bp 0x7ffcca02a240 sp 0x7ffcca0299e0
WRITE of size 311 at 0x7ffcca02a3c4 thread T0
    #0 0x557d4207ee33 in __interceptor_vsprintf (/home/exp/bin/asan_ubsan/mp3gain+0x71e33) (BuildId: 6adba16c3fc2a25561194f170abc8ab9f4e2b498)
    #1 0x557d4207fe27 in sprintf (/home/exp/bin/asan_ubsan/mp3gain+0x72e27) (BuildId: 6adba16c3fc2a25561194f170abc8ab9f4e2b498)
    #2 0x557d42151508 in WriteMP3GainAPETag /home/exp/src/mp3gain/mp3gain/mp3gain/apetag.c:592:3
    #3 0x557d42123f61 in WriteMP3GainTag /home/exp/src/mp3gain/mp3gain/mp3gain/mp3gain.c:1143:3
    #4 0x557d4213fc13 in main_impl /home/exp/src/mp3gain/mp3gain/mp3gain/mp3gain.c:2722:6
    #5 0x557d42125431 in main /home/exp/src/mp3gain/mp3gain/mp3gain/mp3gain.c:2830:9
    #6 0x7fea0122a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #7 0x7fea0122a28a in __libc_start_main csu/../csu/libc-start.c:360:3
    #8 0x557d4205c4b4 in _start (/home/exp/bin/asan_ubsan/mp3gain+0x4f4b4) (BuildId: 6adba16c3fc2a25561194f170abc8ab9f4e2b498)

Address 0x7ffcca02a3c4 is located in stack of thread T0 at offset 132 in frame
    #0 0x557d4214d84f in WriteMP3GainAPETag /home/exp/src/mp3gain/mp3gain/mp3gain/apetag.c:404

  This frame has 3 object(s):
    [32, 132) 'valueString' (line 411)
    [176, 208) 'newFooter' (line 413) <== Memory access at offset 132 partially underflows this variable
    [240, 272) 'newHeader' (line 414) <== Memory access at offset 132 partially underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/exp/bin/asan_ubsan/mp3gain+0x71e33) (BuildId: 6adba16c3fc2a25561194f170abc8ab9f4e2b498) in __interceptor_vsprintf
Shadow bytes around the buggy address:
  0x1000193fd420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000193fd430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000193fd440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000193fd450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000193fd460: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00 00 00
=>0x1000193fd470: 00 00 00 00 00 00 00 00[04]f2 f2 f2 f2 f2 00 00
  0x1000193fd480: 00 00 f2 f2 f2 f2 00 00 00 00 f3 f3 f3 f3 f3 f3
  0x1000193fd490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000193fd4a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000193fd4b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000193fd4c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  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
==811175==ABORTING
1 Attachments

Discussion


Log in to post a comment.

MongoDB Logo MongoDB