Menu

#17 Buffer overflow (READ of size 1) in the add_label() function

1.09
open
nobody
None
5
2021-04-03
2021-04-03
bsdb0y
No

Hi,

While fuzzing ATasm 1.09, I found a buffer overflow in the add_label() function, asm.c

Attaching a reproducer, issue can be reproduced by running:

atasm add_label_test02

ATasm 1.09 (A mostly Mac65 compatible 6502 cross-assembler)
Pass 1: =================================================================
==11687==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000000e175df at pc 0x0000004d22fc bp 0x7ffc503be8b0 sp 0x7ffc503be8a8
READ of size 1 at 0x000000e175df thread T0
    #0 0x4d22fb in add_label /src/atasm109/src/asm.c:811:7
    #1 0x4e8958 in do_cmd /src/atasm109/src/asm.c:1963:5
    #2 0x4e8958 in assemble /src/atasm109/src/asm.c:2009:9
    #3 0x4eb4c7 in main /src/atasm109/src/asm.c:2421:3
    #4 0x7f7b7da250b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #5 0x41c5ed in _start (/src/atasm109/src/atasm+0x41c5ed)

0x000000e175df is located 1 bytes to the left of global variable 'buf' defined in 'asm.c:372:15' (0xe175e0) of size 256
0x000000e175df is located 55 bytes to the right of global variable 'listFile' defined in 'asm.c:159:7' (0xe175a0) of size 8
SUMMARY: AddressSanitizer: global-buffer-overflow /src/atasm109/src/asm.c:811:7 in add_label
Shadow bytes around the buggy address:
  0x0000801bae60: f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9
  0x0000801bae70: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9
  0x0000801bae80: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9
  0x0000801bae90: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9
  0x0000801baea0: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9
=>0x0000801baeb0: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9[f9]00 00 00 00
  0x0000801baec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0000801baed0: 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9
  0x0000801baee0: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
  0x0000801baef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0000801baf00: 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9
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
  Shadow gap:              cc
==11687==ABORTING
1 Attachments

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.